@aws-amplify/predictions 5.5.6-api-v6-models.b3abc9b.0 → 6.0.1-console-preview.d745d43.0

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.
Files changed (143) hide show
  1. package/README.md +3 -0
  2. package/lib/Predictions.d.ts +11 -45
  3. package/lib/Predictions.js +15 -122
  4. package/lib/errors/PredictionsError.d.ts +4 -0
  5. package/lib/errors/PredictionsError.js +19 -0
  6. package/lib/errors/types/validation.d.ts +14 -0
  7. package/lib/errors/types/validation.js +51 -0
  8. package/lib/errors/utils/assertValidationError.d.ts +2 -0
  9. package/lib/errors/utils/assertValidationError.js +14 -0
  10. package/lib/index.d.ts +2 -4
  11. package/lib/index.js +2 -9
  12. package/{lib-esm/Providers → lib/providers}/AmazonAIConvertPredictionsProvider.d.ts +6 -7
  13. package/lib/{Providers → providers}/AmazonAIConvertPredictionsProvider.js +114 -130
  14. package/lib/{Providers → providers}/AmazonAIIdentifyPredictionsProvider.d.ts +5 -6
  15. package/lib/{Providers → providers}/AmazonAIIdentifyPredictionsProvider.js +148 -191
  16. package/lib/{Providers → providers}/AmazonAIInterpretPredictionsProvider.d.ts +3 -4
  17. package/lib/providers/AmazonAIInterpretPredictionsProvider.js +280 -0
  18. package/lib/providers/IdentifyTextUtils.d.ts +16 -0
  19. package/lib/{Providers → providers}/IdentifyTextUtils.js +74 -58
  20. package/lib/{Providers → providers}/Utils.d.ts +2 -2
  21. package/lib/{Providers → providers}/Utils.js +1 -1
  22. package/lib/{Providers → providers}/index.d.ts +1 -2
  23. package/lib/providers/index.js +11 -0
  24. package/lib/tsconfig.tsbuildinfo +1 -0
  25. package/lib/types/AWSTypes.d.ts +8 -9
  26. package/lib/types/AWSTypes.js +0 -1
  27. package/lib/types/Predictions.d.ts +63 -59
  28. package/lib/types/Predictions.js +28 -15
  29. package/lib/types/index.js +0 -1
  30. package/lib-esm/Predictions.d.ts +11 -45
  31. package/lib-esm/Predictions.js +15 -123
  32. package/lib-esm/errors/PredictionsError.d.ts +4 -0
  33. package/lib-esm/errors/PredictionsError.js +16 -0
  34. package/lib-esm/errors/types/validation.d.ts +14 -0
  35. package/lib-esm/errors/types/validation.js +48 -0
  36. package/lib-esm/errors/utils/assertValidationError.d.ts +2 -0
  37. package/lib-esm/errors/utils/assertValidationError.js +10 -0
  38. package/lib-esm/index.d.ts +2 -4
  39. package/lib-esm/index.js +1 -5
  40. package/{lib/Providers → lib-esm/providers}/AmazonAIConvertPredictionsProvider.d.ts +6 -7
  41. package/lib-esm/{Providers → providers}/AmazonAIConvertPredictionsProvider.js +106 -123
  42. package/lib-esm/{Providers → providers}/AmazonAIIdentifyPredictionsProvider.d.ts +5 -6
  43. package/lib-esm/{Providers → providers}/AmazonAIIdentifyPredictionsProvider.js +135 -179
  44. package/lib-esm/{Providers → providers}/AmazonAIInterpretPredictionsProvider.d.ts +3 -4
  45. package/lib-esm/providers/AmazonAIInterpretPredictionsProvider.js +277 -0
  46. package/lib-esm/providers/IdentifyTextUtils.d.ts +16 -0
  47. package/lib-esm/{Providers → providers}/IdentifyTextUtils.js +76 -58
  48. package/lib-esm/{Providers → providers}/Utils.d.ts +2 -2
  49. package/lib-esm/{Providers → providers}/Utils.js +0 -1
  50. package/lib-esm/{Providers → providers}/index.d.ts +1 -2
  51. package/lib-esm/{Providers → providers}/index.js +1 -3
  52. package/lib-esm/tsconfig.tsbuildinfo +1 -0
  53. package/lib-esm/types/AWSTypes.d.ts +8 -9
  54. package/lib-esm/types/AWSTypes.js +1 -1
  55. package/lib-esm/types/Predictions.d.ts +63 -59
  56. package/lib-esm/types/Predictions.js +21 -14
  57. package/lib-esm/types/index.js +0 -1
  58. package/package.json +121 -130
  59. package/src/Predictions.ts +33 -220
  60. package/src/errors/PredictionsError.ts +16 -0
  61. package/src/errors/types/validation.ts +51 -0
  62. package/src/errors/utils/assertValidationError.ts +18 -0
  63. package/src/index.ts +16 -16
  64. package/src/{Providers → providers}/AmazonAIConvertPredictionsProvider.ts +210 -171
  65. package/src/{Providers → providers}/AmazonAIIdentifyPredictionsProvider.ts +244 -246
  66. package/src/providers/AmazonAIInterpretPredictionsProvider.ts +293 -0
  67. package/src/{Providers → providers}/IdentifyTextUtils.ts +69 -52
  68. package/src/{Providers → providers}/Utils.ts +2 -2
  69. package/src/{Providers → providers}/index.ts +0 -2
  70. package/src/types/AWSTypes.ts +5 -6
  71. package/src/types/Predictions.ts +107 -62
  72. package/lib/.tsbuildinfo +0 -3
  73. package/lib/Predictions.js.map +0 -1
  74. package/lib/Providers/AmazonAIConvertPredictionsProvider.js.map +0 -1
  75. package/lib/Providers/AmazonAIIdentifyPredictionsProvider.js.map +0 -1
  76. package/lib/Providers/AmazonAIInterpretPredictionsProvider.js +0 -321
  77. package/lib/Providers/AmazonAIInterpretPredictionsProvider.js.map +0 -1
  78. package/lib/Providers/AmazonAIPredictionsProvider.d.ts +0 -14
  79. package/lib/Providers/AmazonAIPredictionsProvider.js +0 -43
  80. package/lib/Providers/AmazonAIPredictionsProvider.js.map +0 -1
  81. package/lib/Providers/IdentifyTextUtils.d.ts +0 -40
  82. package/lib/Providers/IdentifyTextUtils.js.map +0 -1
  83. package/lib/Providers/Utils.js.map +0 -1
  84. package/lib/Providers/index.js +0 -13
  85. package/lib/Providers/index.js.map +0 -1
  86. package/lib/index.js.map +0 -1
  87. package/lib/types/AWSTypes.js.map +0 -1
  88. package/lib/types/Predictions.js.map +0 -1
  89. package/lib/types/Providers/AbstractConvertPredictionsProvider.d.ts +0 -9
  90. package/lib/types/Providers/AbstractConvertPredictionsProvider.js +0 -44
  91. package/lib/types/Providers/AbstractConvertPredictionsProvider.js.map +0 -1
  92. package/lib/types/Providers/AbstractIdentifyPredictionsProvider.d.ts +0 -9
  93. package/lib/types/Providers/AbstractIdentifyPredictionsProvider.js +0 -44
  94. package/lib/types/Providers/AbstractIdentifyPredictionsProvider.js.map +0 -1
  95. package/lib/types/Providers/AbstractInterpretPredictionsProvider.d.ts +0 -7
  96. package/lib/types/Providers/AbstractInterpretPredictionsProvider.js +0 -27
  97. package/lib/types/Providers/AbstractInterpretPredictionsProvider.js.map +0 -1
  98. package/lib/types/Providers/AbstractPredictionsProvider.d.ts +0 -7
  99. package/lib/types/Providers/AbstractPredictionsProvider.js +0 -16
  100. package/lib/types/Providers/AbstractPredictionsProvider.js.map +0 -1
  101. package/lib/types/Providers/index.d.ts +0 -4
  102. package/lib/types/Providers/index.js +0 -10
  103. package/lib/types/Providers/index.js.map +0 -1
  104. package/lib/types/index.js.map +0 -1
  105. package/lib-esm/.tsbuildinfo +0 -3
  106. package/lib-esm/Predictions.js.map +0 -1
  107. package/lib-esm/Providers/AmazonAIConvertPredictionsProvider.js.map +0 -1
  108. package/lib-esm/Providers/AmazonAIIdentifyPredictionsProvider.js.map +0 -1
  109. package/lib-esm/Providers/AmazonAIInterpretPredictionsProvider.js +0 -319
  110. package/lib-esm/Providers/AmazonAIInterpretPredictionsProvider.js.map +0 -1
  111. package/lib-esm/Providers/AmazonAIPredictionsProvider.d.ts +0 -14
  112. package/lib-esm/Providers/AmazonAIPredictionsProvider.js +0 -41
  113. package/lib-esm/Providers/AmazonAIPredictionsProvider.js.map +0 -1
  114. package/lib-esm/Providers/IdentifyTextUtils.d.ts +0 -40
  115. package/lib-esm/Providers/IdentifyTextUtils.js.map +0 -1
  116. package/lib-esm/Providers/Utils.js.map +0 -1
  117. package/lib-esm/Providers/index.js.map +0 -1
  118. package/lib-esm/index.js.map +0 -1
  119. package/lib-esm/types/AWSTypes.js.map +0 -1
  120. package/lib-esm/types/Predictions.js.map +0 -1
  121. package/lib-esm/types/Providers/AbstractConvertPredictionsProvider.d.ts +0 -9
  122. package/lib-esm/types/Providers/AbstractConvertPredictionsProvider.js +0 -42
  123. package/lib-esm/types/Providers/AbstractConvertPredictionsProvider.js.map +0 -1
  124. package/lib-esm/types/Providers/AbstractIdentifyPredictionsProvider.d.ts +0 -9
  125. package/lib-esm/types/Providers/AbstractIdentifyPredictionsProvider.js +0 -42
  126. package/lib-esm/types/Providers/AbstractIdentifyPredictionsProvider.js.map +0 -1
  127. package/lib-esm/types/Providers/AbstractInterpretPredictionsProvider.d.ts +0 -7
  128. package/lib-esm/types/Providers/AbstractInterpretPredictionsProvider.js +0 -25
  129. package/lib-esm/types/Providers/AbstractInterpretPredictionsProvider.js.map +0 -1
  130. package/lib-esm/types/Providers/AbstractPredictionsProvider.d.ts +0 -7
  131. package/lib-esm/types/Providers/AbstractPredictionsProvider.js +0 -14
  132. package/lib-esm/types/Providers/AbstractPredictionsProvider.js.map +0 -1
  133. package/lib-esm/types/Providers/index.d.ts +0 -4
  134. package/lib-esm/types/Providers/index.js +0 -7
  135. package/lib-esm/types/Providers/index.js.map +0 -1
  136. package/lib-esm/types/index.js.map +0 -1
  137. package/src/Providers/AmazonAIInterpretPredictionsProvider.ts +0 -281
  138. package/src/Providers/AmazonAIPredictionsProvider.ts +0 -69
  139. package/src/types/Providers/AbstractConvertPredictionsProvider.ts +0 -55
  140. package/src/types/Providers/AbstractIdentifyPredictionsProvider.ts +0 -57
  141. package/src/types/Providers/AbstractInterpretPredictionsProvider.ts +0 -26
  142. package/src/types/Providers/AbstractPredictionsProvider.ts +0 -20
  143. package/src/types/Providers/index.ts +0 -6
package/README.md ADDED
@@ -0,0 +1,3 @@
1
+ > INTERNAL USE ONLY
2
+
3
+ This package contains the AWS Amplify Predictions category and is intended for internal use only. To integrate Amplify into your app, please use [aws-amplify](https://www.npmjs.com/package/aws-amplify).
@@ -1,49 +1,15 @@
1
- import { PredictionsOptions, TranslateTextInput, TranslateTextOutput, TextToSpeechInput, ProviderOptions, TextToSpeechOutput, SpeechToTextInput, SpeechToTextOutput, IdentifyTextInput, IdentifyTextOutput, IdentifyLabelsOutput, IdentifyLabelsInput, IdentifyEntitiesInput, IdentifyEntitiesOutput, InterpretTextOutput, InterpretTextInput } from './types';
2
- import { AbstractPredictionsProvider } from './types/Providers';
1
+ import { IdentifyEntitiesInput, IdentifyEntitiesOutput, IdentifyLabelsInput, IdentifyLabelsOutput, IdentifyTextInput, IdentifyTextOutput, InterpretTextInput, InterpretTextOutput, SpeechToTextInput, SpeechToTextOutput, TextToSpeechInput, TextToSpeechOutput, TranslateTextInput, TranslateTextOutput } from './types';
3
2
  export declare class PredictionsClass {
4
- private _options;
5
- private _convertPluggables;
6
- private _identifyPluggables;
7
- private _interpretPluggables;
8
- /**
9
- * Initialize Predictions with AWS configurations
10
- * @param {PredictionsOptions} options - Configuration object for Predictions
11
- */
12
- constructor(options: PredictionsOptions);
3
+ private convertProvider;
4
+ private identifyProvider;
5
+ private interpretProvider;
13
6
  getModuleName(): string;
14
- /**
15
- * add plugin/pluggable into Predictions category
16
- * @param {Object} pluggable - an instance of the plugin/pluggable
17
- **/
18
- addPluggable(pluggable: AbstractPredictionsProvider): void;
19
- /**
20
- * Get the plugin object
21
- * @param providerName - the name of the plugin
22
- */
23
- getPluggable(providerName: string): AbstractPredictionsProvider;
24
- /**
25
- * Remove the plugin object
26
- * @param providerName - the name of the plugin
27
- */
28
- removePluggable(providerName: string): void;
29
- /**
30
- * To make both top level providers and category level providers work with same interface and configuration
31
- * this method duplicates Predictions config into parent level config (for top level provider) and
32
- * category level config (such as convert, identify etc) and pass both to each provider.
33
- */
34
- configure(options: PredictionsOptions): void;
35
- interpret(input: InterpretTextInput, options?: ProviderOptions): Promise<InterpretTextOutput>;
36
- convert(input: TranslateTextInput, options?: ProviderOptions): Promise<TranslateTextOutput>;
37
- convert(input: TextToSpeechInput, options?: ProviderOptions): Promise<TextToSpeechOutput>;
38
- convert(input: SpeechToTextInput, options?: ProviderOptions): Promise<SpeechToTextOutput>;
39
- identify(input: IdentifyTextInput, options?: ProviderOptions): Promise<IdentifyTextOutput>;
40
- identify(input: IdentifyLabelsInput, options?: ProviderOptions): Promise<IdentifyLabelsOutput>;
41
- identify(input: IdentifyEntitiesInput, options?: ProviderOptions): Promise<IdentifyEntitiesOutput>;
42
- private getPluggableToExecute;
43
- private getAllProviders;
44
- private configurePluggable;
45
- private implementsConvertPluggable;
46
- private implementsIdentifyPluggable;
47
- private implementsInterpretPluggable;
7
+ interpret(input: InterpretTextInput): Promise<InterpretTextOutput>;
8
+ convert(input: TranslateTextInput): Promise<TranslateTextOutput>;
9
+ convert(input: TextToSpeechInput): Promise<TextToSpeechOutput>;
10
+ convert(input: SpeechToTextInput): Promise<SpeechToTextOutput>;
11
+ identify(input: IdentifyTextInput): Promise<IdentifyTextOutput>;
12
+ identify(input: IdentifyLabelsInput): Promise<IdentifyLabelsOutput>;
13
+ identify(input: IdentifyEntitiesInput): Promise<IdentifyEntitiesOutput>;
48
14
  }
49
15
  export declare const Predictions: PredictionsClass;
@@ -1,137 +1,30 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- var tslib_1 = require("tslib");
3
+ exports.Predictions = exports.PredictionsClass = void 0;
4
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
5
+ // SPDX-License-Identifier: Apache-2.0
4
6
  var core_1 = require("@aws-amplify/core");
7
+ var providers_1 = require("./providers");
5
8
  var logger = new core_1.ConsoleLogger('Predictions');
6
9
  var PredictionsClass = /** @class */ (function () {
7
- /**
8
- * Initialize Predictions with AWS configurations
9
- * @param {PredictionsOptions} options - Configuration object for Predictions
10
- */
11
- function PredictionsClass(options) {
12
- this._options = options;
13
- this._convertPluggables = [];
14
- this._identifyPluggables = [];
15
- this._interpretPluggables = [];
10
+ function PredictionsClass() {
11
+ this.convertProvider = new providers_1.AmazonAIConvertPredictionsProvider();
12
+ this.identifyProvider = new providers_1.AmazonAIIdentifyPredictionsProvider();
13
+ this.interpretProvider = new providers_1.AmazonAIInterpretPredictionsProvider();
16
14
  }
17
15
  PredictionsClass.prototype.getModuleName = function () {
18
16
  return 'Predictions';
19
17
  };
20
- /**
21
- * add plugin/pluggable into Predictions category
22
- * @param {Object} pluggable - an instance of the plugin/pluggable
23
- **/
24
- PredictionsClass.prototype.addPluggable = function (pluggable) {
25
- if (this.getPluggable(pluggable.getProviderName())) {
26
- throw new Error("Pluggable with name " + pluggable.getProviderName() + " has already been added.");
27
- }
28
- var pluggableAdded = false;
29
- if (this.implementsConvertPluggable(pluggable)) {
30
- this._convertPluggables.push(pluggable);
31
- pluggableAdded = true;
32
- }
33
- if (this.implementsIdentifyPluggable(pluggable)) {
34
- this._identifyPluggables.push(pluggable);
35
- pluggableAdded = true;
36
- }
37
- if (this.implementsInterpretPluggable(pluggable)) {
38
- this._interpretPluggables.push(pluggable);
39
- pluggableAdded = true;
40
- }
41
- if (pluggableAdded) {
42
- this.configurePluggable(pluggable);
43
- }
18
+ PredictionsClass.prototype.interpret = function (input) {
19
+ return this.interpretProvider.interpret(input);
44
20
  };
45
- /**
46
- * Get the plugin object
47
- * @param providerName - the name of the plugin
48
- */
49
- PredictionsClass.prototype.getPluggable = function (providerName) {
50
- var pluggable = this.getAllProviders().find(function (pluggable) { return pluggable.getProviderName() === providerName; });
51
- if (pluggable === undefined) {
52
- logger.debug('No plugin found with providerName=>', providerName);
53
- return null;
54
- }
55
- else
56
- return pluggable;
21
+ PredictionsClass.prototype.convert = function (input) {
22
+ return this.convertProvider.convert(input);
57
23
  };
58
- /**
59
- * Remove the plugin object
60
- * @param providerName - the name of the plugin
61
- */
62
- PredictionsClass.prototype.removePluggable = function (providerName) {
63
- this._convertPluggables = this._convertPluggables.filter(function (pluggable) { return pluggable.getProviderName() !== providerName; });
64
- this._identifyPluggables = this._identifyPluggables.filter(function (pluggable) { return pluggable.getProviderName() !== providerName; });
65
- this._interpretPluggables = this._interpretPluggables.filter(function (pluggable) { return pluggable.getProviderName() !== providerName; });
66
- return;
67
- };
68
- /**
69
- * To make both top level providers and category level providers work with same interface and configuration
70
- * this method duplicates Predictions config into parent level config (for top level provider) and
71
- * category level config (such as convert, identify etc) and pass both to each provider.
72
- */
73
- PredictionsClass.prototype.configure = function (options) {
74
- var _this = this;
75
- var predictionsConfig = options ? options.predictions || options : {};
76
- predictionsConfig = tslib_1.__assign(tslib_1.__assign({}, predictionsConfig), options);
77
- this._options = Object.assign({}, this._options, predictionsConfig);
78
- logger.debug('configure Predictions', this._options);
79
- this.getAllProviders().forEach(function (pluggable) {
80
- return _this.configurePluggable(pluggable);
81
- });
82
- };
83
- PredictionsClass.prototype.interpret = function (input, options) {
84
- var pluggableToExecute = this.getPluggableToExecute(this._interpretPluggables, options);
85
- return pluggableToExecute.interpret(input);
86
- };
87
- PredictionsClass.prototype.convert = function (input, options) {
88
- var pluggableToExecute = this.getPluggableToExecute(this._convertPluggables, options);
89
- return pluggableToExecute.convert(input);
90
- };
91
- PredictionsClass.prototype.identify = function (input, options) {
92
- var pluggableToExecute = this.getPluggableToExecute(this._identifyPluggables, options);
93
- return pluggableToExecute.identify(input);
94
- };
95
- // tslint:disable-next-line: max-line-length
96
- PredictionsClass.prototype.getPluggableToExecute = function (pluggables, providerOptions) {
97
- // Give preference to provider name first since it is more specific to this call, even if
98
- // there is only one provider configured to error out if the name provided is not the one matched.
99
- if (providerOptions && providerOptions.providerName) {
100
- return tslib_1.__spread(pluggables).find(function (pluggable) {
101
- return pluggable.getProviderName() === providerOptions.providerName;
102
- });
103
- }
104
- else {
105
- if (pluggables.length === 1) {
106
- return pluggables[0];
107
- }
108
- else {
109
- throw new Error('More than one or no providers are configured, ' +
110
- 'Either specify a provider name or configure exactly one provider');
111
- }
112
- }
113
- };
114
- PredictionsClass.prototype.getAllProviders = function () {
115
- return tslib_1.__spread(this._convertPluggables, this._identifyPluggables, this._interpretPluggables);
116
- };
117
- PredictionsClass.prototype.configurePluggable = function (pluggable) {
118
- var categoryConfig = Object.assign({}, this._options['predictions'], // Parent predictions config for the top level provider
119
- this._options[pluggable.getCategory().toLowerCase()] // Actual category level config
120
- );
121
- pluggable.configure(categoryConfig);
122
- };
123
- PredictionsClass.prototype.implementsConvertPluggable = function (obj) {
124
- return obj && typeof obj.convert === 'function';
125
- };
126
- PredictionsClass.prototype.implementsIdentifyPluggable = function (obj) {
127
- return obj && typeof obj.identify === 'function';
128
- };
129
- PredictionsClass.prototype.implementsInterpretPluggable = function (obj) {
130
- return obj && typeof obj.interpret === 'function';
24
+ PredictionsClass.prototype.identify = function (input) {
25
+ return this.identifyProvider.identify(input);
131
26
  };
132
27
  return PredictionsClass;
133
28
  }());
134
29
  exports.PredictionsClass = PredictionsClass;
135
- exports.Predictions = new PredictionsClass({});
136
- core_1.Amplify.register(exports.Predictions);
137
- //# sourceMappingURL=Predictions.js.map
30
+ exports.Predictions = new PredictionsClass();
@@ -0,0 +1,4 @@
1
+ import { AmplifyError, AmplifyErrorParams } from '@aws-amplify/core/internals/utils';
2
+ export declare class PredictionsError extends AmplifyError {
3
+ constructor(params: AmplifyErrorParams);
4
+ }
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PredictionsError = void 0;
4
+ var tslib_1 = require("tslib");
5
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
6
+ // SPDX-License-Identifier: Apache-2.0
7
+ var utils_1 = require("@aws-amplify/core/internals/utils");
8
+ var PredictionsError = /** @class */ (function (_super) {
9
+ tslib_1.__extends(PredictionsError, _super);
10
+ function PredictionsError(params) {
11
+ var _this = _super.call(this, params) || this;
12
+ // TODO: Delete the following 2 lines after we change the build target to >= es2015
13
+ _this.constructor = PredictionsError;
14
+ Object.setPrototypeOf(_this, PredictionsError.prototype);
15
+ return _this;
16
+ }
17
+ return PredictionsError;
18
+ }(utils_1.AmplifyError));
19
+ exports.PredictionsError = PredictionsError;
@@ -0,0 +1,14 @@
1
+ import { AmplifyErrorMap } from '@aws-amplify/core/internals/utils';
2
+ export declare enum PredictionsValidationErrorCode {
3
+ CelebrityDetectionNotEnabled = "CelebrityDetectionNotEnabled",
4
+ InvalidInput = "InvalidInput",
5
+ InvalidSource = "InvalidSource",
6
+ NoCredentials = "NoCredentials",
7
+ NoLanguage = "NoLanguage",
8
+ NoRegion = "NoRegion",
9
+ NoSource = "NoSource",
10
+ NoSourceLanguage = "NoSourceLanguage",
11
+ NoTargetLanguage = "NoTargetLanguage",
12
+ NoVoiceId = "NoVoiceId"
13
+ }
14
+ export declare const validationErrorMap: AmplifyErrorMap<PredictionsValidationErrorCode>;
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
+ // SPDX-License-Identifier: Apache-2.0
4
+ var _a;
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.validationErrorMap = exports.PredictionsValidationErrorCode = void 0;
7
+ var PredictionsValidationErrorCode;
8
+ (function (PredictionsValidationErrorCode) {
9
+ PredictionsValidationErrorCode["CelebrityDetectionNotEnabled"] = "CelebrityDetectionNotEnabled";
10
+ PredictionsValidationErrorCode["InvalidInput"] = "InvalidInput";
11
+ PredictionsValidationErrorCode["InvalidSource"] = "InvalidSource";
12
+ PredictionsValidationErrorCode["NoCredentials"] = "NoCredentials";
13
+ PredictionsValidationErrorCode["NoLanguage"] = "NoLanguage";
14
+ PredictionsValidationErrorCode["NoRegion"] = "NoRegion";
15
+ PredictionsValidationErrorCode["NoSource"] = "NoSource";
16
+ PredictionsValidationErrorCode["NoSourceLanguage"] = "NoSourceLanguage";
17
+ PredictionsValidationErrorCode["NoTargetLanguage"] = "NoTargetLanguage";
18
+ PredictionsValidationErrorCode["NoVoiceId"] = "NoVoiceId";
19
+ })(PredictionsValidationErrorCode = exports.PredictionsValidationErrorCode || (exports.PredictionsValidationErrorCode = {}));
20
+ exports.validationErrorMap = (_a = {},
21
+ _a[PredictionsValidationErrorCode.CelebrityDetectionNotEnabled] = {
22
+ message: 'Celebrity Detection must be enabled.',
23
+ },
24
+ _a[PredictionsValidationErrorCode.InvalidInput] = {
25
+ message: 'Input does not conform to expected type.',
26
+ },
27
+ _a[PredictionsValidationErrorCode.InvalidSource] = {
28
+ message: 'Source type not supported.',
29
+ },
30
+ _a[PredictionsValidationErrorCode.NoCredentials] = {
31
+ message: 'Credentials should not be empty.',
32
+ },
33
+ _a[PredictionsValidationErrorCode.NoLanguage] = {
34
+ message: 'Missing language.',
35
+ },
36
+ _a[PredictionsValidationErrorCode.NoRegion] = {
37
+ message: 'Missing region.',
38
+ },
39
+ _a[PredictionsValidationErrorCode.NoSource] = {
40
+ message: 'Missing source.',
41
+ },
42
+ _a[PredictionsValidationErrorCode.NoSourceLanguage] = {
43
+ message: 'Missing source language for translation.',
44
+ },
45
+ _a[PredictionsValidationErrorCode.NoTargetLanguage] = {
46
+ message: 'Missing target language for translation.',
47
+ },
48
+ _a[PredictionsValidationErrorCode.NoVoiceId] = {
49
+ message: 'Missing voice id.',
50
+ },
51
+ _a);
@@ -0,0 +1,2 @@
1
+ import { PredictionsValidationErrorCode } from '../types/validation';
2
+ export declare function assertValidationError(assertion: boolean, name: PredictionsValidationErrorCode): asserts assertion;
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
+ // SPDX-License-Identifier: Apache-2.0
4
+ Object.defineProperty(exports, "__esModule", { value: true });
5
+ exports.assertValidationError = void 0;
6
+ var PredictionsError_1 = require("../PredictionsError");
7
+ var validation_1 = require("../types/validation");
8
+ function assertValidationError(assertion, name) {
9
+ if (!assertion) {
10
+ var _a = validation_1.validationErrorMap[name], message = _a.message, recoverySuggestion = _a.recoverySuggestion;
11
+ throw new PredictionsError_1.PredictionsError({ name: name, message: message, recoverySuggestion: recoverySuggestion });
12
+ }
13
+ }
14
+ exports.assertValidationError = assertValidationError;
package/lib/index.d.ts CHANGED
@@ -1,4 +1,2 @@
1
- import { Predictions } from './Predictions';
2
- import { AmazonAIConvertPredictionsProvider, AmazonAIIdentifyPredictionsProvider, AmazonAIPredictionsProvider, AmazonAIInterpretPredictionsProvider } from './Providers';
3
- export * from './types';
4
- export { Predictions, AmazonAIIdentifyPredictionsProvider, AmazonAIConvertPredictionsProvider, AmazonAIPredictionsProvider, AmazonAIInterpretPredictionsProvider, };
1
+ export { Predictions } from './Predictions';
2
+ export { IdentifyEntitiesInput, IdentifyEntitiesOutput, IdentifyLabelsInput, IdentifyLabelsOutput, IdentifyTextInput, IdentifyTextOutput, InterpretTextInput, InterpretTextOutput, SpeechToTextInput, SpeechToTextOutput, TextToSpeechInput, TextToSpeechOutput, TranslateTextInput, TranslateTextOutput, } from './types';
package/lib/index.js CHANGED
@@ -1,14 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- var tslib_1 = require("tslib");
3
+ exports.Predictions = void 0;
4
4
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
5
5
  // SPDX-License-Identifier: Apache-2.0
6
6
  var Predictions_1 = require("./Predictions");
7
- exports.Predictions = Predictions_1.Predictions;
8
- var Providers_1 = require("./Providers");
9
- exports.AmazonAIConvertPredictionsProvider = Providers_1.AmazonAIConvertPredictionsProvider;
10
- exports.AmazonAIIdentifyPredictionsProvider = Providers_1.AmazonAIIdentifyPredictionsProvider;
11
- exports.AmazonAIPredictionsProvider = Providers_1.AmazonAIPredictionsProvider;
12
- exports.AmazonAIInterpretPredictionsProvider = Providers_1.AmazonAIInterpretPredictionsProvider;
13
- tslib_1.__exportStar(require("./types"), exports);
14
- //# sourceMappingURL=index.js.map
7
+ Object.defineProperty(exports, "Predictions", { enumerable: true, get: function () { return Predictions_1.Predictions; } });
@@ -1,14 +1,13 @@
1
- import { AbstractConvertPredictionsProvider } from '../types/Providers/AbstractConvertPredictionsProvider';
2
- import { TranslateTextInput, TextToSpeechInput, SpeechToTextInput, TranslateTextOutput, TextToSpeechOutput, SpeechToTextOutput } from '../types';
3
- export declare class AmazonAIConvertPredictionsProvider extends AbstractConvertPredictionsProvider {
4
- private translateClient;
5
- private pollyClient;
6
- constructor();
1
+ import { SpeechToTextInput, SpeechToTextOutput, TextToSpeechInput, TextToSpeechOutput, TranslateTextInput, TranslateTextOutput } from '../types';
2
+ export declare class AmazonAIConvertPredictionsProvider {
3
+ private translateClient?;
4
+ private pollyClient?;
7
5
  getProviderName(): string;
6
+ convert(input: TranslateTextInput | TextToSpeechInput | SpeechToTextInput): Promise<TextToSpeechOutput | TranslateTextOutput | SpeechToTextOutput>;
8
7
  protected translateText(input: TranslateTextInput): Promise<TranslateTextOutput>;
9
8
  protected convertTextToSpeech(input: TextToSpeechInput): Promise<TextToSpeechOutput>;
10
9
  protected convertSpeechToText(input: SpeechToTextInput): Promise<SpeechToTextOutput>;
11
- static serializeDataFromTranscribe(message: any): string;
10
+ static serializeDataFromTranscribe(message: MessageEvent): string;
12
11
  private sendDataToTranscribe;
13
12
  private sendEncodedDataToTranscribe;
14
13
  private getAudioEventMessage;