Skip to content

Commit adaf655

Browse files
Merge pull request #619 from watson-developer-cloud/update-typescript
Update typescript
2 parents dfda4f5 + 92c884e commit adaf655

File tree

20 files changed

+394
-371
lines changed

20 files changed

+394
-371
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,5 @@ authorization/*.js
3131
index.js
3232
.nyc_output
3333
**/*.d.ts
34+
!*/blob.d.ts
3435
**/*.js.map

.npmignore

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ transform.js
2323
scripts/
2424
# this is created in the build on travis ci when it updates the docs in the gh-pages branch
2525
gh-pages/
26-
tsconfig.json
2726
tslint.json
2827
typings.json
2928
typings
@@ -34,4 +33,6 @@ typings
3433
.eslintcache
3534
.eslintignore
3635
.gitattributes
37-
watson-developer-cloud-*.tgz
36+
*.ts
37+
!*.d.ts
38+
watson-developer-cloud-*.tgz

conversation/v1-generated.ts

Lines changed: 87 additions & 86 deletions
Large diffs are not rendered by default.

dialog/v1.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ class DialogV1 extends BaseService {
6262
getProfile(
6363
params: DialogV1.GetProfileParams,
6464
callback: DialogV1.Callback
65-
): ReadableStream | void {
65+
): NodeJS.ReadableStream | void {
6666
const _params = params || {};
6767
const parameters = {
6868
options: {
@@ -85,7 +85,7 @@ class DialogV1 extends BaseService {
8585
updateProfile(
8686
params: DialogV1.UpdateProfileParams,
8787
callback: DialogV1.Callback
88-
): ReadableStream | void {
88+
): NodeJS.ReadableStream | void {
8989
const _params = params || {};
9090
const parameters = {
9191
options: {
@@ -108,7 +108,7 @@ class DialogV1 extends BaseService {
108108
getConversation(
109109
params: DialogV1.GetConversationParams,
110110
callback: DialogV1.Callback
111-
): ReadableStream | void {
111+
): NodeJS.ReadableStream | void {
112112
const _params = params || {};
113113
const parameters = {
114114
options: {
@@ -132,7 +132,7 @@ class DialogV1 extends BaseService {
132132
conversation(
133133
params: DialogV1.ConversationParams,
134134
callback: DialogV1.Callback
135-
): ReadableStream | void {
135+
): NodeJS.ReadableStream | void {
136136
const _params = params || {};
137137
const parameters = {
138138
options: {
@@ -155,7 +155,7 @@ class DialogV1 extends BaseService {
155155
updateContent(
156156
params: DialogV1.UpdateContentParams,
157157
callback: DialogV1.Callback
158-
): ReadableStream | void {
158+
): NodeJS.ReadableStream | void {
159159
const _params = params || {};
160160
const parameters = {
161161
options: {
@@ -182,7 +182,7 @@ class DialogV1 extends BaseService {
182182
getContent(
183183
params: DialogV1.GetContentParams,
184184
callback: DialogV1.Callback
185-
): ReadableStream | void {
185+
): NodeJS.ReadableStream | void {
186186
const _params = params || {};
187187
const parameters = {
188188
options: {
@@ -204,7 +204,7 @@ class DialogV1 extends BaseService {
204204
createDialog(
205205
params: DialogV1.CreateDialogParams,
206206
callback: DialogV1.Callback
207-
): ReadableStream | void {
207+
): NodeJS.ReadableStream | void {
208208
const _params = params || {};
209209
if (!_params['file']) {
210210
callback(new Error('Missing required parameters: file'));
@@ -233,7 +233,7 @@ class DialogV1 extends BaseService {
233233
getDialogs(
234234
params: DialogV1.GetDialogsParams,
235235
callback: DialogV1.Callback
236-
): ReadableStream | void {
236+
): NodeJS.ReadableStream | void {
237237
const parameters = {
238238
options: {
239239
url: '/v1/dialogs',
@@ -251,7 +251,7 @@ class DialogV1 extends BaseService {
251251
deleteDialog(
252252
params: DialogV1.DeleteDialogParams,
253253
callback: DialogV1.Callback
254-
): ReadableStream | void {
254+
): NodeJS.ReadableStream | void {
255255
const parameters = {
256256
options: {
257257
url: '/v1/dialogs/{dialog_id}',
@@ -272,7 +272,7 @@ class DialogV1 extends BaseService {
272272
updateDialog(
273273
params: DialogV1.UpdateDialogParams,
274274
callback: DialogV1.Callback
275-
): ReadableStream | void {
275+
): NodeJS.ReadableStream | void {
276276
const _params = params || {};
277277
if (!_params['file']) {
278278
callback(new Error('Missing required parameters: file'));

discovery/v1-generated.ts

Lines changed: 82 additions & 82 deletions
Large diffs are not rendered by default.

language-translator/v2-generated.ts

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,14 @@ class LanguageTranslatorV2 extends BaseService {
6161
* @param {string} [params.source] - Used in combination with target as an alternative way to select the model for translation. When target and source are set, and model_id is not set, the system chooses a default model with the right language pair to translate (usually the model based on the news domain).
6262
* @param {string} [params.target] - Used in combination with source as an alternative way to select the model for translation. When target and source are set, and model_id is not set, the system chooses a default model with the right language pair to translate (usually the model based on the news domain).
6363
* @param {Function} [callback] - The callback that handles the response.
64-
* @returns {ReadableStream|void}
64+
* @returns {NodeJS.ReadableStream|void}
6565
*/
6666
translate(
6767
params: LanguageTranslatorV2.TranslateParams,
6868
callback?: LanguageTranslatorV2.Callback<
6969
LanguageTranslatorV2.TranslationResult
7070
>
71-
): ReadableStream | void {
71+
): NodeJS.ReadableStream | void {
7272
const _params = extend({}, params);
7373
const _callback = callback ? callback : () => {};
7474
const requiredParams = ['text'];
@@ -109,14 +109,14 @@ class LanguageTranslatorV2 extends BaseService {
109109
* @param {Object} params - The parameters to send to the service.
110110
* @param {string} params.text - Input text in UTF-8 format.
111111
* @param {Function} [callback] - The callback that handles the response.
112-
* @returns {ReadableStream|void}
112+
* @returns {NodeJS.ReadableStream|void}
113113
*/
114114
identify(
115115
params: LanguageTranslatorV2.IdentifyParams,
116116
callback?: LanguageTranslatorV2.Callback<
117117
LanguageTranslatorV2.IdentifiedLanguages
118118
>
119-
): ReadableStream | void {
119+
): NodeJS.ReadableStream | void {
120120
const _params = extend({}, params);
121121
const _callback = callback ? callback : () => {};
122122
const requiredParams = ['text'];
@@ -149,14 +149,14 @@ class LanguageTranslatorV2 extends BaseService {
149149
*
150150
* @param {Object} [params] - The parameters to send to the service.
151151
* @param {Function} [callback] - The callback that handles the response.
152-
* @returns {ReadableStream|void}
152+
* @returns {NodeJS.ReadableStream|void}
153153
*/
154154
listIdentifiableLanguages(
155155
params?: LanguageTranslatorV2.ListIdentifiableLanguagesParams,
156156
callback?: LanguageTranslatorV2.Callback<
157157
LanguageTranslatorV2.IdentifiableLanguages
158158
>
159-
): ReadableStream | void {
159+
): NodeJS.ReadableStream | void {
160160
const _params =
161161
typeof params === 'function' && !callback ? {} : extend({}, params);
162162
const _callback =
@@ -187,18 +187,18 @@ class LanguageTranslatorV2 extends BaseService {
187187
* @param {Object} params - The parameters to send to the service.
188188
* @param {string} params.base_model_id - Specifies the domain model that is used as the base for the training. To see current supported domain models, use the GET /v2/models parameter.
189189
* @param {string} [params.name] - The model name. Valid characters are letters, numbers, -, and _. No spaces.
190-
* @param {ReadableStream|FileObject|Buffer} [params.forced_glossary] - A TMX file with your customizations. The customizations in the file completely overwrite the domain data translation, including high frequency or high confidence phrase translations. You can upload only one glossary with a file size less than 10 MB per call.
191-
* @param {ReadableStream|FileObject|Buffer} [params.parallel_corpus] - A TMX file that contains entries that are treated as a parallel corpus instead of a glossary.
192-
* @param {ReadableStream|FileObject|Buffer} [params.monolingual_corpus] - A UTF-8 encoded plain text file that is used to customize the target language model.
190+
* @param {NodeJS.ReadableStream|FileObject|Buffer} [params.forced_glossary] - A TMX file with your customizations. The customizations in the file completely overwrite the domain data translation, including high frequency or high confidence phrase translations. You can upload only one glossary with a file size less than 10 MB per call.
191+
* @param {NodeJS.ReadableStream|FileObject|Buffer} [params.parallel_corpus] - A TMX file that contains entries that are treated as a parallel corpus instead of a glossary.
192+
* @param {NodeJS.ReadableStream|FileObject|Buffer} [params.monolingual_corpus] - A UTF-8 encoded plain text file that is used to customize the target language model.
193193
* @param {Function} [callback] - The callback that handles the response.
194-
* @returns {ReadableStream|void}
194+
* @returns {NodeJS.ReadableStream|void}
195195
*/
196196
createModel(
197197
params: LanguageTranslatorV2.CreateModelParams,
198198
callback?: LanguageTranslatorV2.Callback<
199199
LanguageTranslatorV2.TranslationModel
200200
>
201-
): ReadableStream | void {
201+
): NodeJS.ReadableStream | void {
202202
const _params = extend({}, params);
203203
const _callback = callback ? callback : () => {};
204204
const requiredParams = ['base_model_id'];
@@ -247,14 +247,14 @@ class LanguageTranslatorV2 extends BaseService {
247247
* @param {Object} params - The parameters to send to the service.
248248
* @param {string} params.model_id - The model identifier.
249249
* @param {Function} [callback] - The callback that handles the response.
250-
* @returns {ReadableStream|void}
250+
* @returns {NodeJS.ReadableStream|void}
251251
*/
252252
deleteModel(
253253
params: LanguageTranslatorV2.DeleteModelParams,
254254
callback?: LanguageTranslatorV2.Callback<
255255
LanguageTranslatorV2.DeleteModelResult
256256
>
257-
): ReadableStream | void {
257+
): NodeJS.ReadableStream | void {
258258
const _params = extend({}, params);
259259
const _callback = callback ? callback : () => {};
260260
const requiredParams = ['model_id'];
@@ -286,14 +286,14 @@ class LanguageTranslatorV2 extends BaseService {
286286
* @param {Object} params - The parameters to send to the service.
287287
* @param {string} params.model_id - Model ID to use.
288288
* @param {Function} [callback] - The callback that handles the response.
289-
* @returns {ReadableStream|void}
289+
* @returns {NodeJS.ReadableStream|void}
290290
*/
291291
getModel(
292292
params: LanguageTranslatorV2.GetModelParams,
293293
callback?: LanguageTranslatorV2.Callback<
294294
LanguageTranslatorV2.TranslationModel
295295
>
296-
): ReadableStream | void {
296+
): NodeJS.ReadableStream | void {
297297
const _params = extend({}, params);
298298
const _callback = callback ? callback : () => {};
299299
const requiredParams = ['model_id'];
@@ -327,14 +327,14 @@ class LanguageTranslatorV2 extends BaseService {
327327
* @param {string} [params.target] - Filter models by target language.
328328
* @param {boolean} [params.default_models] - Valid values are leaving it unset, `true`, and `false`. When `true`, it filters models to return the default_models model or models. When `false`, it returns the non-default_models model or models. If not set, it returns all models, default_models and non-default_models.
329329
* @param {Function} [callback] - The callback that handles the response.
330-
* @returns {ReadableStream|void}
330+
* @returns {NodeJS.ReadableStream|void}
331331
*/
332332
listModels(
333333
params?: LanguageTranslatorV2.ListModelsParams,
334334
callback?: LanguageTranslatorV2.Callback<
335335
LanguageTranslatorV2.TranslationModels
336336
>
337-
): ReadableStream | void {
337+
): NodeJS.ReadableStream | void {
338338
const _params =
339339
typeof params === 'function' && !callback ? {} : extend({}, params);
340340
const _callback =
@@ -422,11 +422,11 @@ namespace LanguageTranslatorV2 {
422422
/** The model name. Valid characters are letters, numbers, -, and _. No spaces. **/
423423
name?: string;
424424
/** A TMX file with your customizations. The customizations in the file completely overwrite the domain data translation, including high frequency or high confidence phrase translations. You can upload only one glossary with a file size less than 10 MB per call. **/
425-
forced_glossary?: ReadableStream | FileObject | Buffer;
425+
forced_glossary?: NodeJS.ReadableStream | FileObject | Buffer;
426426
/** A TMX file that contains entries that are treated as a parallel corpus instead of a glossary. **/
427-
parallel_corpus?: ReadableStream | FileObject | Buffer;
427+
parallel_corpus?: NodeJS.ReadableStream | FileObject | Buffer;
428428
/** A UTF-8 encoded plain text file that is used to customize the target language model. **/
429-
monolingual_corpus?: ReadableStream | FileObject | Buffer;
429+
monolingual_corpus?: NodeJS.ReadableStream | FileObject | Buffer;
430430
}
431431

432432
/** Parameters for the `deleteModel` operation. **/

lib/blob.d.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
interface Blob {
2+
readonly size: number;
3+
readonly type: string;
4+
msClose(): void;
5+
msDetachStream(): any;
6+
slice(start?: number, end?: number, contentType?: string): Blob;
7+
}
8+
9+
declare var Blob: {
10+
prototype: Blob;
11+
new (blobParts?: any[], options?: BlobPropertyBag): Blob;
12+
};
13+
14+
interface BlobPropertyBag {
15+
type?: string;
16+
endings?: string;
17+
}

lib/content-type.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import { extname } from 'path';
22

3+
/// <reference path="blob.d.ts" />
4+
35
// This module attempts to identify common content-types based on the filename or header
46
// It is not exhaustive, and for best results, you should always manually specify the content-type option.
57
// See the complete list of supported content-types at

lib/helper.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import { isReadable } from 'isstream';
2222

2323
// exported interfaces
2424
export interface FileObject {
25-
value: ReadableStream | Buffer | string;
25+
value: NodeJS.ReadableStream | Buffer | string;
2626
options?: FileOptions;
2727
}
2828

@@ -33,11 +33,11 @@ export interface FileOptions {
3333
}
3434

3535
export interface FileParamAttributes {
36-
data: ReadableStream | Buffer | FileObject;
36+
data: NodeJS.ReadableStream | Buffer | FileObject;
3737
contentType: string;
3838
}
3939

40-
export interface FileStream extends ReadableStream {
40+
export interface FileStream extends NodeJS.ReadableStream {
4141
path: string | Buffer;
4242
}
4343

@@ -63,15 +63,15 @@ export function isEmptyObject(obj: any): boolean {
6363

6464
/**
6565
* This function retrieves the content type of the input.
66-
* @param {ReadableStream|Buffer|string} inputData - The data to retrieve content type for.
66+
* @param {NodeJS.ReadableStream|Buffer|string} inputData - The data to retrieve content type for.
6767
* @returns {string} the content type of the input.
6868
*/
6969
export function getContentType(
70-
inputData: ReadableStream | Buffer | string
70+
inputData: NodeJS.ReadableStream | Buffer | string
7171
): string {
7272
let contentType = null;
7373
if (isFileStream(inputData)) {
74-
// if the inputData is a ReadableStream
74+
// if the inputData is a NodeJS.ReadableStream
7575
const mimeType = lookup(inputData.path);
7676
contentType = { mime: mimeType || null };
7777
} else if (Buffer.isBuffer(inputData)) {
@@ -156,7 +156,7 @@ export function getFormat(
156156
/**
157157
* this function builds a `form-data` object for each file parameter
158158
* @param {FileParamAttributes} fileParams - the file parameter attributes
159-
* @param {ReadableStream|Buffer|FileObject} fileParams.data - the data content of the file
159+
* @param {NodeJS.ReadableStream|Buffer|FileObject} fileParams.data - the data content of the file
160160
* @param {string} fileParams.contentType - the content type of the file
161161
* @returns {FileObject}
162162
*/
@@ -208,7 +208,7 @@ export function buildRequestFileObject(
208208
}
209209

210210
// build value
211-
let value: ReadableStream | Buffer | string = isFileObject(fileParams.data)
211+
let value: NodeJS.ReadableStream | Buffer | string = isFileObject(fileParams.data)
212212
? fileParams.data.value
213213
: fileParams.data;
214214
if (typeof value === 'string') {

0 commit comments

Comments
 (0)