Skip to content

Commit 4a4cd50

Browse files
Mike Kistlergermanattanasio
Mike Kistler
authored andcommitted
Rename base service version property to serviceVersion (watson-developer-cloud#628)
* Rename base service version property to serviceVersion * Better implementation of munging the service options (per German)
1 parent 84ab4f1 commit 4a4cd50

File tree

14 files changed

+43
-30
lines changed

14 files changed

+43
-30
lines changed

authorization/v1.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import url = require('url');
2020

2121
class AuthorizationV1 extends BaseService {
2222
name;
23-
version;
23+
serviceVersion;
2424
static URL: string = 'https://stream.watsonplatform.net/authorization/api';
2525

2626
/**
@@ -73,6 +73,6 @@ class AuthorizationV1 extends BaseService {
7373
}
7474

7575
AuthorizationV1.prototype.name = 'authorization';
76-
AuthorizationV1.prototype.version = 'v1';
76+
AuthorizationV1.prototype.serviceVersion = 'v1';
7777

7878
export = AuthorizationV1;

conversation/v1-generated.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import { BaseService } from '../lib/base_service';
2727

2828
class ConversationV1 extends BaseService {
2929
name: string; // set by prototype to 'conversation'
30-
version: string; // set by prototype to 'v1'
30+
serviceVersion: string; // set by prototype to 'v1'
3131

3232
static URL: string = 'https://gateway.watsonplatform.net/conversation/api';
3333

@@ -2231,7 +2231,7 @@ class ConversationV1 extends BaseService {
22312231
}
22322232

22332233
ConversationV1.prototype.name = 'conversation';
2234-
ConversationV1.prototype.version = 'v1';
2234+
ConversationV1.prototype.serviceVersion = 'v1';
22352235

22362236
/*************************
22372237
* interfaces

dialog/v1.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import { FileObject } from '../lib/helper';
2525

2626
class DialogV1 extends BaseService {
2727
static URL: string = 'https://gateway.watsonplatform.net/dialog/api';
28-
28+
2929
/**
3030
* Construct a DialogV1 object.
3131
*
@@ -298,7 +298,7 @@ class DialogV1 extends BaseService {
298298
}
299299

300300
DialogV1.prototype.name = 'dialog';
301-
DialogV1.prototype.version = 'v1';
301+
DialogV1.prototype.serviceVersion = 'v1';
302302

303303
namespace DialogV1 {
304304
/** Options for the `DialogV1` constructor. **/

discovery/v1-generated.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import { FileObject } from '../lib/helper';
2727

2828
class DiscoveryV1 extends BaseService {
2929
name: string; // set by prototype to 'discovery'
30-
version: string; // set by prototype to 'v1'
30+
serviceVersion: string; // set by prototype to 'v1'
3131

3232
static URL: string = 'https://gateway.watsonplatform.net/discovery/api';
3333

@@ -1993,7 +1993,7 @@ class DiscoveryV1 extends BaseService {
19931993
}
19941994

19951995
DiscoveryV1.prototype.name = 'discovery';
1996-
DiscoveryV1.prototype.version = 'v1';
1996+
DiscoveryV1.prototype.serviceVersion = 'v1';
19971997

19981998
/*************************
19991999
* interfaces

index.ts

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ const servicesByVersion = {};
5252
Object.keys(exports).forEach(key => {
5353
const Service = exports[key];
5454
const name = Service.prototype.name;
55-
const version = Service.prototype.version;
55+
const version = Service.prototype.serviceVersion;
5656
servicesByVersion[name] = servicesByVersion[name] || {};
5757
servicesByVersion[name][version] = Service;
5858
});
@@ -63,6 +63,15 @@ Object.keys(servicesByVersion).forEach(serviceName => {
6363
configurable: true,
6464
writable: true,
6565
value: function(options) {
66+
67+
// eslint-disable-next-line no-console
68+
console.warn(
69+
'WARNING: This method of instantiating the Watson services has been deprecated ' +
70+
'beginning with Version 3.0.0 of the Node SDK. Please refer to the Node SDK ' +
71+
'documentation for information on how to instantiate Watson services. This ' +
72+
'form of service instantiaion will be removed in a future release of the SDK.'
73+
);
74+
6675
options = options || {};
6776

6877
// previously, AlchemyAPI did not require a version to be specified
@@ -78,7 +87,11 @@ Object.keys(servicesByVersion).forEach(serviceName => {
7887
);
7988
}
8089

81-
return new Service(options);
90+
return new Service({
91+
...options,
92+
serviceVersion: options.version,
93+
version: options.version_date,
94+
});
8295
}
8396
});
8497
});

language-translator/v2-generated.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import { FileObject } from '../lib/helper';
2727

2828
class LanguageTranslatorV2 extends BaseService {
2929
name: string; // set by prototype to 'language_translator'
30-
version: string; // set by prototype to 'v2'
30+
serviceVersion: string; // set by prototype to 'v2'
3131

3232
static URL: string = 'https://gateway.watsonplatform.net/language-translator/api';
3333

@@ -364,7 +364,7 @@ class LanguageTranslatorV2 extends BaseService {
364364
}
365365

366366
LanguageTranslatorV2.prototype.name = 'language_translator';
367-
LanguageTranslatorV2.prototype.version = 'v2';
367+
LanguageTranslatorV2.prototype.serviceVersion = 'v2';
368368

369369
/*************************
370370
* interfaces

lib/base_service.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ export class BaseService {
7171
protected serviceDefaults: object;
7272
static URL: string;
7373
name: string;
74-
version: string;
74+
serviceVersion: string;
7575
/**
7676
* Internal base class that other services inherit from
7777
* @param {UserOptions} options
@@ -143,7 +143,7 @@ export class BaseService {
143143
.replace(
144144
/_/g,
145145
' '
146-
)} ${this.version.toUpperCase()} unless use_unauthenticated is set`
146+
)} ${this.serviceVersion.toUpperCase()} unless use_unauthenticated is set`
147147
);
148148
} else if (!hasCredentials(_options)) {
149149
throw new Error(
@@ -152,7 +152,7 @@ export class BaseService {
152152
.replace(
153153
/_/g,
154154
' '
155-
)} ${this.version.toUpperCase()} unless use_unauthenticated is set`
155+
)} ${this.serviceVersion.toUpperCase()} unless use_unauthenticated is set`
156156
);
157157
}
158158
if (hasBasicCredentials(_options)) {
@@ -213,7 +213,7 @@ export class BaseService {
213213
}
214214
/**
215215
* Retrieve this service's credentials - useful for passing to the authorization service
216-
*
216+
*
217217
* Only returns a URL when token auth is used.
218218
*
219219
* @returns {Credentials}

natural-language-classifier/v1-generated.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import { FileObject } from '../lib/helper';
2727

2828
class NaturalLanguageClassifierV1 extends BaseService {
2929
name: string; // set by prototype to 'natural_language_classifier'
30-
version: string; // set by prototype to 'v1'
30+
serviceVersion: string; // set by prototype to 'v1'
3131

3232
static URL: string = 'https://gateway.watsonplatform.net/natural-language-classifier/api';
3333

@@ -270,7 +270,7 @@ class NaturalLanguageClassifierV1 extends BaseService {
270270
}
271271

272272
NaturalLanguageClassifierV1.prototype.name = 'natural_language_classifier';
273-
NaturalLanguageClassifierV1.prototype.version = 'v1';
273+
NaturalLanguageClassifierV1.prototype.serviceVersion = 'v1';
274274

275275
/*************************
276276
* interfaces

personality-insights/v2.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ class PersonalityInsightsV2 extends BaseService {
105105
}
106106

107107
PersonalityInsightsV2.prototype.name = 'personality_insights';
108-
PersonalityInsightsV2.prototype.version = 'v2';
108+
PersonalityInsightsV2.prototype.serviceVersion = 'v2';
109109

110110
namespace PersonalityInsightsV2 {
111111
export type Callback = (

personality-insights/v3-generated.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import { BaseService } from '../lib/base_service';
2626

2727
class PersonalityInsightsV3 extends BaseService {
2828
name: string; // set by prototype to 'personality_insights'
29-
version: string; // set by prototype to 'v3'
29+
serviceVersion: string; // set by prototype to 'v3'
3030

3131
static URL: string = 'https://gateway.watsonplatform.net/personality-insights/api';
3232

@@ -111,7 +111,7 @@ class PersonalityInsightsV3 extends BaseService {
111111
}
112112

113113
PersonalityInsightsV3.prototype.name = 'personality_insights';
114-
PersonalityInsightsV3.prototype.version = 'v3';
114+
PersonalityInsightsV3.prototype.serviceVersion = 'v3';
115115

116116
/*************************
117117
* interfaces

speech-to-text/v1-generated.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import { FileObject } from '../lib/helper';
2828

2929
class SpeechToTextV1 extends BaseService {
3030
name: string; // set by prototype to 'speech_to_text'
31-
version: string; // set by prototype to 'v1'
31+
serviceVersion: string; // set by prototype to 'v1'
3232

3333
static URL: string = 'https://stream.watsonplatform.net/speech-to-text/api';
3434

@@ -255,7 +255,7 @@ class SpeechToTextV1 extends BaseService {
255255
};
256256
return createRequest(parameters, _callback);
257257
}
258-
258+
259259
/*************************
260260
* asynchronous
261261
************************/
@@ -1700,7 +1700,7 @@ class SpeechToTextV1 extends BaseService {
17001700
}
17011701

17021702
SpeechToTextV1.prototype.name = 'speech_to_text';
1703-
SpeechToTextV1.prototype.version = 'v1';
1703+
SpeechToTextV1.prototype.serviceVersion = 'v1';
17041704

17051705
/*************************
17061706
* interfaces

text-to-speech/v1-generated.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import { BaseService } from '../lib/base_service';
2626

2727
class TextToSpeechV1 extends BaseService {
2828
name: string; // set by prototype to 'text_to_speech'
29-
version: string; // set by prototype to 'v1'
29+
serviceVersion: string; // set by prototype to 'v1'
3030

3131
static URL: string = 'https://stream.watsonplatform.net/text-to-speech/api';
3232

@@ -663,7 +663,7 @@ class TextToSpeechV1 extends BaseService {
663663
}
664664

665665
TextToSpeechV1.prototype.name = 'text_to_speech';
666-
TextToSpeechV1.prototype.version = 'v1';
666+
TextToSpeechV1.prototype.serviceVersion = 'v1';
667667

668668
/*************************
669669
* interfaces

tone-analyzer/v3-generated.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import { BaseService } from '../lib/base_service';
2626

2727
class ToneAnalyzerV3 extends BaseService {
2828
name: string; // set by prototype to 'tone_analyzer'
29-
version: string; // set by prototype to 'v3'
29+
serviceVersion: string; // set by prototype to 'v3'
3030

3131
static URL: string = 'https://gateway.watsonplatform.net/tone-analyzer/api';
3232

@@ -154,7 +154,7 @@ class ToneAnalyzerV3 extends BaseService {
154154
}
155155

156156
ToneAnalyzerV3.prototype.name = 'tone_analyzer';
157-
ToneAnalyzerV3.prototype.version = 'v3';
157+
ToneAnalyzerV3.prototype.serviceVersion = 'v3';
158158

159159
/*************************
160160
* interfaces

visual-recognition/v3-generated.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import { FileObject } from '../lib/helper';
2727

2828
class VisualRecognitionV3 extends BaseService {
2929
name: string; // set by prototype to 'visual_recognition'
30-
version: string; // set by prototype to 'v3'
30+
serviceVersion: string; // set by prototype to 'v3'
3131

3232
static URL: string = 'https://gateway-a.watsonplatform.net/visual-recognition/api';
3333

@@ -386,7 +386,7 @@ class VisualRecognitionV3 extends BaseService {
386386
}
387387

388388
VisualRecognitionV3.prototype.name = 'visual_recognition';
389-
VisualRecognitionV3.prototype.version = 'v3';
389+
VisualRecognitionV3.prototype.serviceVersion = 'v3';
390390

391391
/*************************
392392
* interfaces

0 commit comments

Comments
 (0)