@maxim_mazurok/gapi.client.translate-v3beta1 0.0.20230922 → 0.0.20231201
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 +1181 -1947
- package/package.json +6 -6
- package/readme.md +21 -18
- package/tests.ts +0 -305
- package/tsconfig.json +0 -18
- package/tslint.json +0 -6
package/package.json
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@maxim_mazurok/gapi.client.translate-v3beta1",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.20231201",
|
|
4
4
|
"description": "TypeScript typings for Cloud Translation API v3beta1",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "https://github.com/Maxim-Mazurok/google-api-typings-generator.git"
|
|
8
|
+
},
|
|
5
9
|
"license": "MIT",
|
|
6
10
|
"author": {
|
|
7
|
-
"email": "maxim@mazurok.com",
|
|
8
11
|
"name": "Maxim Mazurok",
|
|
12
|
+
"email": "maxim@mazurok.com",
|
|
9
13
|
"url": "https://maxim.mazurok.com"
|
|
10
14
|
},
|
|
11
|
-
"repository": {
|
|
12
|
-
"type": "git",
|
|
13
|
-
"url": "https://github.com/Maxim-Mazurok/google-api-typings-generator.git"
|
|
14
|
-
},
|
|
15
15
|
"types": "index.d.ts",
|
|
16
16
|
"dependencies": {
|
|
17
17
|
"@types/gapi.client": "*",
|
package/readme.md
CHANGED
|
@@ -25,10 +25,13 @@ gapi.load('client', () => {
|
|
|
25
25
|
Then load api client wrapper:
|
|
26
26
|
|
|
27
27
|
```typescript
|
|
28
|
-
gapi.client.load(
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
28
|
+
gapi.client.load(
|
|
29
|
+
'https://translation.googleapis.com/$discovery/rest?version=v3beta1',
|
|
30
|
+
() => {
|
|
31
|
+
// now we can use:
|
|
32
|
+
// gapi.client.translate
|
|
33
|
+
}
|
|
34
|
+
);
|
|
32
35
|
```
|
|
33
36
|
|
|
34
37
|
```typescript
|
|
@@ -45,42 +48,42 @@ Don't forget to authenticate your client before sending any request to resources
|
|
|
45
48
|
// declare client_id registered in Google Developers Console
|
|
46
49
|
var client_id = '',
|
|
47
50
|
scope = [
|
|
48
|
-
|
|
49
|
-
|
|
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',
|
|
50
53
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
54
|
+
// Translate text from one language to another using Google Translate
|
|
55
|
+
'https://www.googleapis.com/auth/cloud-translation',
|
|
56
|
+
],
|
|
57
|
+
immediate = true;
|
|
55
58
|
// ...
|
|
56
59
|
|
|
57
60
|
gapi.auth.authorize(
|
|
58
|
-
{
|
|
61
|
+
{client_id: client_id, scope: scope, immediate: immediate},
|
|
59
62
|
authResult => {
|
|
60
63
|
if (authResult && !authResult.error) {
|
|
61
|
-
|
|
64
|
+
/* handle successful authorization */
|
|
62
65
|
} else {
|
|
63
|
-
|
|
66
|
+
/* handle authorization error */
|
|
64
67
|
}
|
|
65
|
-
}
|
|
68
|
+
}
|
|
69
|
+
);
|
|
66
70
|
```
|
|
67
71
|
|
|
68
72
|
After that you can use Cloud Translation API resources: <!-- TODO: make this work for multiple namespaces -->
|
|
69
73
|
|
|
70
74
|
```typescript
|
|
71
|
-
|
|
72
75
|
/*
|
|
73
76
|
Detects the language of text within a request.
|
|
74
77
|
*/
|
|
75
|
-
await gapi.client.translate.projects.detectLanguage({
|
|
78
|
+
await gapi.client.translate.projects.detectLanguage({parent: 'parent'});
|
|
76
79
|
|
|
77
80
|
/*
|
|
78
81
|
Returns a list of supported languages for translation.
|
|
79
82
|
*/
|
|
80
|
-
await gapi.client.translate.projects.getSupportedLanguages({
|
|
83
|
+
await gapi.client.translate.projects.getSupportedLanguages({parent: 'parent'});
|
|
81
84
|
|
|
82
85
|
/*
|
|
83
86
|
Translates input text and returns translated text.
|
|
84
87
|
*/
|
|
85
|
-
await gapi.client.translate.projects.translateText({
|
|
88
|
+
await gapi.client.translate.projects.translateText({parent: 'parent'});
|
|
86
89
|
```
|
package/tests.ts
DELETED
|
@@ -1,305 +0,0 @@
|
|
|
1
|
-
/* This is stub file for gapi.client.translate-v3beta1 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: 20230922
|
|
7
|
-
|
|
8
|
-
gapi.load('client', async () => {
|
|
9
|
-
/** now we can use gapi.client */
|
|
10
|
-
|
|
11
|
-
await gapi.client.load('https://translation.googleapis.com/$discovery/rest?version=v3beta1');
|
|
12
|
-
/** now we can use gapi.client.translate */
|
|
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
|
-
/** See, edit, configure, and delete your Google Cloud data and see the email address for your Google Account. */
|
|
19
|
-
'https://www.googleapis.com/auth/cloud-platform',
|
|
20
|
-
/** Translate text from one language to another using Google Translate */
|
|
21
|
-
'https://www.googleapis.com/auth/cloud-translation',
|
|
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
|
-
/** Detects the language of text within a request. */
|
|
35
|
-
await gapi.client.translate.projects.detectLanguage({
|
|
36
|
-
parent: "Test string",
|
|
37
|
-
}, {
|
|
38
|
-
content: "Test string",
|
|
39
|
-
labels: {
|
|
40
|
-
A: "Test string"
|
|
41
|
-
},
|
|
42
|
-
mimeType: "Test string",
|
|
43
|
-
model: "Test string",
|
|
44
|
-
});
|
|
45
|
-
/** Returns a list of supported languages for translation. */
|
|
46
|
-
await gapi.client.translate.projects.getSupportedLanguages({
|
|
47
|
-
displayLanguageCode: "Test string",
|
|
48
|
-
model: "Test string",
|
|
49
|
-
parent: "Test string",
|
|
50
|
-
});
|
|
51
|
-
/** Translates input text and returns translated text. */
|
|
52
|
-
await gapi.client.translate.projects.translateText({
|
|
53
|
-
parent: "Test string",
|
|
54
|
-
}, {
|
|
55
|
-
contents: [
|
|
56
|
-
"Test string"
|
|
57
|
-
],
|
|
58
|
-
glossaryConfig: {
|
|
59
|
-
glossary: "Test string",
|
|
60
|
-
ignoreCase: true,
|
|
61
|
-
},
|
|
62
|
-
labels: {
|
|
63
|
-
A: "Test string"
|
|
64
|
-
},
|
|
65
|
-
mimeType: "Test string",
|
|
66
|
-
model: "Test string",
|
|
67
|
-
sourceLanguageCode: "Test string",
|
|
68
|
-
targetLanguageCode: "Test string",
|
|
69
|
-
});
|
|
70
|
-
/**
|
|
71
|
-
* Translates a large volume of document in asynchronous batch mode. This function provides real-time output as the inputs are being processed. If caller cancels a request, the partial
|
|
72
|
-
* results (for an input file, it's all or nothing) may still be available on the specified output location. This call returns immediately and you can use google.longrunning.Operation.name
|
|
73
|
-
* to poll the status of the call.
|
|
74
|
-
*/
|
|
75
|
-
await gapi.client.translate.projects.locations.batchTranslateDocument({
|
|
76
|
-
parent: "Test string",
|
|
77
|
-
}, {
|
|
78
|
-
customizedAttribution: "Test string",
|
|
79
|
-
enableRotationCorrection: true,
|
|
80
|
-
enableShadowRemovalNativePdf: true,
|
|
81
|
-
formatConversions: {
|
|
82
|
-
A: "Test string"
|
|
83
|
-
},
|
|
84
|
-
glossaries: {
|
|
85
|
-
A: {
|
|
86
|
-
glossary: "Test string",
|
|
87
|
-
ignoreCase: true,
|
|
88
|
-
}
|
|
89
|
-
},
|
|
90
|
-
inputConfigs: [
|
|
91
|
-
{
|
|
92
|
-
gcsSource: {
|
|
93
|
-
inputUri: "Test string",
|
|
94
|
-
},
|
|
95
|
-
}
|
|
96
|
-
],
|
|
97
|
-
models: {
|
|
98
|
-
A: "Test string"
|
|
99
|
-
},
|
|
100
|
-
outputConfig: {
|
|
101
|
-
gcsDestination: {
|
|
102
|
-
outputUriPrefix: "Test string",
|
|
103
|
-
},
|
|
104
|
-
},
|
|
105
|
-
sourceLanguageCode: "Test string",
|
|
106
|
-
targetLanguageCodes: [
|
|
107
|
-
"Test string"
|
|
108
|
-
],
|
|
109
|
-
});
|
|
110
|
-
/**
|
|
111
|
-
* Translates a large volume of text in asynchronous batch mode. This function provides real-time output as the inputs are being processed. If caller cancels a request, the partial results
|
|
112
|
-
* (for an input file, it's all or nothing) may still be available on the specified output location. This call returns immediately and you can use google.longrunning.Operation.name to poll
|
|
113
|
-
* the status of the call.
|
|
114
|
-
*/
|
|
115
|
-
await gapi.client.translate.projects.locations.batchTranslateText({
|
|
116
|
-
parent: "Test string",
|
|
117
|
-
}, {
|
|
118
|
-
glossaries: {
|
|
119
|
-
A: {
|
|
120
|
-
glossary: "Test string",
|
|
121
|
-
ignoreCase: true,
|
|
122
|
-
}
|
|
123
|
-
},
|
|
124
|
-
inputConfigs: [
|
|
125
|
-
{
|
|
126
|
-
gcsSource: {
|
|
127
|
-
inputUri: "Test string",
|
|
128
|
-
},
|
|
129
|
-
mimeType: "Test string",
|
|
130
|
-
}
|
|
131
|
-
],
|
|
132
|
-
labels: {
|
|
133
|
-
A: "Test string"
|
|
134
|
-
},
|
|
135
|
-
models: {
|
|
136
|
-
A: "Test string"
|
|
137
|
-
},
|
|
138
|
-
outputConfig: {
|
|
139
|
-
gcsDestination: {
|
|
140
|
-
outputUriPrefix: "Test string",
|
|
141
|
-
},
|
|
142
|
-
},
|
|
143
|
-
sourceLanguageCode: "Test string",
|
|
144
|
-
targetLanguageCodes: [
|
|
145
|
-
"Test string"
|
|
146
|
-
],
|
|
147
|
-
});
|
|
148
|
-
/** Detects the language of text within a request. */
|
|
149
|
-
await gapi.client.translate.projects.locations.detectLanguage({
|
|
150
|
-
parent: "Test string",
|
|
151
|
-
}, {
|
|
152
|
-
content: "Test string",
|
|
153
|
-
labels: {
|
|
154
|
-
A: "Test string"
|
|
155
|
-
},
|
|
156
|
-
mimeType: "Test string",
|
|
157
|
-
model: "Test string",
|
|
158
|
-
});
|
|
159
|
-
/** Gets information about a location. */
|
|
160
|
-
await gapi.client.translate.projects.locations.get({
|
|
161
|
-
name: "Test string",
|
|
162
|
-
});
|
|
163
|
-
/** Returns a list of supported languages for translation. */
|
|
164
|
-
await gapi.client.translate.projects.locations.getSupportedLanguages({
|
|
165
|
-
displayLanguageCode: "Test string",
|
|
166
|
-
model: "Test string",
|
|
167
|
-
parent: "Test string",
|
|
168
|
-
});
|
|
169
|
-
/** Lists information about the supported locations for this service. */
|
|
170
|
-
await gapi.client.translate.projects.locations.list({
|
|
171
|
-
filter: "Test string",
|
|
172
|
-
name: "Test string",
|
|
173
|
-
pageSize: 42,
|
|
174
|
-
pageToken: "Test string",
|
|
175
|
-
});
|
|
176
|
-
/** Translates documents in synchronous mode. */
|
|
177
|
-
await gapi.client.translate.projects.locations.translateDocument({
|
|
178
|
-
parent: "Test string",
|
|
179
|
-
}, {
|
|
180
|
-
customizedAttribution: "Test string",
|
|
181
|
-
documentInputConfig: {
|
|
182
|
-
content: "Test string",
|
|
183
|
-
gcsSource: {
|
|
184
|
-
inputUri: "Test string",
|
|
185
|
-
},
|
|
186
|
-
mimeType: "Test string",
|
|
187
|
-
},
|
|
188
|
-
documentOutputConfig: {
|
|
189
|
-
gcsDestination: {
|
|
190
|
-
outputUriPrefix: "Test string",
|
|
191
|
-
},
|
|
192
|
-
mimeType: "Test string",
|
|
193
|
-
},
|
|
194
|
-
enableRotationCorrection: true,
|
|
195
|
-
enableShadowRemovalNativePdf: true,
|
|
196
|
-
glossaryConfig: {
|
|
197
|
-
glossary: "Test string",
|
|
198
|
-
ignoreCase: true,
|
|
199
|
-
},
|
|
200
|
-
isTranslateNativePdfOnly: true,
|
|
201
|
-
labels: {
|
|
202
|
-
A: "Test string"
|
|
203
|
-
},
|
|
204
|
-
model: "Test string",
|
|
205
|
-
sourceLanguageCode: "Test string",
|
|
206
|
-
targetLanguageCode: "Test string",
|
|
207
|
-
});
|
|
208
|
-
/** Translates input text and returns translated text. */
|
|
209
|
-
await gapi.client.translate.projects.locations.translateText({
|
|
210
|
-
parent: "Test string",
|
|
211
|
-
}, {
|
|
212
|
-
contents: [
|
|
213
|
-
"Test string"
|
|
214
|
-
],
|
|
215
|
-
glossaryConfig: {
|
|
216
|
-
glossary: "Test string",
|
|
217
|
-
ignoreCase: true,
|
|
218
|
-
},
|
|
219
|
-
labels: {
|
|
220
|
-
A: "Test string"
|
|
221
|
-
},
|
|
222
|
-
mimeType: "Test string",
|
|
223
|
-
model: "Test string",
|
|
224
|
-
sourceLanguageCode: "Test string",
|
|
225
|
-
targetLanguageCode: "Test string",
|
|
226
|
-
});
|
|
227
|
-
/** Creates a glossary and returns the long-running operation. Returns NOT_FOUND, if the project doesn't exist. */
|
|
228
|
-
await gapi.client.translate.projects.locations.glossaries.create({
|
|
229
|
-
parent: "Test string",
|
|
230
|
-
}, {
|
|
231
|
-
endTime: "Test string",
|
|
232
|
-
entryCount: 42,
|
|
233
|
-
inputConfig: {
|
|
234
|
-
gcsSource: {
|
|
235
|
-
inputUri: "Test string",
|
|
236
|
-
},
|
|
237
|
-
},
|
|
238
|
-
languageCodesSet: {
|
|
239
|
-
languageCodes: [
|
|
240
|
-
"Test string"
|
|
241
|
-
],
|
|
242
|
-
},
|
|
243
|
-
languagePair: {
|
|
244
|
-
sourceLanguageCode: "Test string",
|
|
245
|
-
targetLanguageCode: "Test string",
|
|
246
|
-
},
|
|
247
|
-
name: "Test string",
|
|
248
|
-
submitTime: "Test string",
|
|
249
|
-
});
|
|
250
|
-
/** Deletes a glossary, or cancels glossary construction if the glossary isn't created yet. Returns NOT_FOUND, if the glossary doesn't exist. */
|
|
251
|
-
await gapi.client.translate.projects.locations.glossaries.delete({
|
|
252
|
-
name: "Test string",
|
|
253
|
-
});
|
|
254
|
-
/** Gets a glossary. Returns NOT_FOUND, if the glossary doesn't exist. */
|
|
255
|
-
await gapi.client.translate.projects.locations.glossaries.get({
|
|
256
|
-
name: "Test string",
|
|
257
|
-
});
|
|
258
|
-
/** Lists glossaries in a project. Returns NOT_FOUND, if the project doesn't exist. */
|
|
259
|
-
await gapi.client.translate.projects.locations.glossaries.list({
|
|
260
|
-
filter: "Test string",
|
|
261
|
-
pageSize: 42,
|
|
262
|
-
pageToken: "Test string",
|
|
263
|
-
parent: "Test string",
|
|
264
|
-
});
|
|
265
|
-
/**
|
|
266
|
-
* Starts asynchronous cancellation on a long-running operation. The server makes a best effort to cancel the operation, but success is not guaranteed. If the server doesn't support this
|
|
267
|
-
* method, it returns `google.rpc.Code.UNIMPLEMENTED`. Clients can use Operations.GetOperation or other methods to check whether the cancellation succeeded or whether the operation
|
|
268
|
-
* completed despite cancellation. On successful cancellation, the operation is not deleted; instead, it becomes an operation with an Operation.error value with a google.rpc.Status.code of
|
|
269
|
-
* 1, corresponding to `Code.CANCELLED`.
|
|
270
|
-
*/
|
|
271
|
-
await gapi.client.translate.projects.locations.operations.cancel({
|
|
272
|
-
name: "Test string",
|
|
273
|
-
}, {
|
|
274
|
-
});
|
|
275
|
-
/**
|
|
276
|
-
* Deletes a long-running operation. This method indicates that the client is no longer interested in the operation result. It does not cancel the operation. If the server doesn't support
|
|
277
|
-
* this method, it returns `google.rpc.Code.UNIMPLEMENTED`.
|
|
278
|
-
*/
|
|
279
|
-
await gapi.client.translate.projects.locations.operations.delete({
|
|
280
|
-
name: "Test string",
|
|
281
|
-
});
|
|
282
|
-
/** Gets the latest state of a long-running operation. Clients can use this method to poll the operation result at intervals as recommended by the API service. */
|
|
283
|
-
await gapi.client.translate.projects.locations.operations.get({
|
|
284
|
-
name: "Test string",
|
|
285
|
-
});
|
|
286
|
-
/** Lists operations that match the specified filter in the request. If the server doesn't support this method, it returns `UNIMPLEMENTED`. */
|
|
287
|
-
await gapi.client.translate.projects.locations.operations.list({
|
|
288
|
-
filter: "Test string",
|
|
289
|
-
name: "Test string",
|
|
290
|
-
pageSize: 42,
|
|
291
|
-
pageToken: "Test string",
|
|
292
|
-
});
|
|
293
|
-
/**
|
|
294
|
-
* Waits until the specified long-running operation is done or reaches at most a specified timeout, returning the latest state. If the operation is already done, the latest state is
|
|
295
|
-
* immediately returned. If the timeout specified is greater than the default HTTP/RPC timeout, the HTTP/RPC timeout is used. If the server does not support this method, it returns
|
|
296
|
-
* `google.rpc.Code.UNIMPLEMENTED`. Note that this method is on a best-effort basis. It may return the latest state before the specified timeout (including immediately), meaning even an
|
|
297
|
-
* immediate response is no guarantee that the operation is done.
|
|
298
|
-
*/
|
|
299
|
-
await gapi.client.translate.projects.locations.operations.wait({
|
|
300
|
-
name: "Test string",
|
|
301
|
-
}, {
|
|
302
|
-
timeout: "Test string",
|
|
303
|
-
});
|
|
304
|
-
}
|
|
305
|
-
});
|
package/tsconfig.json
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
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
|
-
}
|