forked from watson-developer-cloud/node-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
109 lines (83 loc) · 3.62 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
/**
* Copyright 2014 IBM Corp. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
'use strict';
/**
* @module watson-developer-cloud
*/
exports.AlchemyDataNewsV1 = require('./alchemy-data-news/v1');
exports.AlchemyLanguageV1 = require('./alchemy-language/v1');
exports.AlchemyVisionV1 = require('./alchemy-vision/v1');
exports.AuthorizationV1 = require('./authorization/v1');
exports.ConversationV1 = require('./conversation/v1');
exports.ConversationV1Experimental = require('./conversation/v1-experimental');
exports.DialogV1 = require('./dialog/v1');
exports.DiscoveryV1Experimental = require('./discovery/v1-experimental');
exports.DocumentConversionV1 = require('./document-conversion/v1');
exports.LanguageTranslationV2 = require('./language-translation/v2');
exports.LanguageTranslatorV2 = require('./language-translator/v2');
exports.NaturalLanguageClassifierV1 = require('./natural-language-classifier/v1');
exports.PersonalityInsightsV2 = require('./personality-insights/v2');
exports.PersonalityInsightsV3 = require('./personality-insights/v3');
exports.RetrieveAndRankV1 = require('./retrieve-and-rank/v1');
exports.SpeechToTextV1 = require('./speech-to-text/v1');
exports.TextToSpeechV1 = require('./text-to-speech/v1');
exports.ToneAnalyzerV3 = require('./tone-analyzer/v3');
exports.TradeoffAnalyticsV1 = require('./tradeoff-analytics/v1');
exports.VisualRecognitionV3 = require('./visual-recognition/v3');
// adding shim constructors for backwards compatibility
// 2-d map of snake_case service names & version => constructor function
// e.g. servicesByVersion.text_to_speech.v1 === exports.TextToSpeechV1;
var servicesByVersion = {};
Object.keys(exports).forEach(function(key) {
var Service = exports[key];
var name = Service.prototype.name;
var version = Service.prototype.version;
servicesByVersion[name] = servicesByVersion[name] || {};
servicesByVersion[name][version] = Service;
});
Object.keys(servicesByVersion).forEach(function(serviceName) {
Object.defineProperty(exports, serviceName, {
enumerable: false,
configurable: true,
writable: true,
value: function(options) {
options = options || {};
// previously, AlchemyAPI did not require a version to be specified
if(serviceName.indexOf('alchemy_') === 0) {
options.version = 'v1';
}
var Service = servicesByVersion[serviceName][options.version];
if (!Service) {
throw new Error('Unable to find ' + serviceName + ' version ' + options.version);
}
return new Service(options);
}
});
});
// removed services
// we don't want these services listed (so non-enumerable), but we do want a clear error message
// if old code happens to try using one
['concept_insights', 'relationship_extraction', 'message_resonance', 'question_and_answer',
'visual_insights', 'concept_expansion'].forEach(function(serviceName) {
Object.defineProperty(exports, serviceName, {
enumerable: false,
configurable: true,
writable: true,
value: function() {
throw new Error('The ' + serviceName + ' service is no longer available');
}
});
});