@aws-amplify/predictions 6.0.1-unstable.cfbde4c.0 → 6.0.1

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 (94) hide show
  1. package/{lib → dist/cjs}/Predictions.js +4 -2
  2. package/dist/cjs/Predictions.js.map +1 -0
  3. package/{lib → dist/cjs}/errors/PredictionsError.js +3 -1
  4. package/dist/cjs/errors/PredictionsError.js.map +1 -0
  5. package/{lib → dist/cjs}/errors/types/validation.js +3 -1
  6. package/dist/cjs/errors/types/validation.js.map +1 -0
  7. package/{lib → dist/cjs}/errors/utils/assertValidationError.js +3 -1
  8. package/dist/cjs/errors/utils/assertValidationError.js.map +1 -0
  9. package/{lib → dist/cjs}/index.js +3 -1
  10. package/dist/cjs/index.js.map +1 -0
  11. package/{lib → dist/cjs}/providers/AmazonAIConvertPredictionsProvider.js +3 -1
  12. package/dist/cjs/providers/AmazonAIConvertPredictionsProvider.js.map +1 -0
  13. package/{lib → dist/cjs}/providers/AmazonAIIdentifyPredictionsProvider.js +3 -1
  14. package/dist/cjs/providers/AmazonAIIdentifyPredictionsProvider.js.map +1 -0
  15. package/{lib → dist/cjs}/providers/AmazonAIInterpretPredictionsProvider.js +3 -1
  16. package/dist/cjs/providers/AmazonAIInterpretPredictionsProvider.js.map +1 -0
  17. package/{lib → dist/cjs}/providers/IdentifyTextUtils.js +3 -1
  18. package/dist/cjs/providers/IdentifyTextUtils.js.map +1 -0
  19. package/{lib → dist/cjs}/providers/Utils.js +3 -1
  20. package/dist/cjs/providers/Utils.js.map +1 -0
  21. package/{lib → dist/cjs}/providers/index.js +3 -1
  22. package/dist/cjs/providers/index.js.map +1 -0
  23. package/{lib → dist/cjs}/types/AWSTypes.js +3 -1
  24. package/dist/cjs/types/AWSTypes.js.map +1 -0
  25. package/{lib → dist/cjs}/types/Predictions.js +3 -1
  26. package/dist/cjs/types/Predictions.js.map +1 -0
  27. package/{lib → dist/cjs}/types/index.js +3 -1
  28. package/dist/cjs/types/index.js.map +1 -0
  29. package/{lib-esm/Predictions.js → dist/esm/Predictions.mjs} +11 -5
  30. package/dist/esm/Predictions.mjs.map +1 -0
  31. package/{lib-esm/errors/PredictionsError.js → dist/esm/errors/PredictionsError.mjs} +6 -2
  32. package/dist/esm/errors/PredictionsError.mjs.map +1 -0
  33. package/{lib-esm/errors/types/validation.js → dist/esm/errors/types/validation.mjs} +5 -2
  34. package/dist/esm/errors/types/validation.mjs.map +1 -0
  35. package/{lib-esm/errors/utils/assertValidationError.js → dist/esm/errors/utils/assertValidationError.mjs} +7 -3
  36. package/dist/esm/errors/utils/assertValidationError.mjs.map +1 -0
  37. package/dist/esm/index.mjs +2 -0
  38. package/dist/esm/index.mjs.map +1 -0
  39. package/{lib-esm/providers/AmazonAIConvertPredictionsProvider.js → dist/esm/providers/AmazonAIConvertPredictionsProvider.mjs} +16 -12
  40. package/dist/esm/providers/AmazonAIConvertPredictionsProvider.mjs.map +1 -0
  41. package/{lib-esm/providers/AmazonAIIdentifyPredictionsProvider.js → dist/esm/providers/AmazonAIIdentifyPredictionsProvider.mjs} +16 -12
  42. package/dist/esm/providers/AmazonAIIdentifyPredictionsProvider.mjs.map +1 -0
  43. package/{lib-esm/providers/AmazonAIInterpretPredictionsProvider.js → dist/esm/providers/AmazonAIInterpretPredictionsProvider.mjs} +11 -7
  44. package/dist/esm/providers/AmazonAIInterpretPredictionsProvider.mjs.map +1 -0
  45. package/{lib-esm/providers/IdentifyTextUtils.js → dist/esm/providers/IdentifyTextUtils.mjs} +7 -3
  46. package/dist/esm/providers/IdentifyTextUtils.mjs.map +1 -0
  47. package/{lib-esm/providers/Utils.js → dist/esm/providers/Utils.mjs} +6 -3
  48. package/dist/esm/providers/Utils.mjs.map +1 -0
  49. package/dist/esm/providers/index.mjs +4 -0
  50. package/dist/esm/providers/index.mjs.map +1 -0
  51. package/dist/esm/types/AWSTypes.mjs +2 -0
  52. package/dist/esm/types/AWSTypes.mjs.map +1 -0
  53. package/{lib-esm/types/Predictions.js → dist/esm/types/Predictions.mjs} +20 -17
  54. package/dist/esm/types/Predictions.mjs.map +1 -0
  55. package/dist/esm/types/index.mjs +2 -0
  56. package/dist/esm/types/index.mjs.map +1 -0
  57. package/package.json +119 -121
  58. package/src/Predictions.ts +2 -2
  59. package/src/providers/AmazonAIConvertPredictionsProvider.ts +2 -6
  60. package/src/providers/AmazonAIIdentifyPredictionsProvider.ts +2 -6
  61. package/lib/Predictions.d.ts +0 -15
  62. package/lib/errors/PredictionsError.d.ts +0 -4
  63. package/lib/errors/types/validation.d.ts +0 -14
  64. package/lib/errors/utils/assertValidationError.d.ts +0 -2
  65. package/lib/index.d.ts +0 -2
  66. package/lib/providers/AmazonAIConvertPredictionsProvider.d.ts +0 -19
  67. package/lib/providers/AmazonAIIdentifyPredictionsProvider.d.ts +0 -48
  68. package/lib/providers/AmazonAIInterpretPredictionsProvider.d.ts +0 -14
  69. package/lib/providers/IdentifyTextUtils.d.ts +0 -16
  70. package/lib/providers/Utils.d.ts +0 -13
  71. package/lib/providers/index.d.ts +0 -4
  72. package/lib/tsconfig.tsbuildinfo +0 -1
  73. package/lib/types/AWSTypes.d.ts +0 -124
  74. package/lib/types/Predictions.d.ts +0 -298
  75. package/lib/types/index.d.ts +0 -1
  76. package/lib-esm/index.js +0 -3
  77. package/lib-esm/providers/index.js +0 -6
  78. package/lib-esm/tsconfig.tsbuildinfo +0 -1
  79. package/lib-esm/types/AWSTypes.js +0 -1
  80. package/lib-esm/types/index.js +0 -3
  81. /package/{lib-esm → dist/esm}/Predictions.d.ts +0 -0
  82. /package/{lib-esm → dist/esm}/errors/PredictionsError.d.ts +0 -0
  83. /package/{lib-esm → dist/esm}/errors/types/validation.d.ts +0 -0
  84. /package/{lib-esm → dist/esm}/errors/utils/assertValidationError.d.ts +0 -0
  85. /package/{lib-esm → dist/esm}/index.d.ts +0 -0
  86. /package/{lib-esm → dist/esm}/providers/AmazonAIConvertPredictionsProvider.d.ts +0 -0
  87. /package/{lib-esm → dist/esm}/providers/AmazonAIIdentifyPredictionsProvider.d.ts +0 -0
  88. /package/{lib-esm → dist/esm}/providers/AmazonAIInterpretPredictionsProvider.d.ts +0 -0
  89. /package/{lib-esm → dist/esm}/providers/IdentifyTextUtils.d.ts +0 -0
  90. /package/{lib-esm → dist/esm}/providers/Utils.d.ts +0 -0
  91. /package/{lib-esm → dist/esm}/providers/index.d.ts +0 -0
  92. /package/{lib-esm → dist/esm}/types/AWSTypes.d.ts +0 -0
  93. /package/{lib-esm → dist/esm}/types/Predictions.d.ts +0 -0
  94. /package/{lib-esm → dist/esm}/types/index.d.ts +0 -0
@@ -1,11 +1,12 @@
1
- "use strict";
1
+ 'use strict';
2
+
2
3
  Object.defineProperty(exports, "__esModule", { value: true });
3
4
  exports.Predictions = exports.PredictionsClass = void 0;
4
5
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
5
6
  // SPDX-License-Identifier: Apache-2.0
6
7
  const core_1 = require("@aws-amplify/core");
7
8
  const providers_1 = require("./providers");
8
- const logger = new core_1.ConsoleLogger('Predictions');
9
+ new core_1.ConsoleLogger('Predictions');
9
10
  class PredictionsClass {
10
11
  constructor() {
11
12
  this.convertProvider = new providers_1.AmazonAIConvertPredictionsProvider();
@@ -27,3 +28,4 @@ class PredictionsClass {
27
28
  }
28
29
  exports.PredictionsClass = PredictionsClass;
29
30
  exports.Predictions = new PredictionsClass();
31
+ //# sourceMappingURL=Predictions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Predictions.js","sources":["../../src/Predictions.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.Predictions = exports.PredictionsClass = void 0;\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nconst core_1 = require(\"@aws-amplify/core\");\nconst providers_1 = require(\"./providers\");\nconst logger = new core_1.ConsoleLogger('Predictions');\nclass PredictionsClass {\n constructor() {\n this.convertProvider = new providers_1.AmazonAIConvertPredictionsProvider();\n this.identifyProvider = new providers_1.AmazonAIIdentifyPredictionsProvider();\n this.interpretProvider = new providers_1.AmazonAIInterpretPredictionsProvider();\n }\n getModuleName() {\n return 'Predictions';\n }\n interpret(input) {\n return this.interpretProvider.interpret(input);\n }\n convert(input) {\n return this.convertProvider.convert(input);\n }\n identify(input) {\n return this.identifyProvider.identify(input);\n }\n}\nexports.PredictionsClass = PredictionsClass;\nexports.Predictions = new PredictionsClass();\n"],"names":[],"mappings":";;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,WAAW,GAAG,OAAO,CAAC,gBAAgB,GAAG,KAAK,CAAC,CAAC;AACxD;AACA;AACA,MAAM,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC;AAC5C,MAAM,WAAW,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;AAC5B,IAAI,MAAM,CAAC,aAAa,CAAC,aAAa,EAAE;AACvD,MAAM,gBAAgB,CAAC;AACvB,IAAI,WAAW,GAAG;AAClB,QAAQ,IAAI,CAAC,eAAe,GAAG,IAAI,WAAW,CAAC,kCAAkC,EAAE,CAAC;AACpF,QAAQ,IAAI,CAAC,gBAAgB,GAAG,IAAI,WAAW,CAAC,mCAAmC,EAAE,CAAC;AACtF,QAAQ,IAAI,CAAC,iBAAiB,GAAG,IAAI,WAAW,CAAC,oCAAoC,EAAE,CAAC;AACxF,KAAK;AACL,IAAI,aAAa,GAAG;AACpB,QAAQ,OAAO,aAAa,CAAC;AAC7B,KAAK;AACL,IAAI,SAAS,CAAC,KAAK,EAAE;AACrB,QAAQ,OAAO,IAAI,CAAC,iBAAiB,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;AACvD,KAAK;AACL,IAAI,OAAO,CAAC,KAAK,EAAE;AACnB,QAAQ,OAAO,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AACnD,KAAK;AACL,IAAI,QAAQ,CAAC,KAAK,EAAE;AACpB,QAAQ,OAAO,IAAI,CAAC,gBAAgB,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;AACrD,KAAK;AACL,CAAC;AACD,OAAO,CAAC,gBAAgB,GAAG,gBAAgB,CAAC;AAC5C,OAAO,CAAC,WAAW,GAAG,IAAI,gBAAgB,EAAE;;"}
@@ -1,4 +1,5 @@
1
- "use strict";
1
+ 'use strict';
2
+
2
3
  Object.defineProperty(exports, "__esModule", { value: true });
3
4
  exports.PredictionsError = void 0;
4
5
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
@@ -13,3 +14,4 @@ class PredictionsError extends utils_1.AmplifyError {
13
14
  }
14
15
  }
15
16
  exports.PredictionsError = PredictionsError;
17
+ //# sourceMappingURL=PredictionsError.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PredictionsError.js","sources":["../../../src/errors/PredictionsError.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.PredictionsError = void 0;\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nconst utils_1 = require(\"@aws-amplify/core/internals/utils\");\nclass PredictionsError extends utils_1.AmplifyError {\n constructor(params) {\n super(params);\n // TODO: Delete the following 2 lines after we change the build target to >= es2015\n this.constructor = PredictionsError;\n Object.setPrototypeOf(this, PredictionsError.prototype);\n }\n}\nexports.PredictionsError = PredictionsError;\n"],"names":[],"mappings":";;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,gBAAgB,GAAG,KAAK,CAAC,CAAC;AAClC;AACA;AACA,MAAM,OAAO,GAAG,OAAO,CAAC,mCAAmC,CAAC,CAAC;AAC7D,MAAM,gBAAgB,SAAS,OAAO,CAAC,YAAY,CAAC;AACpD,IAAI,WAAW,CAAC,MAAM,EAAE;AACxB,QAAQ,KAAK,CAAC,MAAM,CAAC,CAAC;AACtB;AACA,QAAQ,IAAI,CAAC,WAAW,GAAG,gBAAgB,CAAC;AAC5C,QAAQ,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,gBAAgB,CAAC,SAAS,CAAC,CAAC;AAChE,KAAK;AACL,CAAC;AACD,OAAO,CAAC,gBAAgB,GAAG,gBAAgB;;"}
@@ -1,4 +1,5 @@
1
- "use strict";
1
+ 'use strict';
2
+
2
3
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
4
  // SPDX-License-Identifier: Apache-2.0
4
5
  Object.defineProperty(exports, "__esModule", { value: true });
@@ -48,3 +49,4 @@ exports.validationErrorMap = {
48
49
  message: 'Missing voice id.',
49
50
  },
50
51
  };
52
+ //# sourceMappingURL=validation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validation.js","sources":["../../../../src/errors/types/validation.ts"],"sourcesContent":["\"use strict\";\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.validationErrorMap = exports.PredictionsValidationErrorCode = void 0;\nvar PredictionsValidationErrorCode;\n(function (PredictionsValidationErrorCode) {\n PredictionsValidationErrorCode[\"CelebrityDetectionNotEnabled\"] = \"CelebrityDetectionNotEnabled\";\n PredictionsValidationErrorCode[\"InvalidInput\"] = \"InvalidInput\";\n PredictionsValidationErrorCode[\"InvalidSource\"] = \"InvalidSource\";\n PredictionsValidationErrorCode[\"NoCredentials\"] = \"NoCredentials\";\n PredictionsValidationErrorCode[\"NoLanguage\"] = \"NoLanguage\";\n PredictionsValidationErrorCode[\"NoRegion\"] = \"NoRegion\";\n PredictionsValidationErrorCode[\"NoSource\"] = \"NoSource\";\n PredictionsValidationErrorCode[\"NoSourceLanguage\"] = \"NoSourceLanguage\";\n PredictionsValidationErrorCode[\"NoTargetLanguage\"] = \"NoTargetLanguage\";\n PredictionsValidationErrorCode[\"NoVoiceId\"] = \"NoVoiceId\";\n})(PredictionsValidationErrorCode = exports.PredictionsValidationErrorCode || (exports.PredictionsValidationErrorCode = {}));\nexports.validationErrorMap = {\n [PredictionsValidationErrorCode.CelebrityDetectionNotEnabled]: {\n message: 'Celebrity Detection must be enabled.',\n },\n [PredictionsValidationErrorCode.InvalidInput]: {\n message: 'Input does not conform to expected type.',\n },\n [PredictionsValidationErrorCode.InvalidSource]: {\n message: 'Source type not supported.',\n },\n [PredictionsValidationErrorCode.NoCredentials]: {\n message: 'Credentials should not be empty.',\n },\n [PredictionsValidationErrorCode.NoLanguage]: {\n message: 'Missing language.',\n },\n [PredictionsValidationErrorCode.NoRegion]: {\n message: 'Missing region.',\n },\n [PredictionsValidationErrorCode.NoSource]: {\n message: 'Missing source.',\n },\n [PredictionsValidationErrorCode.NoSourceLanguage]: {\n message: 'Missing source language for translation.',\n },\n [PredictionsValidationErrorCode.NoTargetLanguage]: {\n message: 'Missing target language for translation.',\n },\n [PredictionsValidationErrorCode.NoVoiceId]: {\n message: 'Missing voice id.',\n },\n};\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,kBAAkB,GAAG,OAAO,CAAC,8BAA8B,GAAG,KAAK,CAAC,CAAC;AAC7E,IAAI,8BAA8B,CAAC;AACnC,CAAC,UAAU,8BAA8B,EAAE;AAC3C,IAAI,8BAA8B,CAAC,8BAA8B,CAAC,GAAG,8BAA8B,CAAC;AACpG,IAAI,8BAA8B,CAAC,cAAc,CAAC,GAAG,cAAc,CAAC;AACpE,IAAI,8BAA8B,CAAC,eAAe,CAAC,GAAG,eAAe,CAAC;AACtE,IAAI,8BAA8B,CAAC,eAAe,CAAC,GAAG,eAAe,CAAC;AACtE,IAAI,8BAA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B,CAAC,gBAAgB,GAAG;AACvD,QAAQ,OAAO,EAAE,0CAA0C;AAC3D,KAAK;AACL,IAAI,CAAC,8BAA8B,CAAC,SAAS,GAAG;AAChD,QAAQ,OAAO,EAAE,mBAAmB;AACpC,KAAK;AACL,CAAC;;"}
@@ -1,4 +1,5 @@
1
- "use strict";
1
+ 'use strict';
2
+
2
3
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
4
  // SPDX-License-Identifier: Apache-2.0
4
5
  Object.defineProperty(exports, "__esModule", { value: true });
@@ -12,3 +13,4 @@ function assertValidationError(assertion, name) {
12
13
  }
13
14
  }
14
15
  exports.assertValidationError = assertValidationError;
16
+ //# sourceMappingURL=assertValidationError.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"assertValidationError.js","sources":["../../../../src/errors/utils/assertValidationError.ts"],"sourcesContent":["\"use strict\";\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.assertValidationError = void 0;\nconst PredictionsError_1 = require(\"../PredictionsError\");\nconst validation_1 = require(\"../types/validation\");\nfunction assertValidationError(assertion, name) {\n if (!assertion) {\n const { message, recoverySuggestion } = validation_1.validationErrorMap[name];\n throw new PredictionsError_1.PredictionsError({ name, message, recoverySuggestion });\n }\n}\nexports.assertValidationError = assertValidationError;\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,qBAAqB,GAAG,KAAK,CAAC,CAAC;AACvC,MAAM,kBAAkB,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAAC;AAC1D,MAAM,YAAY,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAAC;AACpD,SAAS,qBAAqB,CAAC,SAAS,EAAE,IAAI,EAAE;AAChD,IAAI,IAAI,CAAC,SAAS,EAAE;AACpB,QAAQ,MAAM,EAAE,OAAO,EAAE,kBAAkB,EAAE,GAAG,YAAY,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAC;AACtF,QAAQ,MAAM,IAAI,kBAAkB,CAAC,gBAAgB,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,kBAAkB,EAAE,CAAC,CAAC;AAC7F,KAAK;AACL,CAAC;AACD,OAAO,CAAC,qBAAqB,GAAG,qBAAqB;;"}
@@ -1,7 +1,9 @@
1
- "use strict";
1
+ 'use strict';
2
+
2
3
  Object.defineProperty(exports, "__esModule", { value: true });
3
4
  exports.Predictions = void 0;
4
5
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
5
6
  // SPDX-License-Identifier: Apache-2.0
6
7
  var Predictions_1 = require("./Predictions");
7
8
  Object.defineProperty(exports, "Predictions", { enumerable: true, get: function () { return Predictions_1.Predictions; } });
9
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../../src/index.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.Predictions = void 0;\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nvar Predictions_1 = require(\"./Predictions\");\nObject.defineProperty(exports, \"Predictions\", { enumerable: true, get: function () { return Predictions_1.Predictions; } });\n"],"names":[],"mappings":";;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,WAAW,GAAG,KAAK,CAAC,CAAC;AAC7B;AACA;AACA,IAAI,aAAa,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;AAC7C,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,aAAa,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,YAAY,EAAE,OAAO,aAAa,CAAC,WAAW,CAAC,EAAE,EAAE,CAAC;;"}
@@ -1,4 +1,5 @@
1
- "use strict";
1
+ 'use strict';
2
+
2
3
  Object.defineProperty(exports, "__esModule", { value: true });
3
4
  exports.AmazonAIConvertPredictionsProvider = void 0;
4
5
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
@@ -305,3 +306,4 @@ class AmazonAIConvertPredictionsProvider {
305
306
  }
306
307
  }
307
308
  exports.AmazonAIConvertPredictionsProvider = AmazonAIConvertPredictionsProvider;
309
+ //# sourceMappingURL=AmazonAIConvertPredictionsProvider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AmazonAIConvertPredictionsProvider.js","sources":["../../../src/providers/AmazonAIConvertPredictionsProvider.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.AmazonAIConvertPredictionsProvider = void 0;\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nconst core_1 = require(\"@aws-amplify/core\");\nconst utils_1 = require(\"@aws-amplify/core/internals/utils\");\nconst client_polly_1 = require(\"@aws-sdk/client-polly\");\nconst client_translate_1 = require(\"@aws-sdk/client-translate\");\nconst eventstream_codec_1 = require(\"@smithy/eventstream-codec\");\nconst util_utf8_1 = require(\"@smithy/util-utf8\");\nconst buffer_1 = require(\"buffer\");\nconst validation_1 = require(\"../errors/types/validation\");\nconst assertValidationError_1 = require(\"../errors/utils/assertValidationError\");\nconst types_1 = require(\"../types\");\nconst logger = new core_1.ConsoleLogger('AmazonAIConvertPredictionsProvider');\nconst eventBuilder = new eventstream_codec_1.EventStreamCodec(util_utf8_1.toUtf8, util_utf8_1.fromUtf8);\nconst LANGUAGES_CODE_IN_8KHZ = ['fr-FR', 'en-AU', 'en-GB', 'fr-CA'];\nclass AmazonAIConvertPredictionsProvider {\n constructor() {\n this.inputSampleRate = 44100;\n }\n getProviderName() {\n return 'AmazonAIConvertPredictionsProvider';\n }\n convert(input) {\n (0, assertValidationError_1.assertValidationError)((0, types_1.isValidConvertInput)(input), validation_1.PredictionsValidationErrorCode.InvalidInput);\n if ((0, types_1.isTranslateTextInput)(input)) {\n logger.debug('translateText');\n return this.translateText(input);\n }\n else if ((0, types_1.isTextToSpeechInput)(input)) {\n logger.debug('textToSpeech');\n return this.convertTextToSpeech(input);\n }\n else {\n logger.debug('textToSpeech');\n return this.convertSpeechToText(input);\n }\n }\n async translateText(input) {\n logger.debug('Starting translation');\n const { translateText = {} } = core_1.Amplify.getConfig().Predictions?.convert ?? {};\n (0, assertValidationError_1.assertValidationError)(!!translateText.region, validation_1.PredictionsValidationErrorCode.NoRegion);\n const { defaults = {}, region } = translateText;\n const { credentials } = await (0, core_1.fetchAuthSession)();\n (0, assertValidationError_1.assertValidationError)(!!credentials, validation_1.PredictionsValidationErrorCode.NoCredentials);\n const { sourceLanguage, targetLanguage } = defaults;\n const sourceLanguageCode = input.translateText?.source?.language ?? sourceLanguage;\n const targetLanguageCode = input.translateText?.targetLanguage ?? targetLanguage;\n (0, assertValidationError_1.assertValidationError)(!!sourceLanguageCode, validation_1.PredictionsValidationErrorCode.NoSourceLanguage);\n (0, assertValidationError_1.assertValidationError)(!!targetLanguageCode, validation_1.PredictionsValidationErrorCode.NoTargetLanguage);\n this.translateClient = new client_translate_1.TranslateClient({\n region,\n credentials,\n customUserAgent: (0, utils_1.getAmplifyUserAgentObject)({\n category: utils_1.Category.Predictions,\n action: utils_1.PredictionsAction.Convert,\n }),\n });\n const translateTextCommand = new client_translate_1.TranslateTextCommand({\n SourceLanguageCode: sourceLanguageCode,\n TargetLanguageCode: targetLanguageCode,\n Text: input.translateText?.source?.text,\n });\n const data = await this.translateClient.send(translateTextCommand);\n return {\n text: data.TranslatedText,\n language: data.TargetLanguageCode,\n };\n }\n async convertTextToSpeech(input) {\n const { credentials } = await (0, core_1.fetchAuthSession)();\n (0, assertValidationError_1.assertValidationError)(!!credentials, validation_1.PredictionsValidationErrorCode.NoCredentials);\n (0, assertValidationError_1.assertValidationError)(!!input.textToSpeech?.source, validation_1.PredictionsValidationErrorCode.NoSource);\n const { speechGenerator } = core_1.Amplify.getConfig().Predictions?.convert ?? {};\n (0, assertValidationError_1.assertValidationError)(!!speechGenerator?.region, validation_1.PredictionsValidationErrorCode.NoRegion);\n const { defaults = {}, region } = speechGenerator;\n const { voiceId: defaultVoiceId } = defaults;\n const voiceId = input.textToSpeech?.voiceId ?? defaultVoiceId;\n (0, assertValidationError_1.assertValidationError)(!!voiceId, validation_1.PredictionsValidationErrorCode.NoVoiceId);\n this.pollyClient = new client_polly_1.PollyClient({\n region,\n credentials,\n customUserAgent: (0, utils_1.getAmplifyUserAgentObject)({\n category: utils_1.Category.Predictions,\n action: utils_1.PredictionsAction.Convert,\n }),\n });\n const synthesizeSpeechCommand = new client_polly_1.SynthesizeSpeechCommand({\n OutputFormat: 'mp3',\n Text: input.textToSpeech?.source?.text,\n VoiceId: voiceId,\n TextType: 'text',\n SampleRate: '24000',\n // tslint:disable-next-line: align\n });\n const data = await this.pollyClient.send(synthesizeSpeechCommand);\n const response = new Response(data.AudioStream);\n const arrayBuffer = await response.arrayBuffer();\n const blob = new Blob([arrayBuffer], {\n type: data.ContentType,\n });\n const url = URL.createObjectURL(blob);\n return {\n speech: { url },\n audioStream: arrayBuffer,\n text: input.textToSpeech?.source?.text,\n };\n }\n async convertSpeechToText(input) {\n logger.debug('starting transcription..');\n const { credentials } = await (0, core_1.fetchAuthSession)();\n (0, assertValidationError_1.assertValidationError)(!!credentials, validation_1.PredictionsValidationErrorCode.NoCredentials);\n const { transcription } = core_1.Amplify.getConfig().Predictions?.convert ?? {};\n (0, assertValidationError_1.assertValidationError)(!!transcription?.region, validation_1.PredictionsValidationErrorCode.NoRegion);\n const { defaults, region } = transcription;\n const language = input.transcription?.language ?? defaults?.language;\n (0, assertValidationError_1.assertValidationError)(!!language, validation_1.PredictionsValidationErrorCode.NoLanguage);\n const source = input.transcription?.source;\n (0, assertValidationError_1.assertValidationError)((0, types_1.isConvertBytesSource)(source), validation_1.PredictionsValidationErrorCode.InvalidSource);\n const connection = await this.openConnectionWithTranscribe({\n credentials,\n region,\n languageCode: language,\n });\n const fullText = await this.sendDataToTranscribe({\n connection,\n raw: source.bytes,\n languageCode: language,\n });\n return {\n transcription: {\n fullText,\n },\n };\n }\n static serializeDataFromTranscribe(message) {\n let decodedMessage = '';\n const transcribeMessage = eventBuilder.decode(buffer_1.Buffer.from(message.data));\n const transcribeMessageJson = JSON.parse((0, util_utf8_1.toUtf8)(transcribeMessage.body));\n if (transcribeMessage.headers[':message-type'].value === 'exception') {\n logger.debug('exception', JSON.stringify(transcribeMessageJson.Message, null, 2));\n throw new Error(transcribeMessageJson.Message);\n }\n else if (transcribeMessage.headers[':message-type'].value === 'event') {\n if (transcribeMessageJson.Transcript.Results.length > 0) {\n if (transcribeMessageJson.Transcript.Results[0].Alternatives.length > 0) {\n if (transcribeMessageJson.Transcript.Results[0].Alternatives[0]\n .Transcript.length > 0) {\n if (transcribeMessageJson.Transcript.Results[0].IsPartial === false) {\n decodedMessage =\n transcribeMessageJson.Transcript.Results[0].Alternatives[0]\n .Transcript + '\\n';\n logger.debug({ decodedMessage });\n }\n else {\n logger.debug({\n transcript: transcribeMessageJson.Transcript.Results[0].Alternatives[0],\n });\n }\n }\n }\n }\n }\n return decodedMessage;\n }\n sendDataToTranscribe({ connection, raw, languageCode, }) {\n return new Promise((res, rej) => {\n let fullText = '';\n connection.onmessage = message => {\n try {\n const decodedMessage = AmazonAIConvertPredictionsProvider.serializeDataFromTranscribe(message);\n if (decodedMessage) {\n fullText += decodedMessage + ' ';\n }\n }\n catch (err) {\n logger.debug(err);\n rej(err);\n }\n };\n connection.onerror = errorEvent => {\n logger.debug({ errorEvent });\n rej('failed to transcribe, network error');\n };\n connection.onclose = closeEvent => {\n logger.debug({ closeEvent });\n return res(fullText.trim());\n };\n logger.debug({ raw });\n if (Array.isArray(raw)) {\n for (let i = 0; i < raw.length - 1023; i += 1024) {\n const data = raw.slice(i, i + 1024);\n this.sendEncodedDataToTranscribe(connection, data, languageCode);\n }\n }\n else {\n // If Buffer\n this.sendEncodedDataToTranscribe(connection, raw, languageCode);\n }\n // sending end frame\n const endFrameEventMessage = this.getAudioEventMessage(buffer_1.Buffer.from([]));\n const endFrameBinary = eventBuilder.encode(endFrameEventMessage);\n connection.send(endFrameBinary);\n });\n }\n sendEncodedDataToTranscribe(connection, data, languageCode) {\n const downsampledBuffer = this.downsampleBuffer({\n buffer: data,\n outputSampleRate: LANGUAGES_CODE_IN_8KHZ.includes(languageCode)\n ? 8000\n : 16000,\n });\n const pcmEncodedBuffer = this.pcmEncode(downsampledBuffer);\n const audioEventMessage = this.getAudioEventMessage(buffer_1.Buffer.from(pcmEncodedBuffer));\n const binary = eventBuilder.encode(audioEventMessage);\n connection.send(binary);\n }\n getAudioEventMessage(buffer) {\n const audioEventMessage = {\n body: buffer,\n headers: {\n ':message-type': {\n type: 'string',\n value: 'event',\n },\n ':event-type': {\n type: 'string',\n value: 'AudioEvent',\n },\n },\n };\n return audioEventMessage;\n }\n pcmEncode(input) {\n let offset = 0;\n // ArrayBuffer cannot be processed using length property\n if (input instanceof ArrayBuffer) {\n return input;\n }\n const buffer = new ArrayBuffer(input.length * 2);\n const view = new DataView(buffer);\n for (let i = 0; i < input.length; i++, offset += 2) {\n const s = Math.max(-1, Math.min(1, input[i]));\n view.setInt16(offset, s < 0 ? s * 0x8000 : s * 0x7fff, true);\n }\n return buffer;\n }\n downsampleBuffer({ buffer, outputSampleRate = 16000, }) {\n // Cannot process ArrayBuffer using length property\n if (outputSampleRate === this.inputSampleRate ||\n buffer instanceof ArrayBuffer) {\n return buffer;\n }\n const sampleRateRatio = this.inputSampleRate / outputSampleRate;\n const newLength = Math.round(buffer.length / sampleRateRatio);\n const result = new Float32Array(newLength);\n let offsetResult = 0;\n let offsetBuffer = 0;\n while (offsetResult < result.length) {\n const nextOffsetBuffer = Math.round((offsetResult + 1) * sampleRateRatio);\n let accum = 0, count = 0;\n for (let i = offsetBuffer; i < nextOffsetBuffer && i < buffer.length; i++) {\n accum += buffer[i];\n count++;\n }\n result[offsetResult] = accum / count;\n offsetResult++;\n offsetBuffer = nextOffsetBuffer;\n }\n return result;\n }\n openConnectionWithTranscribe({ credentials, region, languageCode, }) {\n return new Promise(async (res, rej) => {\n const signedUrl = this.generateTranscribeUrl({\n credentials,\n region,\n languageCode,\n });\n logger.debug('connecting...');\n const connection = new WebSocket(signedUrl);\n connection.binaryType = 'arraybuffer';\n connection.onopen = () => {\n logger.debug('connected');\n res(connection);\n };\n });\n }\n generateTranscribeUrl({ credentials: { accessKeyId, secretAccessKey, sessionToken }, region, languageCode, }) {\n const credentials = {\n access_key: accessKeyId,\n secret_key: secretAccessKey,\n session_token: sessionToken,\n };\n const url = [\n `wss://transcribestreaming.${region}.amazonaws.com:8443`,\n '/stream-transcription-websocket?',\n `media-encoding=pcm&`,\n `sample-rate=${LANGUAGES_CODE_IN_8KHZ.includes(languageCode) ? '8000' : '16000'}&`,\n `language-code=${languageCode}`,\n ].join('');\n const signedUrl = utils_1.Signer.signUrl(url, credentials, { region, service: 'transcribe' }, 300);\n return signedUrl;\n }\n}\nexports.AmazonAIConvertPredictionsProvider = AmazonAIConvertPredictionsProvider;\n"],"names":[],"mappings":";;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,kCAAkC,GAAG,KAAK,CAAC,CAAC;AACpD;AACA;AACA,MAAM,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC;AAC5C,MAAM,OAAO,GAAG,OAAO,CAAC,mCAAmC,CAAC,CAAC;AAC7D,MAAM,cAAc,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAAC;AACxD,MAAM,kBAAkB,GAAG,OAAO,CAAC,2BAA2B,CAAC,CAAC;AAChE,MAAM,mBAAmB,GAAG,OAAO,CAAC,2BAA2B,CA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C9C,YAAY,CAAC,mBAAmB,CAAC;AACjC,YAAY,CAAC,YAAY,EAAE,sBAAsB,CAAC,QAAQ,CAAC,YAAY,CAAC,GAAG,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC;AAC9F,YAAY,CAAC,cAAc,EAAE,YAAY,CAAC,CAAC;AAC3C,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AACnB,QAAQ,MAAM,SAAS,GAAG,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,EAAE,WAAW,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,YAAY,EAAE,EAAE,GAAG,CAAC,CAAC;AAC3G,QAAQ,OAAO,SAAS,CAAC;AACzB,KAAK;AACL,CAAC;AACD,OAAO,CAAC,kCAAkC,GAAG,kCAAkC;;"}
@@ -1,4 +1,5 @@
1
- "use strict";
1
+ 'use strict';
2
+
2
3
  Object.defineProperty(exports, "__esModule", { value: true });
3
4
  exports.AmazonAIIdentifyPredictionsProvider = void 0;
4
5
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
@@ -332,3 +333,4 @@ function _getPredictionsIdentifyAmplifyUserAgent() {
332
333
  action: utils_1.PredictionsAction.Identify,
333
334
  });
334
335
  }
336
+ //# sourceMappingURL=AmazonAIIdentifyPredictionsProvider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AmazonAIIdentifyPredictionsProvider.js","sources":["../../../src/providers/AmazonAIIdentifyPredictionsProvider.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.AmazonAIIdentifyPredictionsProvider = void 0;\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nconst core_1 = require(\"@aws-amplify/core\");\nconst utils_1 = require(\"@aws-amplify/core/internals/utils\");\nconst storage_1 = require(\"@aws-amplify/storage\");\nconst client_rekognition_1 = require(\"@aws-sdk/client-rekognition\");\nconst client_textract_1 = require(\"@aws-sdk/client-textract\");\nconst validation_1 = require(\"../errors/types/validation\");\nconst assertValidationError_1 = require(\"../errors/utils/assertValidationError\");\nconst types_1 = require(\"../types\");\nconst IdentifyTextUtils_1 = require(\"./IdentifyTextUtils\");\nconst Utils_1 = require(\"./Utils\");\nconst logger = new core_1.ConsoleLogger('AmazonAIIdentifyPredictionsProvider');\nclass AmazonAIIdentifyPredictionsProvider {\n getProviderName() {\n return 'AmazonAIIdentifyPredictionsProvider';\n }\n identify(input) {\n (0, assertValidationError_1.assertValidationError)((0, types_1.isValidIdentifyInput)(input), validation_1.PredictionsValidationErrorCode.InvalidInput);\n if ((0, types_1.isIdentifyTextInput)(input)) {\n logger.debug('identifyText');\n return this.identifyText(input);\n }\n else if ((0, types_1.isIdentifyLabelsInput)(input)) {\n logger.debug('identifyLabels');\n return this.identifyLabels(input);\n }\n else {\n logger.debug('identifyEntities');\n return this.identifyEntities(input);\n }\n }\n /**\n * Verify user input source and converts it into source object readable by Rekognition and Textract.\n * Note that Rekognition and Textract use the same source interface, so we need not worry about types.\n * @param {IdentifySource} source - User input source that directs to the object user wants\n * to identify (storage, file, or bytes).\n * @return {Promise<Image>} - Promise resolving to the converted source object.\n */\n configureSource(source) {\n return new Promise((res, rej) => {\n if ((0, types_1.isStorageSource)(source)) {\n const storageConfig = {\n accessLevel: source.level,\n targetIdentityId: source.identityId,\n };\n (0, storage_1.getUrl)({ key: source.key, options: storageConfig })\n .then(value => {\n const parser = /https:\\/\\/([a-zA-Z0-9%\\-_.]+)\\.s3\\.[A-Za-z0-9%\\-._~]+\\/([a-zA-Z0-9%\\-._~/]+)\\?/;\n const parsedURL = value.url.toString().match(parser) ?? '';\n if (parsedURL.length < 3)\n rej('Invalid S3 key was given.');\n res({\n S3Object: {\n Bucket: parsedURL[1],\n Name: decodeURIComponent(parsedURL[2]),\n },\n });\n })\n .catch(err => rej(err));\n }\n else if ((0, types_1.isFileSource)(source)) {\n (0, Utils_1.blobToArrayBuffer)(source.file)\n .then(buffer => {\n res({ Bytes: new Uint8Array(buffer) });\n })\n .catch(err => rej(err));\n }\n else if ((0, types_1.isIdentifyBytesSource)(source)) {\n const bytes = source.bytes;\n if (bytes instanceof Blob) {\n (0, Utils_1.blobToArrayBuffer)(bytes)\n .then(buffer => {\n res({ Bytes: new Uint8Array(buffer) });\n })\n .catch(err => rej(err));\n }\n if (bytes instanceof ArrayBuffer || bytes instanceof Buffer) {\n res({ Bytes: new Uint8Array(bytes) });\n }\n // everything else can be directly passed to Rekognition / Textract.\n res({ Bytes: bytes });\n }\n else {\n rej('Input source is not configured correctly.');\n }\n });\n }\n /**\n * Recognize text from real-world images and documents (plain text, forms and tables). Detects text in the input\n * image and converts it into machine-readable text.\n * @param {IdentifySource} source - Object containing the source image and feature types to analyze.\n * @return {Promise<IdentifyTextOutput>} - Promise resolving to object containing identified texts.\n */\n async identifyText(input) {\n const { credentials } = await (0, core_1.fetchAuthSession)();\n (0, assertValidationError_1.assertValidationError)(!!credentials, validation_1.PredictionsValidationErrorCode.NoCredentials);\n const { identifyText = {} } = core_1.Amplify.getConfig().Predictions?.identify ?? {};\n const { region = '', defaults = {} } = identifyText;\n const { format: configFormat = 'PLAIN' } = defaults;\n this.rekognitionClient = new client_rekognition_1.RekognitionClient({\n region,\n credentials,\n customUserAgent: _getPredictionsIdentifyAmplifyUserAgent(),\n });\n this.textractClient = new client_textract_1.TextractClient({\n region,\n credentials,\n customUserAgent: _getPredictionsIdentifyAmplifyUserAgent(),\n });\n let inputDocument;\n inputDocument = await this.configureSource(input.text?.source);\n // get default value if format isn't specified in the input.\n const format = input.text?.format ?? configFormat;\n const featureTypes = []; // structures we want to analyze (e.g. [TABLES, FORMS]).\n if (format === 'FORM' || format === 'ALL')\n featureTypes.push('FORMS');\n if (format === 'TABLE' || format === 'ALL')\n featureTypes.push('TABLES');\n if (featureTypes.length === 0) {\n /**\n * Empty featureTypes indicates that we will identify plain text. We will use rekognition (suitable\n * for everyday images but has 50 word limit) first and see if reaches its word limit. If it does, then\n * we call textract and use the data that identify more words.\n */\n const textractParam = {\n Document: inputDocument,\n };\n const rekognitionParam = {\n Image: inputDocument,\n };\n const detectTextCommand = new client_rekognition_1.DetectTextCommand(rekognitionParam);\n const rekognitionData = await this.rekognitionClient.send(detectTextCommand);\n const rekognitionResponse = (0, IdentifyTextUtils_1.categorizeRekognitionBlocks)(rekognitionData.TextDetections);\n if (rekognitionResponse.text.words.length < 50) {\n // did not hit the word limit, return the data\n return rekognitionResponse;\n }\n const detectDocumentTextCommand = new client_textract_1.DetectDocumentTextCommand(textractParam);\n const { Blocks } = await this.textractClient.send(detectDocumentTextCommand);\n if ((rekognitionData.TextDetections?.length ?? 0) > (Blocks?.length ?? 0)) {\n return rekognitionResponse;\n }\n return (0, IdentifyTextUtils_1.categorizeTextractBlocks)(Blocks);\n }\n else {\n const param = {\n Document: inputDocument,\n FeatureTypes: featureTypes,\n };\n const analyzeDocumentCommand = new client_textract_1.AnalyzeDocumentCommand(param);\n const { Blocks } = await this.textractClient.send(analyzeDocumentCommand);\n return (0, IdentifyTextUtils_1.categorizeTextractBlocks)(Blocks);\n }\n }\n /**\n * Identify instances of real world entities from an image and if it contains unsafe content.\n * @param {IdentifyLabelsInput} input - Object containing the source image and entity type to identify.\n * @return {Promise<IdentifyLabelsOutput>} - Promise resolving to an array of identified entities.\n */\n async identifyLabels(input) {\n const { credentials } = await (0, core_1.fetchAuthSession)();\n (0, assertValidationError_1.assertValidationError)(!!credentials, validation_1.PredictionsValidationErrorCode.NoCredentials);\n const { identifyLabels = {} } = core_1.Amplify.getConfig().Predictions?.identify ?? {};\n const { region = '', defaults = {} } = identifyLabels;\n const { type = 'LABELS' } = defaults;\n this.rekognitionClient = new client_rekognition_1.RekognitionClient({\n region,\n credentials,\n customUserAgent: _getPredictionsIdentifyAmplifyUserAgent(),\n });\n const inputImage = await this.configureSource(input.labels?.source);\n const param = { Image: inputImage };\n const servicePromises = [];\n // get default argument\n const entityType = input.labels?.type ?? type;\n if (entityType === 'LABELS' || entityType === 'ALL') {\n servicePromises.push(this.detectLabels(param));\n }\n if (entityType === 'UNSAFE' || entityType === 'ALL') {\n servicePromises.push(this.detectModerationLabels(param));\n }\n return Promise.all(servicePromises).then(data => {\n let identifyResult = {};\n // concatenate resolved promises to a single object\n data.forEach(val => {\n identifyResult = { ...identifyResult, ...val };\n });\n return identifyResult;\n });\n }\n /**\n * Calls Rekognition.detectLabels and organizes the returned data.\n * @param {DetectLabelsInput} param - parameter to be passed onto Rekognition\n * @return {Promise<IdentifyLabelsOutput>} - Promise resolving to organized detectLabels response.\n */\n async detectLabels(param) {\n const detectLabelsCommand = new client_rekognition_1.DetectLabelsCommand(param);\n const data = await this.rekognitionClient.send(detectLabelsCommand);\n if (!data.Labels)\n return {}; // no image was detected\n const detectLabelData = data.Labels.map(label => {\n const boxes = label.Instances?.map(instance => (0, Utils_1.makeCamelCase)(instance.BoundingBox)) || [];\n return {\n name: label.Name,\n boundingBoxes: boxes,\n metadata: {\n confidence: label.Confidence,\n parents: (0, Utils_1.makeCamelCaseArray)(label.Parents),\n },\n };\n });\n return { labels: detectLabelData };\n }\n /**\n * Calls Rekognition.detectModerationLabels and organizes the returned data.\n * @param {Rekognition.DetectLabelsRequest} param - Parameter to be passed onto Rekognition\n * @return {Promise<IdentifyLabelsOutput>} - Promise resolving to organized detectModerationLabels response.\n */\n async detectModerationLabels(param) {\n const detectModerationLabelsCommand = new client_rekognition_1.DetectModerationLabelsCommand(param);\n const data = await this.rekognitionClient.send(detectModerationLabelsCommand);\n if (data.ModerationLabels?.length !== 0) {\n return { unsafe: 'YES' };\n }\n else {\n return { unsafe: 'NO' };\n }\n }\n /**\n * Identify faces within an image that is provided as input, and match faces from a collection\n * or identify celebrities.\n * @param {IdentifyEntityInput} input - object containing the source image and face match options.\n * @return {Promise<IdentifyEntityOutput>} Promise resolving to identify results.\n */\n async identifyEntities(input) {\n const { credentials } = await (0, core_1.fetchAuthSession)();\n (0, assertValidationError_1.assertValidationError)(!!credentials, validation_1.PredictionsValidationErrorCode.NoCredentials);\n const { identifyEntities = {} } = core_1.Amplify.getConfig().Predictions?.identify ?? {};\n const { region = '', celebrityDetectionEnabled = false, defaults = {}, } = identifyEntities;\n const { collectionId: collectionIdConfig = '', maxEntities: maxFacesConfig = 50, } = defaults;\n // default arguments\n this.rekognitionClient = new client_rekognition_1.RekognitionClient({\n region,\n credentials,\n customUserAgent: _getPredictionsIdentifyAmplifyUserAgent(),\n });\n const inputImage = await this.configureSource(input.entities?.source);\n const param = { Attributes: ['ALL'], Image: inputImage };\n if ((0, types_1.isIdentifyCelebrities)(input.entities) &&\n input.entities.celebrityDetection) {\n (0, assertValidationError_1.assertValidationError)(celebrityDetectionEnabled, validation_1.PredictionsValidationErrorCode.CelebrityDetectionNotEnabled);\n const recognizeCelebritiesCommand = new client_rekognition_1.RecognizeCelebritiesCommand(param);\n const data = await this.rekognitionClient.send(recognizeCelebritiesCommand);\n const faces = data.CelebrityFaces?.map(celebrity => ({\n boundingBox: (0, Utils_1.makeCamelCase)(celebrity.Face?.BoundingBox),\n landmarks: (0, Utils_1.makeCamelCaseArray)(celebrity.Face?.Landmarks),\n metadata: {\n ...(0, Utils_1.makeCamelCase)(celebrity, ['Id', 'Name', 'Urls']),\n pose: (0, Utils_1.makeCamelCase)(celebrity.Face?.Pose),\n },\n })) ?? [];\n return { entities: faces };\n }\n else if ((0, types_1.isIdentifyFromCollection)(input.entities) &&\n input.entities.collection) {\n const { collectionId = collectionIdConfig, maxEntities: maxFaces = maxFacesConfig, } = input.entities;\n // Concatenate additional parameters\n const updatedParam = {\n ...param,\n CollectionId: collectionId,\n MaxFaces: maxFaces,\n };\n const searchFacesByImageCommand = new client_rekognition_1.SearchFacesByImageCommand(updatedParam);\n const data = await this.rekognitionClient.send(searchFacesByImageCommand);\n const faces = data.FaceMatches?.map(match => {\n const externalImageId = match.Face?.ExternalImageId\n ? this.decodeExternalImageId(match.Face.ExternalImageId)\n : undefined;\n return {\n boundingBox: (0, Utils_1.makeCamelCase)(match.Face?.BoundingBox),\n metadata: {\n externalImageId,\n similarity: match.Similarity,\n },\n };\n }) ?? [];\n return { entities: faces };\n }\n else {\n const detectFacesCommand = new client_rekognition_1.DetectFacesCommand(param);\n const data = await this.rekognitionClient.send(detectFacesCommand);\n const faces = data.FaceDetails?.map(detail => {\n // face attributes keys we want to extract from Rekognition's response\n const attributeKeys = [\n 'Smile',\n 'Eyeglasses',\n 'Sunglasses',\n 'Gender',\n 'Beard',\n 'Mustache',\n 'EyesOpen',\n 'MouthOpen',\n ];\n const faceAttributes = (0, Utils_1.makeCamelCase)(detail, attributeKeys);\n faceAttributes.emotions = detail.Emotions?.map(emotion => emotion.Type);\n return {\n boundingBox: (0, Utils_1.makeCamelCase)(detail.BoundingBox),\n landmarks: (0, Utils_1.makeCamelCaseArray)(detail.Landmarks),\n ageRange: (0, Utils_1.makeCamelCase)(detail.AgeRange),\n attributes: faceAttributes,\n metadata: {\n confidence: detail.Confidence,\n pose: (0, Utils_1.makeCamelCase)(detail.Pose),\n },\n };\n }) ?? [];\n return { entities: faces };\n }\n }\n decodeExternalImageId(externalImageId) {\n return ('' + externalImageId).replace(/::/g, '/');\n }\n}\nexports.AmazonAIIdentifyPredictionsProvider = AmazonAIIdentifyPredictionsProvider;\nfunction _getPredictionsIdentifyAmplifyUserAgent() {\n return (0, utils_1.getAmplifyUserAgentObject)({\n category: utils_1.Category.Predictions,\n action: utils_1.PredictionsAction.Identify,\n });\n}\n"],"names":[],"mappings":";;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,mCAAmC,GAAG,KAAK,CAAC,CAAC;AACrD;AACA;AACA,MAAM,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC;AAC5C,MAAM,OAAO,GAAG,OAAO,CAAC,mCAAmC,CAAC,CAAC;AAC7D,MAAM,SAAS,GAAG,OAAO,CAAC,sBAAsB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mazonAIInterpretPredictionsProvider = void 0;
4
5
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
@@ -206,3 +207,4 @@ class AmazonAIInterpretPredictionsProvider {
206
207
  }
207
208
  }
208
209
  exports.AmazonAIInterpretPredictionsProvider = AmazonAIInterpretPredictionsProvider;
210
+ //# sourceMappingURL=AmazonAIInterpretPredictionsProvider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AmazonAIInterpretPredictionsProvider.js","sources":["../../../src/providers/AmazonAIInterpretPredictionsProvider.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.AmazonAIInterpretPredictionsProvider = void 0;\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nconst core_1 = require(\"@aws-amplify/core\");\nconst utils_1 = require(\"@aws-amplify/core/internals/utils\");\nconst client_comprehend_1 = require(\"@aws-sdk/client-comprehend\");\nconst validation_1 = require(\"../errors/types/validation\");\nconst assertValidationError_1 = require(\"../errors/utils/assertValidationError\");\nconst types_1 = require(\"../types\");\nclass AmazonAIInterpretPredictionsProvider {\n getProviderName() {\n return 'AmazonAIInterpretPredictionsProvider';\n }\n interpret(input) {\n (0, assertValidationError_1.assertValidationError)((0, types_1.isValidInterpretInput)(input), validation_1.PredictionsValidationErrorCode.InvalidInput);\n return this.interpretText(input);\n }\n async interpretText(input) {\n const { credentials } = await (0, core_1.fetchAuthSession)();\n (0, assertValidationError_1.assertValidationError)(!!credentials, validation_1.PredictionsValidationErrorCode.NoCredentials);\n const { interpretText = {} } = core_1.Amplify.getConfig().Predictions?.interpret ?? {};\n const { region = '', defaults = {} } = interpretText;\n const { type: defaultType = '' } = defaults;\n const { text: textSource } = input;\n const { source, type = defaultType } = textSource;\n const { text } = source;\n let language;\n if ((0, types_1.isInterpretTextOthers)(textSource)) {\n language = textSource.source.language;\n }\n this.comprehendClient = new client_comprehend_1.ComprehendClient({\n credentials,\n region,\n customUserAgent: (0, utils_1.getAmplifyUserAgentObject)({\n category: utils_1.Category.Predictions,\n action: utils_1.PredictionsAction.Interpret,\n }),\n });\n const doAll = type === 'all';\n let languageCode = language;\n if (doAll || type === 'language') {\n const languageDetectionParams = {\n Text: text,\n };\n languageCode = await this.detectLanguage(languageDetectionParams);\n }\n let entitiesPromise;\n if (doAll || type === 'entities') {\n (0, assertValidationError_1.assertValidationError)(!!languageCode, validation_1.PredictionsValidationErrorCode.NoLanguage);\n const entitiesDetectionParams = {\n Text: text,\n LanguageCode: languageCode,\n };\n entitiesPromise = this.detectEntities(entitiesDetectionParams);\n }\n let sentimentPromise;\n if (doAll || type === 'sentiment') {\n (0, assertValidationError_1.assertValidationError)(!!languageCode, validation_1.PredictionsValidationErrorCode.NoLanguage);\n const sentimentParams = {\n Text: text,\n LanguageCode: languageCode,\n };\n sentimentPromise = this.detectSentiment(sentimentParams);\n }\n let syntaxPromise;\n if (doAll || type === 'syntax') {\n (0, assertValidationError_1.assertValidationError)(!!languageCode, validation_1.PredictionsValidationErrorCode.NoLanguage);\n const syntaxParams = {\n Text: text,\n LanguageCode: languageCode,\n };\n syntaxPromise = this.detectSyntax(syntaxParams);\n }\n let keyPhrasesPromise;\n if (doAll || type === 'keyPhrases') {\n (0, assertValidationError_1.assertValidationError)(!!languageCode, validation_1.PredictionsValidationErrorCode.NoLanguage);\n const keyPhrasesParams = {\n Text: text,\n LanguageCode: languageCode,\n };\n keyPhrasesPromise = this.detectKeyPhrases(keyPhrasesParams);\n }\n const [textEntities, sentiment, syntax, keyPhrases] = await Promise.all([\n entitiesPromise,\n sentimentPromise,\n syntaxPromise,\n keyPhrasesPromise,\n ]);\n return {\n textInterpretation: {\n keyPhrases,\n language: languageCode,\n sentiment,\n syntax,\n textEntities,\n },\n };\n }\n async detectKeyPhrases(params) {\n try {\n const detectKeyPhrasesCommand = new client_comprehend_1.DetectKeyPhrasesCommand(params);\n const data = await this.comprehendClient.send(detectKeyPhrasesCommand);\n const { KeyPhrases = [] } = data || {};\n return KeyPhrases.map(({ Text: text }) => {\n return { text };\n });\n }\n catch (err) {\n if (err.code === 'AccessDeniedException') {\n throw new Error('Not authorized, did you enable Interpret Text on predictions category Amplify CLI? try: ' +\n 'amplify predictions add');\n }\n else {\n throw err;\n }\n }\n }\n async detectSyntax(params) {\n try {\n const detectSyntaxCommand = new client_comprehend_1.DetectSyntaxCommand(params);\n const data = await this.comprehendClient.send(detectSyntaxCommand);\n const { SyntaxTokens = [] } = data || {};\n return this.serializeSyntaxFromComprehend(SyntaxTokens);\n }\n catch (err) {\n if (err.code === 'AccessDeniedException') {\n throw new Error('Not authorized, did you enable Interpret Text on predictions category Amplify CLI? try: ' +\n 'amplify predictions add');\n }\n else {\n throw err;\n }\n }\n }\n serializeSyntaxFromComprehend(tokens) {\n let response = [];\n if (tokens && Array.isArray(tokens)) {\n response = tokens.map(({ Text: text = '', PartOfSpeech: { Tag: syntax = '' } = {} }) => {\n return { text, syntax };\n });\n }\n return response;\n }\n async detectSentiment(params) {\n try {\n const detectSentimentCommand = new client_comprehend_1.DetectSentimentCommand(params);\n const data = await this.comprehendClient.send(detectSentimentCommand);\n const { Sentiment: predominant = '', SentimentScore: { Positive: positive = 0, Negative: negative = 0, Neutral: neutral = 0, Mixed: mixed = 0, } = {}, } = ({} = data);\n return { predominant, positive, negative, neutral, mixed };\n }\n catch (err) {\n if (err.code === 'AccessDeniedException') {\n throw new Error('Not authorized, did you enable Interpret Text on predictions category Amplify CLI? try: ' +\n 'amplify predictions add');\n }\n else {\n throw err;\n }\n }\n }\n async detectEntities(params) {\n try {\n const detectEntitiesCommand = new client_comprehend_1.DetectEntitiesCommand(params);\n const data = await this.comprehendClient.send(detectEntitiesCommand);\n const { Entities = [] } = data || {};\n return this.serializeEntitiesFromComprehend(Entities);\n }\n catch (err) {\n if (err.code === 'AccessDeniedException') {\n throw new Error('Not authorized, did you enable Interpret Text on predictions category Amplify CLI? try: ' +\n 'amplify predictions add');\n }\n else {\n throw err;\n }\n }\n }\n serializeEntitiesFromComprehend(data) {\n let response = [];\n if (data && Array.isArray(data)) {\n response = data.map(({ Type: type, Text: text }) => {\n return { type, text };\n });\n }\n return response;\n }\n async detectLanguage(params) {\n try {\n const detectDominantLanguageCommand = new client_comprehend_1.DetectDominantLanguageCommand(params);\n const data = await this.comprehendClient.send(detectDominantLanguageCommand);\n const { Languages: [{ LanguageCode }] = [{}] } = ({} = data || {});\n (0, assertValidationError_1.assertValidationError)(!!LanguageCode, validation_1.PredictionsValidationErrorCode.NoLanguage);\n return LanguageCode;\n }\n catch (err) {\n if (err.code === 'AccessDeniedException') {\n throw new Error('Not authorized, did you enable Interpret Text on predictions category Amplify CLI? try: ' +\n 'amplify predictions add');\n }\n else {\n throw err;\n }\n }\n }\n}\nexports.AmazonAIInterpretPredictionsProvider = AmazonAIInterpretPredictionsProvider;\n"],"names":[],"mappings":";;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,oCAAoC,GAAG,KAAK,CAAC,CAAC;AACtD;AACA;AACA,MAAM,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC;AAC5C,MAAM,OAAO,GAAG,OAAO,CAAC,mCAAmC,CAAC,CAAC;AAC7D,MAAM,mBAAmB,GAAG,OAAO,CAAC,4BAA4B,CAAC,CAAC;AAClE,MAAM,YAAY,GAAG,OAAO,CAAC,4BAA4B,CAAC,CAAC;AAC3D,MAAM,uBAAuB,GAAG,OAAO,CAAC,uCAAuC,CAAC,CAAC;AACjF,MAAM,OAAO,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AACpC,MAAM,oCAAoC,CAAC;AAC3C,IAAI,eAAe,GAAG;AACtB,QAAQ,OAAO,sCAAsC,CAAC;AACtD,KAAK;AACL,IAAI,SAAS,CAAC,KAAK,EAAE;AACrB,QAAQ,IAAI,uBAAuB,CAAC,qBAAqB,EAAE,IA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AAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK;AAChE,gBAAgB,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;AACtC,aAAa,CAAC,CAAC;AACf,SAAS;AACT,QAAQ,OAAO,QAAQ,CAAC;AACxB,KAAK;AACL,IAAI,MAAM,cAAc,CAAC,MAAM,EAAE;AACjC,QAAQ,IAAI;AACZ,YAAY,MAAM,6BAA6B,GAAG,IAAI,mBAAmB,CAAC,6BAA6B,CAAC,MAAM,CAAC,CAAC;AAChH,YAAY,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,6BAA6B,CAAC,CAAC;AACzF,YAAY,MAAM,EAAE,SAAS,EAAE,CAAC,EAAE,YAAY,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,IAAI,EAAE,GAAG,IAAI,IAAI,EAAE,CAAC,CAAC;AAC/E,YAAY,CAAC,CAAC,EAAE,uBAAuB,CAAC,qBAAqB,EAAE,CAAC,CAAC,YAAY,EAAE,YAAY,CAAC,8BAA8B,CAAC,UAAU,CAAC,CAAC;AACvI,YAAY,OAAO,YAAY,CAAC;AAChC,SAAS;AACT,QAAQ,OAAO,GAAG,EAAE;AACpB,YAAY,IAAI,GAAG,CAAC,IAAI,KAAK,uBAAuB,EAAE;AACtD,gBAAgB,MAAM,IAAI,KAAK,CAAC,0FAA0F;AAC1H,oBAAoB,yBAAyB,CAAC,CAAC;AAC/C,aAAa;AACb,iBAAiB;AACjB,gBAAgB,MAAM,GAAG,CAAC;AAC1B,aAAa;AACb,SAAS;AACT,KAAK;AACL,CAAC;AACD,OAAO,CAAC,oCAAoC,GAAG,oCAAoC;;"}
@@ -1,4 +1,5 @@
1
- "use strict";
1
+ 'use strict';
2
+
2
3
  Object.defineProperty(exports, "__esModule", { value: true });
3
4
  exports.categorizeTextractBlocks = exports.categorizeRekognitionBlocks = void 0;
4
5
  const Utils_1 = require("./Utils");
@@ -267,3 +268,4 @@ function extractContentsFromBlock(block, blockMap) {
267
268
  words = words.substr(0, words.length - 1); // remove trailing space.
268
269
  return { text: words, selected: isSelected };
269
270
  }
271
+ //# sourceMappingURL=IdentifyTextUtils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IdentifyTextUtils.js","sources":["../../../src/providers/IdentifyTextUtils.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.categorizeTextractBlocks = exports.categorizeRekognitionBlocks = void 0;\nconst Utils_1 = require(\"./Utils\");\nfunction getBoundingBox(geometry) {\n return (0, Utils_1.makeCamelCase)(geometry?.BoundingBox);\n}\nfunction getPolygon(geometry) {\n if (!geometry?.Polygon)\n return undefined;\n return (0, Utils_1.makeCamelCaseArray)(Array.from(geometry.Polygon));\n}\n/**\n * Organizes blocks from Rekognition API to each of the categories and and structures\n * their data accordingly.\n * @param {BlockList} source - Array containing blocks returned from Textract API.\n * @return {IdentifyTextOutput} - Object that categorizes each block and its information.\n */\nfunction categorizeRekognitionBlocks(blocks) {\n // Skeleton IdentifyText API response. We will populate it as we iterate through blocks.\n const response = {\n text: {\n fullText: '',\n words: [],\n lines: [],\n linesDetailed: [],\n },\n };\n // We categorize each block by running a forEach loop through them.\n blocks.forEach(block => {\n switch (block.Type) {\n case 'LINE':\n if (block.DetectedText) {\n response.text.lines.push(block.DetectedText);\n }\n response.text.linesDetailed.push({\n text: block.DetectedText,\n polygon: getPolygon(block.Geometry),\n boundingBox: getBoundingBox(block.Geometry),\n page: undefined, // rekognition doesn't have this info\n });\n break;\n case 'WORD':\n response.text.fullText += block.DetectedText + ' ';\n response.text.words.push({\n text: block.DetectedText,\n polygon: getPolygon(block.Geometry),\n boundingBox: getBoundingBox(block.Geometry),\n });\n break;\n }\n });\n // remove trailing space of fullText\n response.text.fullText = response.text.fullText.substr(0, response.text.fullText.length - 1);\n return response;\n}\nexports.categorizeRekognitionBlocks = categorizeRekognitionBlocks;\n/**\n * Organizes blocks from Textract API to each of the categories and and structures\n * their data accordingly.\n * @param {BlockList} source - Array containing blocks returned from Textract API.\n * @return {IdentifyTextOutput} - Object that categorizes each block and its information.\n */\nfunction categorizeTextractBlocks(blocks) {\n // Skeleton IdentifyText API response. We will populate it as we iterate through blocks.\n const response = {\n text: {\n fullText: '',\n words: [],\n lines: [],\n linesDetailed: [],\n },\n };\n // if blocks is an empty array, ie. textract did not detect anything, return empty response.\n if (blocks.length === 0)\n return response;\n /**\n * We categorize each of the blocks by running a forEach loop through them.\n *\n * For complex structures such as Tables and KeyValue, we need to trasverse through their children. To do so,\n * we will post-process them after the for each loop. We do this by storing table and keyvalues in arrays and\n * mapping other blocks in `blockMap` (id to block) so we can reference them easily later.\n *\n * Note that we do not map `WORD` and `TABLE` in `blockMap` because they will not be referenced by any other\n * block except the Page block.\n */\n const tableBlocks = Array();\n const keyValueBlocks = Array();\n const blockMap = {};\n blocks.forEach(block => {\n switch (block.BlockType) {\n case 'LINE':\n if (block.Text) {\n response.text.lines.push(block.Text);\n }\n response.text.linesDetailed.push({\n text: block.Text,\n polygon: getPolygon(block.Geometry),\n boundingBox: getBoundingBox(block.Geometry),\n page: block.Page,\n });\n break;\n case 'WORD':\n response.text.fullText += block.Text + ' ';\n response.text.words.push({\n text: block.Text,\n polygon: getPolygon(block.Geometry),\n boundingBox: getBoundingBox(block.Geometry),\n });\n if (block.Id) {\n blockMap[block.Id] = block;\n }\n break;\n case 'SELECTION_ELEMENT':\n const selectionStatus = block.SelectionStatus === 'SELECTED' ? true : false;\n if (!response.text.selections)\n response.text.selections = [];\n response.text.selections.push({\n selected: selectionStatus,\n polygon: getPolygon(block.Geometry),\n boundingBox: getBoundingBox(block.Geometry),\n });\n if (block.Id) {\n blockMap[block.Id] = block;\n }\n break;\n case 'TABLE':\n tableBlocks.push(block);\n break;\n case 'KEY_VALUE_SET':\n keyValueBlocks.push(block);\n if (block.Id) {\n blockMap[block.Id] = block;\n }\n break;\n default:\n if (block.Id) {\n blockMap[block.Id] = block;\n }\n }\n });\n // remove trailing space in fullText\n response.text.fullText = response.text.fullText.substr(0, response.text.fullText.length - 1);\n // Post-process complex structures if they exist.\n if (tableBlocks.length !== 0) {\n const tableResponse = Array();\n tableBlocks.forEach(table => {\n tableResponse.push(constructTable(table, blockMap));\n });\n response.text.tables = tableResponse;\n }\n if (keyValueBlocks.length !== 0) {\n const keyValueResponse = Array();\n keyValueBlocks.forEach(keyValue => {\n // We need the KeyValue blocks of EntityType = `KEY`, which has both key and value references.\n if (keyValue.EntityTypes) {\n const entityTypes = Array.from(keyValue.EntityTypes);\n if (entityTypes.indexOf('KEY') !== -1) {\n keyValueResponse.push(constructKeyValue(keyValue, blockMap));\n }\n }\n });\n response.text.keyValues = keyValueResponse;\n }\n return response;\n}\nexports.categorizeTextractBlocks = categorizeTextractBlocks;\n/**\n * Constructs a table object using data from its children cells.\n * @param {Block} table - Table block that has references (`Relationships`) to its cells\n * @param {[id: string]: Block} blockMap - Maps block Ids to blocks.\n */\nfunction constructTable(table, blockMap) {\n let tableMatrix;\n tableMatrix = [];\n // visit each of the cell associated with the table's relationship.\n for (const tableRelation of table.Relationships ?? []) {\n for (const cellId of tableRelation.Ids ?? []) {\n const cellBlock = blockMap[cellId];\n if (cellBlock.RowIndex && cellBlock.ColumnIndex) {\n const row = cellBlock.RowIndex - 1; // textract starts indexing at 1, so subtract it by 1.\n const col = cellBlock.ColumnIndex - 1; // textract starts indexing at 1, so subtract it by 1.\n // extract data contained inside the cell.\n const content = extractContentsFromBlock(cellBlock, blockMap);\n const cell = {\n text: content.text,\n boundingBox: getBoundingBox(cellBlock.Geometry),\n polygon: getPolygon(cellBlock.Geometry),\n selected: content.selected,\n rowSpan: cellBlock.RowSpan,\n columnSpan: cellBlock.ColumnSpan,\n };\n if (!tableMatrix[row])\n tableMatrix[row] = [];\n tableMatrix[row][col] = cell;\n }\n }\n }\n const rowSize = tableMatrix.length;\n const columnSize = tableMatrix[0].length;\n const boundingBox = getBoundingBox(table.Geometry);\n const polygon = getPolygon(table.Geometry);\n // Note that we leave spanned cells undefined for distinction\n return {\n size: { rows: rowSize, columns: columnSize },\n table: tableMatrix,\n boundingBox,\n polygon,\n };\n}\n/**\n * Constructs a key value object from its children key and value blocks.\n * @param {Block} KeyValue - KeyValue block that has references (`Relationships`) to its children.\n * @param {[id: string]: Block} blockMap - Maps block Ids to blocks.\n */\nfunction constructKeyValue(keyBlock, blockMap) {\n let keyText = '';\n let valueText = '';\n let valueSelected = false;\n for (const keyValueRelation of keyBlock.Relationships ?? []) {\n if (keyValueRelation.Type === 'CHILD') {\n // relation refers to key\n const contents = extractContentsFromBlock(keyBlock, blockMap);\n keyText = contents.text ?? '';\n }\n else if (keyValueRelation.Type === 'VALUE') {\n // relation refers to value\n for (const valueId of keyValueRelation.Ids ?? []) {\n const valueBlock = blockMap[valueId];\n const contents = extractContentsFromBlock(valueBlock, blockMap);\n valueText = contents.text ?? '';\n if (contents.selected != null)\n valueSelected = contents.selected;\n }\n }\n }\n return {\n key: keyText,\n value: { text: valueText, selected: valueSelected },\n polygon: getPolygon(keyBlock.Geometry),\n boundingBox: getBoundingBox(keyBlock.Geometry),\n };\n}\n/**\n * Extracts text and selection from input block's children.\n * @param {Block}} block - Block that we want to extract contents from.\n * @param {[id: string]: Block} blockMap - Maps block Ids to blocks.\n */\nfunction extractContentsFromBlock(block, blockMap) {\n let words = '';\n let isSelected = false;\n if (!block.Relationships) {\n // some block might have no content\n return { text: '', selected: undefined };\n }\n for (const relation of block.Relationships) {\n for (const contentId of relation.Ids ?? []) {\n const contentBlock = blockMap[contentId];\n if (contentBlock.BlockType === 'WORD') {\n words += contentBlock.Text + ' ';\n }\n else if (contentBlock.BlockType === 'SELECTION_ELEMENT') {\n isSelected = contentBlock.SelectionStatus === 'SELECTED' ? true : false;\n }\n }\n }\n words = words.substr(0, words.length - 1); // remove trailing space.\n return { text: words, selected: isSelected };\n}\n"],"names":[],"mappings":";;AACA,M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BAAmB,EAAE;AACrE,gBAAgB,UAAU,GAAG,YAAY,CAAC,eAAe,KAAK,UAAU,GAAG,IAAI,GAAG,KAAK,CAAC;AACxF,aAAa;AACb,SAAS;AACT,KAAK;AACL,IAAI,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,EAAE,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;AAC9C,IAAI,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,UAAU,EAAE,CAAC;AACjD;;"}
@@ -1,4 +1,5 @@
1
- "use strict";
1
+ 'use strict';
2
+
2
3
  Object.defineProperty(exports, "__esModule", { value: true });
3
4
  exports.blobToArrayBuffer = exports.makeCamelCaseArray = exports.makeCamelCase = void 0;
4
5
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
@@ -52,3 +53,4 @@ function blobToArrayBuffer(blob) {
52
53
  });
53
54
  }
54
55
  exports.blobToArrayBuffer = blobToArrayBuffer;
56
+ //# sourceMappingURL=Utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Utils.js","sources":["../../../src/providers/Utils.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.blobToArrayBuffer = exports.makeCamelCaseArray = exports.makeCamelCase = void 0;\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n/**\n * Changes object keys to camel case. If optional parameter `keys` is given, then we extract only the\n * keys specified in `keys`.\n */\nfunction makeCamelCase(obj, keys) {\n if (!obj)\n return undefined;\n const newObj = {};\n const keysToRename = keys ? keys : Object.keys(obj);\n keysToRename.forEach(key => {\n if (obj.hasOwnProperty(key)) {\n // change the key to camelcase.\n const camelCaseKey = key.charAt(0).toLowerCase() + key.substr(1);\n Object.assign(newObj, { [camelCaseKey]: obj[key] });\n }\n });\n return newObj;\n}\nexports.makeCamelCase = makeCamelCase;\n/**\n * Given an array of object, call makeCamelCase(...) on each option.\n */\nfunction makeCamelCaseArray(objArr, keys) {\n if (!objArr)\n return undefined;\n return objArr.map(obj => makeCamelCase(obj, keys));\n}\nexports.makeCamelCaseArray = makeCamelCaseArray;\n/**\n * Converts blob to array buffer\n */\nfunction blobToArrayBuffer(blob) {\n return new Promise((res, rej) => {\n const reader = new FileReader();\n reader.onload = _event => {\n res(reader.result);\n };\n reader.onerror = err => {\n rej(err);\n };\n try {\n reader.readAsArrayBuffer(blob);\n }\n catch (err) {\n rej(err); // in case user gives invalid type\n }\n });\n}\nexports.blobToArrayBuffer = blobToArrayBuffer;\n"],"names":[],"mappings":";;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,iBAAiB,GAAG,OAAO,CAAC,kBAAkB,GAAG,OAAO,CAAC,aAAa,GAAG,KAAK,CAAC,CAAC;AACxF;AACA;AACA;AACA;AACA;AACA;AACA,SAAS,aAAa,CAAC,GAAG,EAAE,IAAI,EAAE;AAClC,IAAI,IAAI,CAAC,GAAG;AACZ,QAAQ,OAAO,SAAS,CAAC;AACzB,IAAI,MAAM,MAAM,GAAG,EAAE,CAAC;AACtB,IAAI,MAAM,YAAY,GAAG,IAAI,GAAG,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACxD,IAAI,YAAY,CAAC,OAAO,CAAC,GAAG,IAAI;AAChC,QAAQ,IAAI,GAAG,CAAC,cAAc,CAAC,GAAG,CAAC,EAAE;AACrC;AACA,YAAY,MAAM,YAAY,GAAG,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;AAC7E,YAAY,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,EAAE,CAAC,YAAY,GAAG,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;AAChE,SAAS;AACT,KAAK,CAAC,CAAC;AACP,IAAI,OAAO,MAAM,CAAC;AAClB,CAAC;AACD,OAAO,CAAC,aAAa,GAAG,aAAa,CAAC;AACtC;AACA;AACA;AACA,SAAS,kBAAkB,CAAC,MAAM,EAAE,IAAI,EAAE;AAC1C,IAAI,IAAI,CAAC,MAAM;AACf,QAAQ,OAAO,SAAS,CAAC;AACzB,IAAI,OAAO,MAAM,CAAC,GAAG,CAAC,GAAG,IAAI,aAAa,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC,CAAC;AACvD,CAAC;AACD,OAAO,CAAC,kBAAkB,GAAG,kBAAkB,CAAC;AAChD;AACA;AACA;AACA,SAAS,iBAAiB,CAAC,IAAI,EAAE;AACjC,IAAI,OAAO,IAAI,OAAO,CAAC,CAAC,GAAG,EAAE,GAAG,KAAK;AACrC,QAAQ,MAAM,MAAM,GAAG,IAAI,UAAU,EAAE,CAAC;AACxC,QAAQ,MAAM,CAAC,MAAM,GAAG,MAAM,IAAI;AAClC,YAAY,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;AAC/B,SAAS,CAAC;AACV,QAAQ,MAAM,CAAC,OAAO,GAAG,GAAG,IAAI;AAChC,YAAY,GAAG,CAAC,GAAG,CAAC,CAAC;AACrB,SAAS,CAAC;AACV,QAAQ,IAAI;AACZ,YAAY,MAAM,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC;AAC3C,SAAS;AACT,QAAQ,OAAO,GAAG,EAAE;AACpB,YAAY,GAAG,CAAC,GAAG,CAAC,CAAC;AACrB,SAAS;AACT,KAAK,CAAC,CAAC;AACP,CAAC;AACD,OAAO,CAAC,iBAAiB,GAAG,iBAAiB;;"}
@@ -1,4 +1,5 @@
1
- "use strict";
1
+ 'use strict';
2
+
2
3
  Object.defineProperty(exports, "__esModule", { value: true });
3
4
  exports.AmazonAIInterpretPredictionsProvider = exports.AmazonAIIdentifyPredictionsProvider = exports.AmazonAIConvertPredictionsProvider = void 0;
4
5
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
@@ -9,3 +10,4 @@ const AmazonAIIdentifyPredictionsProvider_1 = require("./AmazonAIIdentifyPredict
9
10
  Object.defineProperty(exports, "AmazonAIIdentifyPredictionsProvider", { enumerable: true, get: function () { return AmazonAIIdentifyPredictionsProvider_1.AmazonAIIdentifyPredictionsProvider; } });
10
11
  const AmazonAIInterpretPredictionsProvider_1 = require("./AmazonAIInterpretPredictionsProvider");
11
12
  Object.defineProperty(exports, "AmazonAIInterpretPredictionsProvider", { enumerable: true, get: function () { return AmazonAIInterpretPredictionsProvider_1.AmazonAIInterpretPredictionsProvider; } });
13
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../../../src/providers/index.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.AmazonAIInterpretPredictionsProvider = exports.AmazonAIIdentifyPredictionsProvider = exports.AmazonAIConvertPredictionsProvider = void 0;\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nconst AmazonAIConvertPredictionsProvider_1 = require(\"./AmazonAIConvertPredictionsProvider\");\nObject.defineProperty(exports, \"AmazonAIConvertPredictionsProvider\", { enumerable: true, get: function () { return AmazonAIConvertPredictionsProvider_1.AmazonAIConvertPredictionsProvider; } });\nconst AmazonAIIdentifyPredictionsProvider_1 = require(\"./AmazonAIIdentifyPredictionsProvider\");\nObject.defineProperty(exports, \"AmazonAIIdentifyPredictionsProvider\", { enumerable: true, get: function () { return AmazonAIIdentifyPredictionsProvider_1.AmazonAIIdentifyPredictionsProvider; } });\nconst AmazonAIInterpretPredictionsProvider_1 = require(\"./AmazonAIInterpretPredictionsProvider\");\nObject.defineProperty(exports, \"AmazonAIInterpretPredictionsProvider\", { enumerable: true, get: function () { return AmazonAIInterpretPredictionsProvider_1.AmazonAIInterpretPredictionsProvider; } });\n"],"names":[],"mappings":";;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,oCAAoC,GAAG,OAAO,CAAC,mCAAmC,GAAG,OAAO,CAAC,kCAAkC,GAAG,KAAK,CAAC,CAAC;AACjJ;AACA;AACA,MAAM,oCAAoC,GAAG,OAAO,CAAC,sCAAsC,CAAC,CAAC;AAC7F,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,oCAAoC,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,YAAY,EAAE,OAAO,oCAAoC,CAAC,kCAAkC,CAAC,EAAE,EAAE,CAAC,CAAC;AACjM,MAAM,qCAAqC,GAAG,OAAO,CAAC,uCAAuC,CAAC,CAAC;AAC/F,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,qCAAqC,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,YAAY,EAAE,OAAO,qCAAqC,CAAC,mCAAmC,CAAC,EAAE,EAAE,CAAC,CAAC;AACpM,MAAM,sCAAsC,GAAG,OAAO,CAAC,wCAAwC,CAAC,CAAC;AACjG,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,sCAAsC,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,YAAY,EAAE,OAAO,sCAAsC,CAAC,oCAAoC,CAAC,EAAE,EAAE,CAAC;;"}
@@ -1,2 +1,4 @@
1
- "use strict";
1
+ 'use strict';
2
+
2
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
+ //# sourceMappingURL=AWSTypes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AWSTypes.js","sources":["../../../src/types/AWSTypes.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\n"],"names":[],"mappings":";;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;;"}
@@ -1,4 +1,5 @@
1
- "use strict";
1
+ 'use strict';
2
+
2
3
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
4
  // SPDX-License-Identifier: Apache-2.0
4
5
  /* tslint:disable:max-line-length */
@@ -90,3 +91,4 @@ function isInterpretTextOthers(text) {
90
91
  return text.source.language !== undefined;
91
92
  }
92
93
  exports.isInterpretTextOthers = isInterpretTextOthers;
94
+ //# sourceMappingURL=Predictions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Predictions.js","sources":["../../../src/types/Predictions.ts"],"sourcesContent":["\"use strict\";\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n/* tslint:disable:max-line-length */\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.isInterpretTextOthers = exports.isInterpretTextInput = exports.isIdentifyEntitiesInput = exports.isIdentifyLabelsInput = exports.isIdentifyTextInput = exports.isIdentifyBytesSource = exports.isConvertBytesSource = exports.isFileSource = exports.isStorageSource = exports.isSpeechToTextInput = exports.isTextToSpeechInput = exports.isTranslateTextInput = exports.isIdentifyCelebrities = exports.isIdentifyFromCollection = exports.isValidInterpretInput = exports.isValidIdentifyInput = exports.isValidConvertInput = void 0;\nfunction isValidConvertInput(obj) {\n return (isTranslateTextInput(obj) ||\n isTextToSpeechInput(obj) ||\n isSpeechToTextInput(obj));\n}\nexports.isValidConvertInput = isValidConvertInput;\nfunction isValidIdentifyInput(obj) {\n return (isIdentifyTextInput(obj) ||\n isIdentifyLabelsInput(obj) ||\n isIdentifyEntitiesInput(obj));\n}\nexports.isValidIdentifyInput = isValidIdentifyInput;\nfunction isValidInterpretInput(obj) {\n return isInterpretTextInput(obj);\n}\nexports.isValidInterpretInput = isValidInterpretInput;\nfunction isIdentifyFromCollection(obj) {\n const key = 'collection';\n const keyId = 'collectionId';\n return obj && (obj.hasOwnProperty(key) || obj.hasOwnProperty(keyId));\n}\nexports.isIdentifyFromCollection = isIdentifyFromCollection;\nfunction isIdentifyCelebrities(obj) {\n const key = 'celebrityDetection';\n return obj && obj.hasOwnProperty(key);\n}\nexports.isIdentifyCelebrities = isIdentifyCelebrities;\nfunction isTranslateTextInput(obj) {\n const key = 'translateText';\n return obj && obj.hasOwnProperty(key);\n}\nexports.isTranslateTextInput = isTranslateTextInput;\nfunction isTextToSpeechInput(obj) {\n const key = 'textToSpeech';\n return obj && obj.hasOwnProperty(key);\n}\nexports.isTextToSpeechInput = isTextToSpeechInput;\nfunction isSpeechToTextInput(obj) {\n const key = 'transcription';\n return obj && obj.hasOwnProperty(key);\n}\nexports.isSpeechToTextInput = isSpeechToTextInput;\nfunction isStorageSource(obj) {\n const key = 'key';\n return obj && obj.hasOwnProperty(key);\n}\nexports.isStorageSource = isStorageSource;\nfunction isFileSource(obj) {\n const key = 'file';\n return obj && obj.hasOwnProperty(key);\n}\nexports.isFileSource = isFileSource;\nfunction isConvertBytesSource(obj) {\n const key = 'bytes';\n return obj && obj.hasOwnProperty(key);\n}\nexports.isConvertBytesSource = isConvertBytesSource;\nfunction isIdentifyBytesSource(obj) {\n const key = 'bytes';\n return obj && obj.hasOwnProperty(key);\n}\nexports.isIdentifyBytesSource = isIdentifyBytesSource;\nfunction isIdentifyTextInput(obj) {\n const key = 'text';\n return obj && obj.hasOwnProperty(key);\n}\nexports.isIdentifyTextInput = isIdentifyTextInput;\nfunction isIdentifyLabelsInput(obj) {\n const key = 'labels';\n return obj && obj.hasOwnProperty(key);\n}\nexports.isIdentifyLabelsInput = isIdentifyLabelsInput;\nfunction isIdentifyEntitiesInput(obj) {\n const key = 'entities';\n return obj && obj.hasOwnProperty(key);\n}\nexports.isIdentifyEntitiesInput = isIdentifyEntitiesInput;\nfunction isInterpretTextInput(obj) {\n const key = 'text';\n return obj && obj.hasOwnProperty(key);\n}\nexports.isInterpretTextInput = isInterpretTextInput;\nfunction isInterpretTextOthers(text) {\n return text.source.language !== undefined;\n}\nexports.isInterpretTextOthers = isInterpretTextOthers;\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AAC3B,IAAI,OAAO,GAAG,IAAI,GAAG,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC;AAC1C,CAAC;AACD,OAAO,CAAC,uBAAuB,GAAG,uBAAuB,CAAC;AAC1D,SAAS,oBAAoB,CAAC,GAAG,EAAE;AACnC,IAAI,MAAM,GAAG,GAAG,MAAM,CAAC;AACvB,IAAI,OAAO,GAAG,IAAI,GAAG,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC;AAC1C,CAAC;AACD,OAAO,CAAC,oBAAoB,GAAG,oBAAoB,CAAC;AACpD,SAAS,qBAAqB,CAAC,IAAI,EAAE;AACrC,IAAI,OAAO,IAAI,CAAC,MAAM,CAAC,QAAQ,KAAK,SAAS,CAAC;AAC9C,CAAC;AACD,OAAO,CAAC,qBAAqB,GAAG,qBAAqB;;"}
@@ -1,6 +1,8 @@
1
- "use strict";
1
+ 'use strict';
2
+
2
3
  Object.defineProperty(exports, "__esModule", { value: true });
3
4
  const tslib_1 = require("tslib");
4
5
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
5
6
  // SPDX-License-Identifier: Apache-2.0
6
7
  tslib_1.__exportStar(require("./Predictions"), exports);
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../../../src/types/index.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nconst tslib_1 = require(\"tslib\");\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\ntslib_1.__exportStar(require(\"./Predictions\"), exports);\n"],"names":[],"mappings":";;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;AACjC;AACA;AACA,OAAO,CAAC,YAAY,CAAC,OAAO,CAAC,eAAe,CAAC,EAAE,OAAO,CAAC;;"}
@@ -1,9 +1,12 @@
1
+ import { ConsoleLogger } from '@aws-amplify/core';
2
+ import { AmazonAIConvertPredictionsProvider } from './providers/AmazonAIConvertPredictionsProvider.mjs';
3
+ import { AmazonAIIdentifyPredictionsProvider } from './providers/AmazonAIIdentifyPredictionsProvider.mjs';
4
+ import { AmazonAIInterpretPredictionsProvider } from './providers/AmazonAIInterpretPredictionsProvider.mjs';
5
+
1
6
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
7
  // SPDX-License-Identifier: Apache-2.0
3
- import { ConsoleLogger as Logger } from '@aws-amplify/core';
4
- import { AmazonAIConvertPredictionsProvider, AmazonAIIdentifyPredictionsProvider, AmazonAIInterpretPredictionsProvider, } from './providers';
5
- const logger = new Logger('Predictions');
6
- export class PredictionsClass {
8
+ new ConsoleLogger('Predictions');
9
+ class PredictionsClass {
7
10
  constructor() {
8
11
  this.convertProvider = new AmazonAIConvertPredictionsProvider();
9
12
  this.identifyProvider = new AmazonAIIdentifyPredictionsProvider();
@@ -22,4 +25,7 @@ export class PredictionsClass {
22
25
  return this.identifyProvider.identify(input);
23
26
  }
24
27
  }
25
- export const Predictions = new PredictionsClass();
28
+ const Predictions = new PredictionsClass();
29
+
30
+ export { Predictions, PredictionsClass };
31
+ //# sourceMappingURL=Predictions.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Predictions.mjs","sources":["../../src/Predictions.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { ConsoleLogger } from '@aws-amplify/core';\nimport { AmazonAIConvertPredictionsProvider, AmazonAIIdentifyPredictionsProvider, AmazonAIInterpretPredictionsProvider, } from './providers';\nconst logger = new ConsoleLogger('Predictions');\nexport class PredictionsClass {\n constructor() {\n this.convertProvider = new AmazonAIConvertPredictionsProvider();\n this.identifyProvider = new AmazonAIIdentifyPredictionsProvider();\n this.interpretProvider = new AmazonAIInterpretPredictionsProvider();\n }\n getModuleName() {\n return 'Predictions';\n }\n interpret(input) {\n return this.interpretProvider.interpret(input);\n }\n convert(input) {\n return this.convertProvider.convert(input);\n }\n identify(input) {\n return this.identifyProvider.identify(input);\n }\n}\nexport const Predictions = new PredictionsClass();\n"],"names":[],"mappings":";;;;;AAAA;AACA;AAGe,IAAI,aAAa,CAAC,aAAa,EAAE;AACzC,MAAM,gBAAgB,CAAC;AAC9B,IAAI,WAAW,GAAG;AAClB,QAAQ,IAAI,CAAC,eAAe,GAAG,IAAI,kCAAkC,EAAE,CAAC;AACxE,QAAQ,IAAI,CAAC,gBAAgB,GAAG,IAAI,mCAAmC,EAAE,CAAC;AAC1E,QAAQ,IAAI,CAAC,iBAAiB,GAAG,IAAI,oCAAoC,EAAE,CAAC;AAC5E,KAAK;AACL,IAAI,aAAa,GAAG;AACpB,QAAQ,OAAO,aAAa,CAAC;AAC7B,KAAK;AACL,IAAI,SAAS,CAAC,KAAK,EAAE;AACrB,QAAQ,OAAO,IAAI,CAAC,iBAAiB,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;AACvD,KAAK;AACL,IAAI,OAAO,CAAC,KAAK,EAAE;AACnB,QAAQ,OAAO,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AACnD,KAAK;AACL,IAAI,QAAQ,CAAC,KAAK,EAAE;AACpB,QAAQ,OAAO,IAAI,CAAC,gBAAgB,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;AACrD,KAAK;AACL,CAAC;AACW,MAAC,WAAW,GAAG,IAAI,gBAAgB;;;;"}
@@ -1,7 +1,8 @@
1
+ import { AmplifyError } from '@aws-amplify/core/internals/utils';
2
+
1
3
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
4
  // SPDX-License-Identifier: Apache-2.0
3
- import { AmplifyError, } from '@aws-amplify/core/internals/utils';
4
- export class PredictionsError extends AmplifyError {
5
+ class PredictionsError extends AmplifyError {
5
6
  constructor(params) {
6
7
  super(params);
7
8
  // TODO: Delete the following 2 lines after we change the build target to >= es2015
@@ -9,3 +10,6 @@ export class PredictionsError extends AmplifyError {
9
10
  Object.setPrototypeOf(this, PredictionsError.prototype);
10
11
  }
11
12
  }
13
+
14
+ export { PredictionsError };
15
+ //# sourceMappingURL=PredictionsError.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PredictionsError.mjs","sources":["../../../src/errors/PredictionsError.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { AmplifyError, } from '@aws-amplify/core/internals/utils';\nexport class PredictionsError extends AmplifyError {\n constructor(params) {\n super(params);\n // TODO: Delete the following 2 lines after we change the build target to >= es2015\n this.constructor = PredictionsError;\n Object.setPrototypeOf(this, PredictionsError.prototype);\n }\n}\n"],"names":[],"mappings":";;AAAA;AACA;AAEO,MAAM,gBAAgB,SAAS,YAAY,CAAC;AACnD,IAAI,WAAW,CAAC,MAAM,EAAE;AACxB,QAAQ,KAAK,CAAC,MAAM,CAAC,CAAC;AACtB;AACA,QAAQ,IAAI,CAAC,WAAW,GAAG,gBAAgB,CAAC;AAC5C,QAAQ,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,gBAAgB,CAAC,SAAS,CAAC,CAAC;AAChE,KAAK;AACL;;;;"}
@@ -1,6 +1,6 @@
1
1
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
2
  // SPDX-License-Identifier: Apache-2.0
3
- export var PredictionsValidationErrorCode;
3
+ var PredictionsValidationErrorCode;
4
4
  (function (PredictionsValidationErrorCode) {
5
5
  PredictionsValidationErrorCode["CelebrityDetectionNotEnabled"] = "CelebrityDetectionNotEnabled";
6
6
  PredictionsValidationErrorCode["InvalidInput"] = "InvalidInput";
@@ -13,7 +13,7 @@ export var PredictionsValidationErrorCode;
13
13
  PredictionsValidationErrorCode["NoTargetLanguage"] = "NoTargetLanguage";
14
14
  PredictionsValidationErrorCode["NoVoiceId"] = "NoVoiceId";
15
15
  })(PredictionsValidationErrorCode || (PredictionsValidationErrorCode = {}));
16
- export const validationErrorMap = {
16
+ const validationErrorMap = {
17
17
  [PredictionsValidationErrorCode.CelebrityDetectionNotEnabled]: {
18
18
  message: 'Celebrity Detection must be enabled.',
19
19
  },
@@ -45,3 +45,6 @@ export const validationErrorMap = {
45
45
  message: 'Missing voice id.',
46
46
  },
47
47
  };
48
+
49
+ export { PredictionsValidationErrorCode, validationErrorMap };
50
+ //# sourceMappingURL=validation.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validation.mjs","sources":["../../../../src/errors/types/validation.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nexport var PredictionsValidationErrorCode;\n(function (PredictionsValidationErrorCode) {\n PredictionsValidationErrorCode[\"CelebrityDetectionNotEnabled\"] = \"CelebrityDetectionNotEnabled\";\n PredictionsValidationErrorCode[\"InvalidInput\"] = \"InvalidInput\";\n PredictionsValidationErrorCode[\"InvalidSource\"] = \"InvalidSource\";\n PredictionsValidationErrorCode[\"NoCredentials\"] = \"NoCredentials\";\n PredictionsValidationErrorCode[\"NoLanguage\"] = \"NoLanguage\";\n PredictionsValidationErrorCode[\"NoRegion\"] = \"NoRegion\";\n PredictionsValidationErrorCode[\"NoSource\"] = \"NoSource\";\n PredictionsValidationErrorCode[\"NoSourceLanguage\"] = \"NoSourceLanguage\";\n PredictionsValidationErrorCode[\"NoTargetLanguage\"] = \"NoTargetLanguage\";\n PredictionsValidationErrorCode[\"NoVoiceId\"] = \"NoVoiceId\";\n})(PredictionsValidationErrorCode || (PredictionsValidationErrorCode = {}));\nexport const validationErrorMap = {\n [PredictionsValidationErrorCode.CelebrityDetectionNotEnabled]: {\n message: 'Celebrity Detection must be enabled.',\n },\n [PredictionsValidationErrorCode.InvalidInput]: {\n message: 'Input does not conform to expected type.',\n },\n [PredictionsValidationErrorCode.InvalidSource]: {\n message: 'Source type not supported.',\n },\n [PredictionsValidationErrorCode.NoCredentials]: {\n message: 'Credentials should not be empty.',\n },\n [PredictionsValidationErrorCode.NoLanguage]: {\n message: 'Missing language.',\n },\n [PredictionsValidationErrorCode.NoRegion]: {\n message: 'Missing region.',\n },\n [PredictionsValidationErrorCode.NoSource]: {\n message: 'Missing source.',\n },\n [PredictionsValidationErrorCode.NoSourceLanguage]: {\n message: 'Missing source language for translation.',\n },\n [PredictionsValidationErrorCode.NoTargetLanguage]: {\n message: 'Missing target language for translation.',\n },\n [PredictionsValidationErrorCode.NoVoiceId]: {\n message: 'Missing voice id.',\n },\n};\n"],"names":[],"mappings":"AAAA;AACA;AACU,IAAC,+BAA+B;AAC1C,CAAC,UAAU,8BAA8B,EAAE;AAC3C,IAAI,8BAA8B,CAAC,8BAA8B,CAAC,GAAG,8BAA8B,CAAC;AACpG,IAAI,8BAA8B,CAAC,cAAc,CAAC,GAAG,cAAc,CAAC;AACpE,IAAI,8BAA8B,CAAC,eAAe,CAAC,GAAG,eAAe,CAAC;AACtE,IAAI,8BAA8B,CAAC,eAAe,CAAC,GAAG,eAAe,CAAC;AACtE,IAAI,8BAA8B,CAAC,YAAY,CAAC,GAAG,YAAY,CAAC;AAChE,IAAI,8BAA8B,CAAC,UAAU,CAAC,GAAG,UAAU,CAAC;AAC5D,IAAI,8BAA8B,CAAC,UAAU,CAAC,GAAG,UAAU,CAAC;AAC5D,IAAI,8BAA8B,CAAC,kBAAkB,CAAC,GAAG,kBAAkB,CAAC;AAC5E,IAAI,8BAA8B,CAAC,kBAAkB,CAAC,GAAG,kBAAkB,CAAC;AAC5E,IAAI,8BAA8B,CAAC,WAAW,CAAC,GAAG,WAAW,CAAC;AAC9D,CAAC,EAAE,8BAA8B,KAAK,8BAA8B,GAAG,EAAE,CAAC,CAAC,CAAC;AAChE,MAAC,kBAAkB,GAAG;AAClC,IAAI,CAAC,8BAA8B,CAAC,4BAA4B,GAAG;AACnE,QAAQ,OAAO,EA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