@maxim_mazurok/gapi.client.language-v2 0.0.20230812
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.d.ts +651 -0
- package/package.json +20 -0
- package/readme.md +96 -0
- package/tests.ts +94 -0
- package/tsconfig.json +18 -0
- package/tslint.json +6 -0
package/index.d.ts
ADDED
|
@@ -0,0 +1,651 @@
|
|
|
1
|
+
/* Type definitions for non-npm package Cloud Natural Language API v2 0.0 */
|
|
2
|
+
// Project: https://cloud.google.com/natural-language/
|
|
3
|
+
// Definitions by: Maxim Mazurok <https://github.com/Maxim-Mazurok>
|
|
4
|
+
// Nick Amoscato <https://github.com/namoscato>
|
|
5
|
+
// Declan Vong <https://github.com/declanvong>
|
|
6
|
+
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
|
7
|
+
|
|
8
|
+
// IMPORTANT
|
|
9
|
+
// This file was generated by https://github.com/Maxim-Mazurok/google-api-typings-generator. Please do not edit it manually.
|
|
10
|
+
// In case of any problems please post issue to https://github.com/Maxim-Mazurok/google-api-typings-generator
|
|
11
|
+
// Generated from: https://language.googleapis.com/$discovery/rest?version=v2
|
|
12
|
+
// Revision: 20230812
|
|
13
|
+
|
|
14
|
+
/// <reference types="gapi.client" />
|
|
15
|
+
|
|
16
|
+
declare namespace gapi.client {
|
|
17
|
+
/** Load Cloud Natural Language API v2 */
|
|
18
|
+
function load(urlOrObject: "https://language.googleapis.com/$discovery/rest?version=v2"): Promise<void>;
|
|
19
|
+
/** @deprecated Please load APIs with discovery documents. */
|
|
20
|
+
function load(name: "language", version: "v2"): Promise<void>;
|
|
21
|
+
/** @deprecated Please load APIs with discovery documents. */
|
|
22
|
+
function load(name: "language", version: "v2", callback: () => any): void;
|
|
23
|
+
|
|
24
|
+
namespace language {
|
|
25
|
+
interface AnalyzeEntitiesRequest {
|
|
26
|
+
/** Required. Input document. */
|
|
27
|
+
document?:
|
|
28
|
+
Document;
|
|
29
|
+
/** The encoding type used by the API to calculate offsets. */
|
|
30
|
+
encodingType?:
|
|
31
|
+
string;
|
|
32
|
+
}
|
|
33
|
+
interface AnalyzeEntitiesResponse {
|
|
34
|
+
/** The recognized entities in the input document. */
|
|
35
|
+
entities?:
|
|
36
|
+
Entity[];
|
|
37
|
+
/**
|
|
38
|
+
* The language of the text, which will be the same as the language specified in the request or, if not specified, the automatically-detected language. See Document.language field for
|
|
39
|
+
* more details.
|
|
40
|
+
*/
|
|
41
|
+
languageCode?:
|
|
42
|
+
string;
|
|
43
|
+
/** Whether the language is officially supported. The API may still return a response when the language is not supported, but it is on a best effort basis. */
|
|
44
|
+
languageSupported?:
|
|
45
|
+
boolean;
|
|
46
|
+
}
|
|
47
|
+
interface AnalyzeSentimentRequest {
|
|
48
|
+
/** Required. Input document. */
|
|
49
|
+
document?:
|
|
50
|
+
Document;
|
|
51
|
+
/** The encoding type used by the API to calculate sentence offsets. */
|
|
52
|
+
encodingType?:
|
|
53
|
+
string;
|
|
54
|
+
}
|
|
55
|
+
interface AnalyzeSentimentResponse {
|
|
56
|
+
/** The overall sentiment of the input document. */
|
|
57
|
+
documentSentiment?:
|
|
58
|
+
Sentiment;
|
|
59
|
+
/**
|
|
60
|
+
* The language of the text, which will be the same as the language specified in the request or, if not specified, the automatically-detected language. See Document.language field for
|
|
61
|
+
* more details.
|
|
62
|
+
*/
|
|
63
|
+
languageCode?:
|
|
64
|
+
string;
|
|
65
|
+
/** Whether the language is officially supported. The API may still return a response when the language is not supported, but it is on a best effort basis. */
|
|
66
|
+
languageSupported?:
|
|
67
|
+
boolean;
|
|
68
|
+
/** The sentiment for all the sentences in the document. */
|
|
69
|
+
sentences?:
|
|
70
|
+
Sentence[];
|
|
71
|
+
}
|
|
72
|
+
interface AnnotateTextRequest {
|
|
73
|
+
/** Required. Input document. */
|
|
74
|
+
document?:
|
|
75
|
+
Document;
|
|
76
|
+
/** The encoding type used by the API to calculate offsets. */
|
|
77
|
+
encodingType?:
|
|
78
|
+
string;
|
|
79
|
+
/** Required. The enabled features. */
|
|
80
|
+
features?:
|
|
81
|
+
Features;
|
|
82
|
+
}
|
|
83
|
+
interface AnnotateTextResponse {
|
|
84
|
+
/** Categories identified in the input document. */
|
|
85
|
+
categories?:
|
|
86
|
+
ClassificationCategory[];
|
|
87
|
+
/** The overall sentiment for the document. Populated if the user enables AnnotateTextRequest.Features.extract_document_sentiment. */
|
|
88
|
+
documentSentiment?:
|
|
89
|
+
Sentiment;
|
|
90
|
+
/**
|
|
91
|
+
* Entities, along with their semantic information, in the input document. Populated if the user enables AnnotateTextRequest.Features.extract_entities or
|
|
92
|
+
* AnnotateTextRequest.Features.extract_entity_sentiment.
|
|
93
|
+
*/
|
|
94
|
+
entities?:
|
|
95
|
+
Entity[];
|
|
96
|
+
/**
|
|
97
|
+
* The language of the text, which will be the same as the language specified in the request or, if not specified, the automatically-detected language. See Document.language field for
|
|
98
|
+
* more details.
|
|
99
|
+
*/
|
|
100
|
+
languageCode?:
|
|
101
|
+
string;
|
|
102
|
+
/** Whether the language is officially supported by all requested features. The API may still return a response when the language is not supported, but it is on a best effort basis. */
|
|
103
|
+
languageSupported?:
|
|
104
|
+
boolean;
|
|
105
|
+
/** Harmful and sensitive categories identified in the input document. */
|
|
106
|
+
moderationCategories?:
|
|
107
|
+
ClassificationCategory[];
|
|
108
|
+
/** Sentences in the input document. Populated if the user enables AnnotateTextRequest.Features.extract_document_sentiment. */
|
|
109
|
+
sentences?:
|
|
110
|
+
Sentence[];
|
|
111
|
+
}
|
|
112
|
+
interface ClassificationCategory {
|
|
113
|
+
/** The classifier's confidence of the category. Number represents how certain the classifier is that this category represents the given text. */
|
|
114
|
+
confidence?:
|
|
115
|
+
number;
|
|
116
|
+
/** The name of the category representing the document. */
|
|
117
|
+
name?:
|
|
118
|
+
string;
|
|
119
|
+
}
|
|
120
|
+
interface ClassifyTextRequest {
|
|
121
|
+
/** Required. Input document. */
|
|
122
|
+
document?:
|
|
123
|
+
Document;
|
|
124
|
+
}
|
|
125
|
+
interface ClassifyTextResponse {
|
|
126
|
+
/** Categories representing the input document. */
|
|
127
|
+
categories?:
|
|
128
|
+
ClassificationCategory[];
|
|
129
|
+
/**
|
|
130
|
+
* The language of the text, which will be the same as the language specified in the request or, if not specified, the automatically-detected language. See Document.language field for
|
|
131
|
+
* more details.
|
|
132
|
+
*/
|
|
133
|
+
languageCode?:
|
|
134
|
+
string;
|
|
135
|
+
/** Whether the language is officially supported. The API may still return a response when the language is not supported, but it is on a best effort basis. */
|
|
136
|
+
languageSupported?:
|
|
137
|
+
boolean;
|
|
138
|
+
}
|
|
139
|
+
interface Document {
|
|
140
|
+
/** The content of the input in string format. Cloud audit logging exempt since it is based on user data. */
|
|
141
|
+
content?:
|
|
142
|
+
string;
|
|
143
|
+
/**
|
|
144
|
+
* The Google Cloud Storage URI where the file content is located. This URI must be of the form: gs://bucket_name/object_name. For more details, see
|
|
145
|
+
* https://cloud.google.com/storage/docs/reference-uris. NOTE: Cloud Storage object versioning is not supported.
|
|
146
|
+
*/
|
|
147
|
+
gcsContentUri?:
|
|
148
|
+
string;
|
|
149
|
+
/**
|
|
150
|
+
* Optional. The language of the document (if not specified, the language is automatically detected). Both ISO and BCP-47 language codes are accepted. [Language
|
|
151
|
+
* Support](https://cloud.google.com/natural-language/docs/languages) lists currently supported languages for each API method. If the language (either specified by the caller or
|
|
152
|
+
* automatically detected) is not supported by the called API method, an `INVALID_ARGUMENT` error is returned.
|
|
153
|
+
*/
|
|
154
|
+
languageCode?:
|
|
155
|
+
string;
|
|
156
|
+
/** Required. If the type is not set or is `TYPE_UNSPECIFIED`, returns an `INVALID_ARGUMENT` error. */
|
|
157
|
+
type?:
|
|
158
|
+
string;
|
|
159
|
+
}
|
|
160
|
+
interface Entity {
|
|
161
|
+
/** The mentions of this entity in the input document. The API currently supports proper noun mentions. */
|
|
162
|
+
mentions?:
|
|
163
|
+
EntityMention[];
|
|
164
|
+
/**
|
|
165
|
+
* Metadata associated with the entity. For most entity types, the metadata is a Wikipedia URL (`wikipedia_url`) and Knowledge Graph MID (`mid`), if they are available. For the
|
|
166
|
+
* metadata associated with other entity types, see the Type table below.
|
|
167
|
+
*/
|
|
168
|
+
metadata?:
|
|
169
|
+
{ [P in string]: string };
|
|
170
|
+
/** The representative name for the entity. */
|
|
171
|
+
name?:
|
|
172
|
+
string;
|
|
173
|
+
/**
|
|
174
|
+
* For calls to AnalyzeEntitySentiment or if AnnotateTextRequest.Features.extract_entity_sentiment is set to true, this field will contain the aggregate sentiment expressed for this
|
|
175
|
+
* entity in the provided document.
|
|
176
|
+
*/
|
|
177
|
+
sentiment?:
|
|
178
|
+
Sentiment;
|
|
179
|
+
/** The entity type. */
|
|
180
|
+
type?:
|
|
181
|
+
string;
|
|
182
|
+
}
|
|
183
|
+
interface EntityMention {
|
|
184
|
+
/** Probability score associated with the entity. The score shows the probability of the entity mention being the entity type. The score is in (0, 1] range. */
|
|
185
|
+
probability?:
|
|
186
|
+
number;
|
|
187
|
+
/**
|
|
188
|
+
* For calls to AnalyzeEntitySentiment or if AnnotateTextRequest.Features.extract_entity_sentiment is set to true, this field will contain the sentiment expressed for this mention of
|
|
189
|
+
* the entity in the provided document.
|
|
190
|
+
*/
|
|
191
|
+
sentiment?:
|
|
192
|
+
Sentiment;
|
|
193
|
+
/** The mention text. */
|
|
194
|
+
text?:
|
|
195
|
+
TextSpan;
|
|
196
|
+
/** The type of the entity mention. */
|
|
197
|
+
type?:
|
|
198
|
+
string;
|
|
199
|
+
}
|
|
200
|
+
interface Features {
|
|
201
|
+
/** Optional. Classify the full document into categories. */
|
|
202
|
+
classifyText?:
|
|
203
|
+
boolean;
|
|
204
|
+
/** Optional. Extract document-level sentiment. */
|
|
205
|
+
extractDocumentSentiment?:
|
|
206
|
+
boolean;
|
|
207
|
+
/** Optional. Extract entities. */
|
|
208
|
+
extractEntities?:
|
|
209
|
+
boolean;
|
|
210
|
+
/** Optional. Moderate the document for harmful and sensitive categories. */
|
|
211
|
+
moderateText?:
|
|
212
|
+
boolean;
|
|
213
|
+
}
|
|
214
|
+
interface ModerateTextRequest {
|
|
215
|
+
/** Required. Input document. */
|
|
216
|
+
document?:
|
|
217
|
+
Document;
|
|
218
|
+
}
|
|
219
|
+
interface ModerateTextResponse {
|
|
220
|
+
/**
|
|
221
|
+
* The language of the text, which will be the same as the language specified in the request or, if not specified, the automatically-detected language. See Document.language field for
|
|
222
|
+
* more details.
|
|
223
|
+
*/
|
|
224
|
+
languageCode?:
|
|
225
|
+
string;
|
|
226
|
+
/** Whether the language is officially supported. The API may still return a response when the language is not supported, but it is on a best effort basis. */
|
|
227
|
+
languageSupported?:
|
|
228
|
+
boolean;
|
|
229
|
+
/** Harmful and sensitive categories representing the input document. */
|
|
230
|
+
moderationCategories?:
|
|
231
|
+
ClassificationCategory[];
|
|
232
|
+
}
|
|
233
|
+
interface Sentence {
|
|
234
|
+
/** For calls to AnalyzeSentiment or if AnnotateTextRequest.Features.extract_document_sentiment is set to true, this field will contain the sentiment for the sentence. */
|
|
235
|
+
sentiment?:
|
|
236
|
+
Sentiment;
|
|
237
|
+
/** The sentence text. */
|
|
238
|
+
text?:
|
|
239
|
+
TextSpan;
|
|
240
|
+
}
|
|
241
|
+
interface Sentiment {
|
|
242
|
+
/** A non-negative number in the [0, +inf) range, which represents the absolute magnitude of sentiment regardless of score (positive or negative). */
|
|
243
|
+
magnitude?:
|
|
244
|
+
number;
|
|
245
|
+
/** Sentiment score between -1.0 (negative sentiment) and 1.0 (positive sentiment). */
|
|
246
|
+
score?:
|
|
247
|
+
number;
|
|
248
|
+
}
|
|
249
|
+
interface Status {
|
|
250
|
+
/** The status code, which should be an enum value of google.rpc.Code. */
|
|
251
|
+
code?:
|
|
252
|
+
number;
|
|
253
|
+
/** A list of messages that carry the error details. There is a common set of message types for APIs to use. */
|
|
254
|
+
details?:
|
|
255
|
+
Array<{ [P in string]: any }>;
|
|
256
|
+
/**
|
|
257
|
+
* A developer-facing error message, which should be in English. Any user-facing error message should be localized and sent in the google.rpc.Status.details field, or localized by the
|
|
258
|
+
* client.
|
|
259
|
+
*/
|
|
260
|
+
message?:
|
|
261
|
+
string;
|
|
262
|
+
}
|
|
263
|
+
interface TextSpan {
|
|
264
|
+
/** The API calculates the beginning offset of the content in the original document according to the EncodingType specified in the API request. */
|
|
265
|
+
beginOffset?:
|
|
266
|
+
number;
|
|
267
|
+
/** The content of the text span, which is a substring of the document. */
|
|
268
|
+
content?:
|
|
269
|
+
string;
|
|
270
|
+
}
|
|
271
|
+
interface DocumentsResource {
|
|
272
|
+
/** Finds named entities (currently proper names and common nouns) in the text along with entity types, probability, mentions for each entity, and other properties. */
|
|
273
|
+
analyzeEntities(request: {
|
|
274
|
+
/** V1 error format. */
|
|
275
|
+
"$.xgafv"?:
|
|
276
|
+
string;
|
|
277
|
+
/** OAuth access token. */
|
|
278
|
+
access_token?:
|
|
279
|
+
string;
|
|
280
|
+
/** Data format for response. */
|
|
281
|
+
alt?:
|
|
282
|
+
string;
|
|
283
|
+
/** JSONP */
|
|
284
|
+
callback?:
|
|
285
|
+
string;
|
|
286
|
+
/** Selector specifying which fields to include in a partial response. */
|
|
287
|
+
fields?:
|
|
288
|
+
string;
|
|
289
|
+
/** API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. */
|
|
290
|
+
key?:
|
|
291
|
+
string;
|
|
292
|
+
/** OAuth 2.0 token for the current user. */
|
|
293
|
+
oauth_token?:
|
|
294
|
+
string;
|
|
295
|
+
/** Returns response with indentations and line breaks. */
|
|
296
|
+
prettyPrint?:
|
|
297
|
+
boolean;
|
|
298
|
+
/** Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. */
|
|
299
|
+
quotaUser?:
|
|
300
|
+
string;
|
|
301
|
+
/** Upload protocol for media (e.g. "raw", "multipart"). */
|
|
302
|
+
upload_protocol?:
|
|
303
|
+
string;
|
|
304
|
+
/** Legacy upload protocol for media (e.g. "media", "multipart"). */
|
|
305
|
+
uploadType?:
|
|
306
|
+
string;
|
|
307
|
+
/** Request body */
|
|
308
|
+
resource:
|
|
309
|
+
AnalyzeEntitiesRequest;
|
|
310
|
+
}): Request<AnalyzeEntitiesResponse>;
|
|
311
|
+
analyzeEntities(request: {
|
|
312
|
+
/** V1 error format. */
|
|
313
|
+
"$.xgafv"?:
|
|
314
|
+
string;
|
|
315
|
+
/** OAuth access token. */
|
|
316
|
+
access_token?:
|
|
317
|
+
string;
|
|
318
|
+
/** Data format for response. */
|
|
319
|
+
alt?:
|
|
320
|
+
string;
|
|
321
|
+
/** JSONP */
|
|
322
|
+
callback?:
|
|
323
|
+
string;
|
|
324
|
+
/** Selector specifying which fields to include in a partial response. */
|
|
325
|
+
fields?:
|
|
326
|
+
string;
|
|
327
|
+
/** API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. */
|
|
328
|
+
key?:
|
|
329
|
+
string;
|
|
330
|
+
/** OAuth 2.0 token for the current user. */
|
|
331
|
+
oauth_token?:
|
|
332
|
+
string;
|
|
333
|
+
/** Returns response with indentations and line breaks. */
|
|
334
|
+
prettyPrint?:
|
|
335
|
+
boolean;
|
|
336
|
+
/** Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. */
|
|
337
|
+
quotaUser?:
|
|
338
|
+
string;
|
|
339
|
+
/** Upload protocol for media (e.g. "raw", "multipart"). */
|
|
340
|
+
upload_protocol?:
|
|
341
|
+
string;
|
|
342
|
+
/** Legacy upload protocol for media (e.g. "media", "multipart"). */
|
|
343
|
+
uploadType?:
|
|
344
|
+
string;
|
|
345
|
+
},
|
|
346
|
+
body: AnalyzeEntitiesRequest): Request<AnalyzeEntitiesResponse>;
|
|
347
|
+
/** Analyzes the sentiment of the provided text. */
|
|
348
|
+
analyzeSentiment(request: {
|
|
349
|
+
/** V1 error format. */
|
|
350
|
+
"$.xgafv"?:
|
|
351
|
+
string;
|
|
352
|
+
/** OAuth access token. */
|
|
353
|
+
access_token?:
|
|
354
|
+
string;
|
|
355
|
+
/** Data format for response. */
|
|
356
|
+
alt?:
|
|
357
|
+
string;
|
|
358
|
+
/** JSONP */
|
|
359
|
+
callback?:
|
|
360
|
+
string;
|
|
361
|
+
/** Selector specifying which fields to include in a partial response. */
|
|
362
|
+
fields?:
|
|
363
|
+
string;
|
|
364
|
+
/** API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. */
|
|
365
|
+
key?:
|
|
366
|
+
string;
|
|
367
|
+
/** OAuth 2.0 token for the current user. */
|
|
368
|
+
oauth_token?:
|
|
369
|
+
string;
|
|
370
|
+
/** Returns response with indentations and line breaks. */
|
|
371
|
+
prettyPrint?:
|
|
372
|
+
boolean;
|
|
373
|
+
/** Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. */
|
|
374
|
+
quotaUser?:
|
|
375
|
+
string;
|
|
376
|
+
/** Upload protocol for media (e.g. "raw", "multipart"). */
|
|
377
|
+
upload_protocol?:
|
|
378
|
+
string;
|
|
379
|
+
/** Legacy upload protocol for media (e.g. "media", "multipart"). */
|
|
380
|
+
uploadType?:
|
|
381
|
+
string;
|
|
382
|
+
/** Request body */
|
|
383
|
+
resource:
|
|
384
|
+
AnalyzeSentimentRequest;
|
|
385
|
+
}): Request<AnalyzeSentimentResponse>;
|
|
386
|
+
analyzeSentiment(request: {
|
|
387
|
+
/** V1 error format. */
|
|
388
|
+
"$.xgafv"?:
|
|
389
|
+
string;
|
|
390
|
+
/** OAuth access token. */
|
|
391
|
+
access_token?:
|
|
392
|
+
string;
|
|
393
|
+
/** Data format for response. */
|
|
394
|
+
alt?:
|
|
395
|
+
string;
|
|
396
|
+
/** JSONP */
|
|
397
|
+
callback?:
|
|
398
|
+
string;
|
|
399
|
+
/** Selector specifying which fields to include in a partial response. */
|
|
400
|
+
fields?:
|
|
401
|
+
string;
|
|
402
|
+
/** API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. */
|
|
403
|
+
key?:
|
|
404
|
+
string;
|
|
405
|
+
/** OAuth 2.0 token for the current user. */
|
|
406
|
+
oauth_token?:
|
|
407
|
+
string;
|
|
408
|
+
/** Returns response with indentations and line breaks. */
|
|
409
|
+
prettyPrint?:
|
|
410
|
+
boolean;
|
|
411
|
+
/** Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. */
|
|
412
|
+
quotaUser?:
|
|
413
|
+
string;
|
|
414
|
+
/** Upload protocol for media (e.g. "raw", "multipart"). */
|
|
415
|
+
upload_protocol?:
|
|
416
|
+
string;
|
|
417
|
+
/** Legacy upload protocol for media (e.g. "media", "multipart"). */
|
|
418
|
+
uploadType?:
|
|
419
|
+
string;
|
|
420
|
+
},
|
|
421
|
+
body: AnalyzeSentimentRequest): Request<AnalyzeSentimentResponse>;
|
|
422
|
+
/** A convenience method that provides all features in one call. */
|
|
423
|
+
annotateText(request: {
|
|
424
|
+
/** V1 error format. */
|
|
425
|
+
"$.xgafv"?:
|
|
426
|
+
string;
|
|
427
|
+
/** OAuth access token. */
|
|
428
|
+
access_token?:
|
|
429
|
+
string;
|
|
430
|
+
/** Data format for response. */
|
|
431
|
+
alt?:
|
|
432
|
+
string;
|
|
433
|
+
/** JSONP */
|
|
434
|
+
callback?:
|
|
435
|
+
string;
|
|
436
|
+
/** Selector specifying which fields to include in a partial response. */
|
|
437
|
+
fields?:
|
|
438
|
+
string;
|
|
439
|
+
/** API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. */
|
|
440
|
+
key?:
|
|
441
|
+
string;
|
|
442
|
+
/** OAuth 2.0 token for the current user. */
|
|
443
|
+
oauth_token?:
|
|
444
|
+
string;
|
|
445
|
+
/** Returns response with indentations and line breaks. */
|
|
446
|
+
prettyPrint?:
|
|
447
|
+
boolean;
|
|
448
|
+
/** Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. */
|
|
449
|
+
quotaUser?:
|
|
450
|
+
string;
|
|
451
|
+
/** Upload protocol for media (e.g. "raw", "multipart"). */
|
|
452
|
+
upload_protocol?:
|
|
453
|
+
string;
|
|
454
|
+
/** Legacy upload protocol for media (e.g. "media", "multipart"). */
|
|
455
|
+
uploadType?:
|
|
456
|
+
string;
|
|
457
|
+
/** Request body */
|
|
458
|
+
resource:
|
|
459
|
+
AnnotateTextRequest;
|
|
460
|
+
}): Request<AnnotateTextResponse>;
|
|
461
|
+
annotateText(request: {
|
|
462
|
+
/** V1 error format. */
|
|
463
|
+
"$.xgafv"?:
|
|
464
|
+
string;
|
|
465
|
+
/** OAuth access token. */
|
|
466
|
+
access_token?:
|
|
467
|
+
string;
|
|
468
|
+
/** Data format for response. */
|
|
469
|
+
alt?:
|
|
470
|
+
string;
|
|
471
|
+
/** JSONP */
|
|
472
|
+
callback?:
|
|
473
|
+
string;
|
|
474
|
+
/** Selector specifying which fields to include in a partial response. */
|
|
475
|
+
fields?:
|
|
476
|
+
string;
|
|
477
|
+
/** API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. */
|
|
478
|
+
key?:
|
|
479
|
+
string;
|
|
480
|
+
/** OAuth 2.0 token for the current user. */
|
|
481
|
+
oauth_token?:
|
|
482
|
+
string;
|
|
483
|
+
/** Returns response with indentations and line breaks. */
|
|
484
|
+
prettyPrint?:
|
|
485
|
+
boolean;
|
|
486
|
+
/** Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. */
|
|
487
|
+
quotaUser?:
|
|
488
|
+
string;
|
|
489
|
+
/** Upload protocol for media (e.g. "raw", "multipart"). */
|
|
490
|
+
upload_protocol?:
|
|
491
|
+
string;
|
|
492
|
+
/** Legacy upload protocol for media (e.g. "media", "multipart"). */
|
|
493
|
+
uploadType?:
|
|
494
|
+
string;
|
|
495
|
+
},
|
|
496
|
+
body: AnnotateTextRequest): Request<AnnotateTextResponse>;
|
|
497
|
+
/** Classifies a document into categories. */
|
|
498
|
+
classifyText(request: {
|
|
499
|
+
/** V1 error format. */
|
|
500
|
+
"$.xgafv"?:
|
|
501
|
+
string;
|
|
502
|
+
/** OAuth access token. */
|
|
503
|
+
access_token?:
|
|
504
|
+
string;
|
|
505
|
+
/** Data format for response. */
|
|
506
|
+
alt?:
|
|
507
|
+
string;
|
|
508
|
+
/** JSONP */
|
|
509
|
+
callback?:
|
|
510
|
+
string;
|
|
511
|
+
/** Selector specifying which fields to include in a partial response. */
|
|
512
|
+
fields?:
|
|
513
|
+
string;
|
|
514
|
+
/** API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. */
|
|
515
|
+
key?:
|
|
516
|
+
string;
|
|
517
|
+
/** OAuth 2.0 token for the current user. */
|
|
518
|
+
oauth_token?:
|
|
519
|
+
string;
|
|
520
|
+
/** Returns response with indentations and line breaks. */
|
|
521
|
+
prettyPrint?:
|
|
522
|
+
boolean;
|
|
523
|
+
/** Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. */
|
|
524
|
+
quotaUser?:
|
|
525
|
+
string;
|
|
526
|
+
/** Upload protocol for media (e.g. "raw", "multipart"). */
|
|
527
|
+
upload_protocol?:
|
|
528
|
+
string;
|
|
529
|
+
/** Legacy upload protocol for media (e.g. "media", "multipart"). */
|
|
530
|
+
uploadType?:
|
|
531
|
+
string;
|
|
532
|
+
/** Request body */
|
|
533
|
+
resource:
|
|
534
|
+
ClassifyTextRequest;
|
|
535
|
+
}): Request<ClassifyTextResponse>;
|
|
536
|
+
classifyText(request: {
|
|
537
|
+
/** V1 error format. */
|
|
538
|
+
"$.xgafv"?:
|
|
539
|
+
string;
|
|
540
|
+
/** OAuth access token. */
|
|
541
|
+
access_token?:
|
|
542
|
+
string;
|
|
543
|
+
/** Data format for response. */
|
|
544
|
+
alt?:
|
|
545
|
+
string;
|
|
546
|
+
/** JSONP */
|
|
547
|
+
callback?:
|
|
548
|
+
string;
|
|
549
|
+
/** Selector specifying which fields to include in a partial response. */
|
|
550
|
+
fields?:
|
|
551
|
+
string;
|
|
552
|
+
/** API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. */
|
|
553
|
+
key?:
|
|
554
|
+
string;
|
|
555
|
+
/** OAuth 2.0 token for the current user. */
|
|
556
|
+
oauth_token?:
|
|
557
|
+
string;
|
|
558
|
+
/** Returns response with indentations and line breaks. */
|
|
559
|
+
prettyPrint?:
|
|
560
|
+
boolean;
|
|
561
|
+
/** Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. */
|
|
562
|
+
quotaUser?:
|
|
563
|
+
string;
|
|
564
|
+
/** Upload protocol for media (e.g. "raw", "multipart"). */
|
|
565
|
+
upload_protocol?:
|
|
566
|
+
string;
|
|
567
|
+
/** Legacy upload protocol for media (e.g. "media", "multipart"). */
|
|
568
|
+
uploadType?:
|
|
569
|
+
string;
|
|
570
|
+
},
|
|
571
|
+
body: ClassifyTextRequest): Request<ClassifyTextResponse>;
|
|
572
|
+
/** Moderates a document for harmful and sensitive categories. */
|
|
573
|
+
moderateText(request: {
|
|
574
|
+
/** V1 error format. */
|
|
575
|
+
"$.xgafv"?:
|
|
576
|
+
string;
|
|
577
|
+
/** OAuth access token. */
|
|
578
|
+
access_token?:
|
|
579
|
+
string;
|
|
580
|
+
/** Data format for response. */
|
|
581
|
+
alt?:
|
|
582
|
+
string;
|
|
583
|
+
/** JSONP */
|
|
584
|
+
callback?:
|
|
585
|
+
string;
|
|
586
|
+
/** Selector specifying which fields to include in a partial response. */
|
|
587
|
+
fields?:
|
|
588
|
+
string;
|
|
589
|
+
/** API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. */
|
|
590
|
+
key?:
|
|
591
|
+
string;
|
|
592
|
+
/** OAuth 2.0 token for the current user. */
|
|
593
|
+
oauth_token?:
|
|
594
|
+
string;
|
|
595
|
+
/** Returns response with indentations and line breaks. */
|
|
596
|
+
prettyPrint?:
|
|
597
|
+
boolean;
|
|
598
|
+
/** Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. */
|
|
599
|
+
quotaUser?:
|
|
600
|
+
string;
|
|
601
|
+
/** Upload protocol for media (e.g. "raw", "multipart"). */
|
|
602
|
+
upload_protocol?:
|
|
603
|
+
string;
|
|
604
|
+
/** Legacy upload protocol for media (e.g. "media", "multipart"). */
|
|
605
|
+
uploadType?:
|
|
606
|
+
string;
|
|
607
|
+
/** Request body */
|
|
608
|
+
resource:
|
|
609
|
+
ModerateTextRequest;
|
|
610
|
+
}): Request<ModerateTextResponse>;
|
|
611
|
+
moderateText(request: {
|
|
612
|
+
/** V1 error format. */
|
|
613
|
+
"$.xgafv"?:
|
|
614
|
+
string;
|
|
615
|
+
/** OAuth access token. */
|
|
616
|
+
access_token?:
|
|
617
|
+
string;
|
|
618
|
+
/** Data format for response. */
|
|
619
|
+
alt?:
|
|
620
|
+
string;
|
|
621
|
+
/** JSONP */
|
|
622
|
+
callback?:
|
|
623
|
+
string;
|
|
624
|
+
/** Selector specifying which fields to include in a partial response. */
|
|
625
|
+
fields?:
|
|
626
|
+
string;
|
|
627
|
+
/** API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. */
|
|
628
|
+
key?:
|
|
629
|
+
string;
|
|
630
|
+
/** OAuth 2.0 token for the current user. */
|
|
631
|
+
oauth_token?:
|
|
632
|
+
string;
|
|
633
|
+
/** Returns response with indentations and line breaks. */
|
|
634
|
+
prettyPrint?:
|
|
635
|
+
boolean;
|
|
636
|
+
/** Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. */
|
|
637
|
+
quotaUser?:
|
|
638
|
+
string;
|
|
639
|
+
/** Upload protocol for media (e.g. "raw", "multipart"). */
|
|
640
|
+
upload_protocol?:
|
|
641
|
+
string;
|
|
642
|
+
/** Legacy upload protocol for media (e.g. "media", "multipart"). */
|
|
643
|
+
uploadType?:
|
|
644
|
+
string;
|
|
645
|
+
},
|
|
646
|
+
body: ModerateTextRequest): Request<ModerateTextResponse>;
|
|
647
|
+
}
|
|
648
|
+
|
|
649
|
+
const documents: DocumentsResource;
|
|
650
|
+
}
|
|
651
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@maxim_mazurok/gapi.client.language-v2",
|
|
3
|
+
"version": "0.0.20230812",
|
|
4
|
+
"description": "TypeScript typings for Cloud Natural Language API v2",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"author": {
|
|
7
|
+
"email": "maxim@mazurok.com",
|
|
8
|
+
"name": "Maxim Mazurok",
|
|
9
|
+
"url": "https://maxim.mazurok.com"
|
|
10
|
+
},
|
|
11
|
+
"repository": {
|
|
12
|
+
"type": "git",
|
|
13
|
+
"url": "https://github.com/Maxim-Mazurok/google-api-typings-generator.git"
|
|
14
|
+
},
|
|
15
|
+
"types": "index.d.ts",
|
|
16
|
+
"dependencies": {
|
|
17
|
+
"@types/gapi.client": "*",
|
|
18
|
+
"@types/gapi.client.discovery-v1": "*"
|
|
19
|
+
}
|
|
20
|
+
}
|
package/readme.md
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
# TypeScript typings for Cloud Natural Language API v2
|
|
2
|
+
|
|
3
|
+
Provides natural language understanding technologies, such as sentiment analysis, entity recognition, entity sentiment analysis, and other text annotations, to developers.
|
|
4
|
+
For detailed description please check [documentation](https://cloud.google.com/natural-language/).
|
|
5
|
+
|
|
6
|
+
## Installing
|
|
7
|
+
|
|
8
|
+
Install typings for Cloud Natural Language API:
|
|
9
|
+
|
|
10
|
+
```
|
|
11
|
+
npm install @types/gapi.client.language-v2 --save-dev
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## Usage
|
|
15
|
+
|
|
16
|
+
You need to initialize Google API client in your code:
|
|
17
|
+
|
|
18
|
+
```typescript
|
|
19
|
+
gapi.load('client', () => {
|
|
20
|
+
// now we can use gapi.client
|
|
21
|
+
// ...
|
|
22
|
+
});
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
Then load api client wrapper:
|
|
26
|
+
|
|
27
|
+
```typescript
|
|
28
|
+
gapi.client.load('https://language.googleapis.com/$discovery/rest?version=v2', () => {
|
|
29
|
+
// now we can use:
|
|
30
|
+
// gapi.client.language
|
|
31
|
+
});
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
```typescript
|
|
35
|
+
// Deprecated, use discovery document URL, see https://github.com/google/google-api-javascript-client/blob/master/docs/reference.md#----gapiclientloadname----version----callback--
|
|
36
|
+
gapi.client.load('language', 'v2', () => {
|
|
37
|
+
// now we can use:
|
|
38
|
+
// gapi.client.language
|
|
39
|
+
});
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
Don't forget to authenticate your client before sending any request to resources:
|
|
43
|
+
|
|
44
|
+
```typescript
|
|
45
|
+
// declare client_id registered in Google Developers Console
|
|
46
|
+
var client_id = '',
|
|
47
|
+
scope = [
|
|
48
|
+
// Apply machine learning models to reveal the structure and meaning of text
|
|
49
|
+
'https://www.googleapis.com/auth/cloud-language',
|
|
50
|
+
|
|
51
|
+
// See, edit, configure, and delete your Google Cloud data and see the email address for your Google Account.
|
|
52
|
+
'https://www.googleapis.com/auth/cloud-platform',
|
|
53
|
+
],
|
|
54
|
+
immediate = true;
|
|
55
|
+
// ...
|
|
56
|
+
|
|
57
|
+
gapi.auth.authorize(
|
|
58
|
+
{ client_id: client_id, scope: scope, immediate: immediate },
|
|
59
|
+
authResult => {
|
|
60
|
+
if (authResult && !authResult.error) {
|
|
61
|
+
/* handle successful authorization */
|
|
62
|
+
} else {
|
|
63
|
+
/* handle authorization error */
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
After that you can use Cloud Natural Language API resources: <!-- TODO: make this work for multiple namespaces -->
|
|
69
|
+
|
|
70
|
+
```typescript
|
|
71
|
+
|
|
72
|
+
/*
|
|
73
|
+
Finds named entities (currently proper names and common nouns) in the text along with entity types, probability, mentions for each entity, and other properties.
|
|
74
|
+
*/
|
|
75
|
+
await gapi.client.language.documents.analyzeEntities({ });
|
|
76
|
+
|
|
77
|
+
/*
|
|
78
|
+
Analyzes the sentiment of the provided text.
|
|
79
|
+
*/
|
|
80
|
+
await gapi.client.language.documents.analyzeSentiment({ });
|
|
81
|
+
|
|
82
|
+
/*
|
|
83
|
+
A convenience method that provides all features in one call.
|
|
84
|
+
*/
|
|
85
|
+
await gapi.client.language.documents.annotateText({ });
|
|
86
|
+
|
|
87
|
+
/*
|
|
88
|
+
Classifies a document into categories.
|
|
89
|
+
*/
|
|
90
|
+
await gapi.client.language.documents.classifyText({ });
|
|
91
|
+
|
|
92
|
+
/*
|
|
93
|
+
Moderates a document for harmful and sensitive categories.
|
|
94
|
+
*/
|
|
95
|
+
await gapi.client.language.documents.moderateText({ });
|
|
96
|
+
```
|
package/tests.ts
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/* This is stub file for gapi.client.language-v2 definition tests */
|
|
2
|
+
// IMPORTANT
|
|
3
|
+
// This file was generated by https://github.com/Maxim-Mazurok/google-api-typings-generator. Please do not edit it manually.
|
|
4
|
+
// In case of any problems please post issue to https://github.com/Maxim-Mazurok/google-api-typings-generator
|
|
5
|
+
|
|
6
|
+
// Revision: 20230812
|
|
7
|
+
|
|
8
|
+
gapi.load('client', async () => {
|
|
9
|
+
/** now we can use gapi.client */
|
|
10
|
+
|
|
11
|
+
await gapi.client.load('https://language.googleapis.com/$discovery/rest?version=v2');
|
|
12
|
+
/** now we can use gapi.client.language */
|
|
13
|
+
|
|
14
|
+
/** don't forget to authenticate your client before sending any request to resources: */
|
|
15
|
+
/** declare client_id registered in Google Developers Console */
|
|
16
|
+
const client_id = '<<PUT YOUR CLIENT ID HERE>>';
|
|
17
|
+
const scope = [
|
|
18
|
+
/** Apply machine learning models to reveal the structure and meaning of text */
|
|
19
|
+
'https://www.googleapis.com/auth/cloud-language',
|
|
20
|
+
/** See, edit, configure, and delete your Google Cloud data and see the email address for your Google Account. */
|
|
21
|
+
'https://www.googleapis.com/auth/cloud-platform',
|
|
22
|
+
];
|
|
23
|
+
const immediate = false;
|
|
24
|
+
gapi.auth.authorize({ client_id, scope, immediate }, authResult => {
|
|
25
|
+
if (authResult && !authResult.error) {
|
|
26
|
+
/** handle successful authorization */
|
|
27
|
+
run();
|
|
28
|
+
} else {
|
|
29
|
+
/** handle authorization error */
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
async function run() {
|
|
34
|
+
/** Finds named entities (currently proper names and common nouns) in the text along with entity types, probability, mentions for each entity, and other properties. */
|
|
35
|
+
await gapi.client.language.documents.analyzeEntities({
|
|
36
|
+
}, {
|
|
37
|
+
document: {
|
|
38
|
+
content: "Test string",
|
|
39
|
+
gcsContentUri: "Test string",
|
|
40
|
+
languageCode: "Test string",
|
|
41
|
+
type: "Test string",
|
|
42
|
+
},
|
|
43
|
+
encodingType: "Test string",
|
|
44
|
+
});
|
|
45
|
+
/** Analyzes the sentiment of the provided text. */
|
|
46
|
+
await gapi.client.language.documents.analyzeSentiment({
|
|
47
|
+
}, {
|
|
48
|
+
document: {
|
|
49
|
+
content: "Test string",
|
|
50
|
+
gcsContentUri: "Test string",
|
|
51
|
+
languageCode: "Test string",
|
|
52
|
+
type: "Test string",
|
|
53
|
+
},
|
|
54
|
+
encodingType: "Test string",
|
|
55
|
+
});
|
|
56
|
+
/** A convenience method that provides all features in one call. */
|
|
57
|
+
await gapi.client.language.documents.annotateText({
|
|
58
|
+
}, {
|
|
59
|
+
document: {
|
|
60
|
+
content: "Test string",
|
|
61
|
+
gcsContentUri: "Test string",
|
|
62
|
+
languageCode: "Test string",
|
|
63
|
+
type: "Test string",
|
|
64
|
+
},
|
|
65
|
+
encodingType: "Test string",
|
|
66
|
+
features: {
|
|
67
|
+
classifyText: true,
|
|
68
|
+
extractDocumentSentiment: true,
|
|
69
|
+
extractEntities: true,
|
|
70
|
+
moderateText: true,
|
|
71
|
+
},
|
|
72
|
+
});
|
|
73
|
+
/** Classifies a document into categories. */
|
|
74
|
+
await gapi.client.language.documents.classifyText({
|
|
75
|
+
}, {
|
|
76
|
+
document: {
|
|
77
|
+
content: "Test string",
|
|
78
|
+
gcsContentUri: "Test string",
|
|
79
|
+
languageCode: "Test string",
|
|
80
|
+
type: "Test string",
|
|
81
|
+
},
|
|
82
|
+
});
|
|
83
|
+
/** Moderates a document for harmful and sensitive categories. */
|
|
84
|
+
await gapi.client.language.documents.moderateText({
|
|
85
|
+
}, {
|
|
86
|
+
document: {
|
|
87
|
+
content: "Test string",
|
|
88
|
+
gcsContentUri: "Test string",
|
|
89
|
+
languageCode: "Test string",
|
|
90
|
+
type: "Test string",
|
|
91
|
+
},
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
});
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"module": "commonjs",
|
|
4
|
+
"lib": ["es6", "dom"],
|
|
5
|
+
"noImplicitAny": true,
|
|
6
|
+
"noImplicitThis": true,
|
|
7
|
+
"strictNullChecks": true,
|
|
8
|
+
"baseUrl": "../",
|
|
9
|
+
"typeRoots": [
|
|
10
|
+
"../"
|
|
11
|
+
],
|
|
12
|
+
"types": [],
|
|
13
|
+
"noEmit": true,
|
|
14
|
+
"forceConsistentCasingInFileNames": true,
|
|
15
|
+
"strictFunctionTypes": true
|
|
16
|
+
},
|
|
17
|
+
"files": ["index.d.ts", "tests.ts"]
|
|
18
|
+
}
|