@aws-amplify/interactions 4.0.48 → 4.0.49-next.13

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/CHANGELOG.md +78 -0
  2. package/dist/aws-amplify-interactions.js +25945 -6010
  3. package/dist/aws-amplify-interactions.js.map +1 -1
  4. package/dist/aws-amplify-interactions.min.js +64 -4
  5. package/dist/aws-amplify-interactions.min.js.map +1 -1
  6. package/lib/Interactions.d.ts +2 -2
  7. package/lib/Interactions.js +37 -18
  8. package/lib/Interactions.js.map +1 -1
  9. package/lib/Providers/AWSLexProvider.d.ts +16 -3
  10. package/lib/Providers/AWSLexProvider.js +114 -68
  11. package/lib/Providers/AWSLexProvider.js.map +1 -1
  12. package/lib/Providers/AWSLexProviderHelper/commonUtils.d.ts +1 -0
  13. package/lib/Providers/AWSLexProviderHelper/{convert.native.js → commonUtils.js} +36 -18
  14. package/lib/Providers/AWSLexProviderHelper/commonUtils.js.map +1 -0
  15. package/lib/Providers/AWSLexProviderHelper/utils.d.ts +3 -0
  16. package/lib/Providers/AWSLexProviderHelper/utils.js +83 -0
  17. package/lib/Providers/AWSLexProviderHelper/utils.js.map +1 -0
  18. package/lib/Providers/AWSLexProviderHelper/utils.native.d.ts +3 -0
  19. package/lib/Providers/AWSLexProviderHelper/utils.native.js +100 -0
  20. package/lib/Providers/AWSLexProviderHelper/utils.native.js.map +1 -0
  21. package/lib/Providers/AWSLexV2Provider.d.ts +58 -0
  22. package/lib/Providers/AWSLexV2Provider.js +351 -0
  23. package/lib/Providers/AWSLexV2Provider.js.map +1 -0
  24. package/lib/Providers/index.d.ts +1 -0
  25. package/lib/Providers/index.js +1 -0
  26. package/lib/Providers/index.js.map +1 -1
  27. package/lib/index.d.ts +2 -0
  28. package/lib/index.js +2 -0
  29. package/lib/index.js.map +1 -1
  30. package/lib/types/Provider.d.ts +2 -1
  31. package/lib/types/Providers/AWSLexProvider.d.ts +10 -0
  32. package/lib/types/Providers/AWSLexProvider.js +3 -0
  33. package/lib/types/Providers/AWSLexProvider.js.map +1 -0
  34. package/lib/types/Providers/AWSLexV2Provider.d.ts +12 -0
  35. package/lib/types/Providers/AWSLexV2Provider.js +3 -0
  36. package/lib/types/Providers/AWSLexV2Provider.js.map +1 -0
  37. package/lib/types/index.d.ts +2 -0
  38. package/lib-esm/Interactions.d.ts +2 -2
  39. package/lib-esm/Interactions.js +37 -18
  40. package/lib-esm/Interactions.js.map +1 -1
  41. package/lib-esm/Providers/AWSLexProvider.d.ts +16 -3
  42. package/lib-esm/Providers/AWSLexProvider.js +113 -67
  43. package/lib-esm/Providers/AWSLexProvider.js.map +1 -1
  44. package/lib-esm/Providers/AWSLexProviderHelper/commonUtils.d.ts +1 -0
  45. package/lib-esm/Providers/AWSLexProviderHelper/{convert.native.js → commonUtils.js} +36 -18
  46. package/lib-esm/Providers/AWSLexProviderHelper/commonUtils.js.map +1 -0
  47. package/lib-esm/Providers/AWSLexProviderHelper/utils.d.ts +3 -0
  48. package/lib-esm/Providers/AWSLexProviderHelper/utils.js +81 -0
  49. package/lib-esm/Providers/AWSLexProviderHelper/utils.js.map +1 -0
  50. package/lib-esm/Providers/AWSLexProviderHelper/utils.native.d.ts +3 -0
  51. package/lib-esm/Providers/AWSLexProviderHelper/utils.native.js +98 -0
  52. package/lib-esm/Providers/AWSLexProviderHelper/utils.native.js.map +1 -0
  53. package/lib-esm/Providers/AWSLexV2Provider.d.ts +58 -0
  54. package/lib-esm/Providers/AWSLexV2Provider.js +349 -0
  55. package/lib-esm/Providers/AWSLexV2Provider.js.map +1 -0
  56. package/lib-esm/Providers/index.d.ts +1 -0
  57. package/lib-esm/Providers/index.js +1 -0
  58. package/lib-esm/Providers/index.js.map +1 -1
  59. package/lib-esm/index.d.ts +2 -0
  60. package/lib-esm/index.js +2 -0
  61. package/lib-esm/index.js.map +1 -1
  62. package/lib-esm/types/Provider.d.ts +2 -1
  63. package/lib-esm/types/Providers/AWSLexProvider.d.ts +10 -0
  64. package/lib-esm/types/Providers/AWSLexProvider.js +1 -0
  65. package/lib-esm/types/Providers/AWSLexProvider.js.map +1 -0
  66. package/lib-esm/types/Providers/AWSLexV2Provider.d.ts +12 -0
  67. package/lib-esm/types/Providers/AWSLexV2Provider.js +1 -0
  68. package/lib-esm/types/Providers/AWSLexV2Provider.js.map +1 -0
  69. package/lib-esm/types/index.d.ts +2 -0
  70. package/package.json +8 -4
  71. package/src/Interactions.ts +43 -21
  72. package/src/Providers/AWSLexProvider.ts +70 -23
  73. package/src/Providers/AWSLexProviderHelper/commonUtils.ts +27 -0
  74. package/src/Providers/AWSLexProviderHelper/utils.native.ts +56 -0
  75. package/src/Providers/AWSLexProviderHelper/utils.ts +39 -0
  76. package/src/Providers/AWSLexV2Provider.ts +343 -0
  77. package/src/Providers/index.ts +1 -0
  78. package/src/index.ts +2 -0
  79. package/src/types/Provider.ts +1 -1
  80. package/src/types/Providers/AWSLexProvider.ts +23 -0
  81. package/src/types/Providers/AWSLexV2Provider.ts +25 -0
  82. package/src/types/index.ts +2 -0
  83. package/lib/Providers/AWSLexProviderHelper/convert.d.ts +0 -3
  84. package/lib/Providers/AWSLexProviderHelper/convert.js +0 -13
  85. package/lib/Providers/AWSLexProviderHelper/convert.js.map +0 -1
  86. package/lib/Providers/AWSLexProviderHelper/convert.native.d.ts +0 -1
  87. package/lib/Providers/AWSLexProviderHelper/convert.native.js.map +0 -1
  88. package/lib-esm/Providers/AWSLexProviderHelper/convert.d.ts +0 -3
  89. package/lib-esm/Providers/AWSLexProviderHelper/convert.js +0 -11
  90. package/lib-esm/Providers/AWSLexProviderHelper/convert.js.map +0 -1
  91. package/lib-esm/Providers/AWSLexProviderHelper/convert.native.d.ts +0 -1
  92. package/lib-esm/Providers/AWSLexProviderHelper/convert.native.js.map +0 -1
  93. package/src/Providers/AWSLexProviderHelper/convert.native.ts +0 -13
  94. package/src/Providers/AWSLexProviderHelper/convert.ts +0 -12
@@ -0,0 +1,100 @@
1
+ "use strict";
2
+ /*
3
+ * Copyright 2017-2022 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
6
+ * the License. A copy of the License is located at
7
+ *
8
+ * http://aws.amazon.com/apache2.0/
9
+ *
10
+ * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
11
+ * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
12
+ * and limitations under the License.
13
+ */
14
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
15
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
16
+ return new (P || (P = Promise))(function (resolve, reject) {
17
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
18
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
19
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
20
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
21
+ });
22
+ };
23
+ var __generator = (this && this.__generator) || function (thisArg, body) {
24
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
25
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
26
+ function verb(n) { return function (v) { return step([n, v]); }; }
27
+ function step(op) {
28
+ if (f) throw new TypeError("Generator is already executing.");
29
+ while (_) try {
30
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
31
+ if (y = 0, t) op = [op[0] & 2, t.value];
32
+ switch (op[0]) {
33
+ case 0: case 1: t = op; break;
34
+ case 4: _.label++; return { value: op[1], done: false };
35
+ case 5: _.label++; y = op[1]; op = [0]; continue;
36
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
37
+ default:
38
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
39
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
40
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
41
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
42
+ if (t[2]) _.ops.pop();
43
+ _.trys.pop(); continue;
44
+ }
45
+ op = body.call(thisArg, _);
46
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
47
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
48
+ }
49
+ };
50
+ Object.defineProperty(exports, "__esModule", { value: true });
51
+ var base_64_1 = require("base-64");
52
+ var pako_1 = require("pako");
53
+ exports.convert = function (stream) { return __awaiter(void 0, void 0, void 0, function () {
54
+ return __generator(this, function (_a) {
55
+ if (!(stream instanceof Blob)) {
56
+ return [2 /*return*/, Promise.reject('Invalid content type')];
57
+ }
58
+ return [2 /*return*/, new Promise(function (resolve, reject) { return __awaiter(void 0, void 0, void 0, function () {
59
+ var fileReaderInstance_1;
60
+ return __generator(this, function (_a) {
61
+ try {
62
+ fileReaderInstance_1 = new FileReader();
63
+ fileReaderInstance_1.readAsDataURL(stream);
64
+ fileReaderInstance_1.onload = function () { return __awaiter(void 0, void 0, void 0, function () {
65
+ var blobURL, base64Blob, decodedArrayBuffer;
66
+ return __generator(this, function (_a) {
67
+ blobURL = fileReaderInstance_1.result;
68
+ base64Blob = blobURL.split(/,(.*)/s)[1];
69
+ decodedArrayBuffer = exports.base64ToArrayBuffer(base64Blob);
70
+ resolve(decodedArrayBuffer);
71
+ return [2 /*return*/];
72
+ });
73
+ }); };
74
+ }
75
+ catch (error) {
76
+ reject('unable to convert blob to arrayBuffer: ' + error);
77
+ }
78
+ return [2 /*return*/];
79
+ });
80
+ }); })];
81
+ });
82
+ }); };
83
+ exports.base64ToArrayBuffer = function (base64) {
84
+ var binaryString = base_64_1.decode(base64);
85
+ return Uint8Array.from(binaryString, function (c) { return c.charCodeAt(0); });
86
+ };
87
+ exports.gzipDecompressToString = function (data) { return __awaiter(void 0, void 0, void 0, function () {
88
+ return __generator(this, function (_a) {
89
+ return [2 /*return*/, new Promise(function (resolve, reject) {
90
+ try {
91
+ var result = pako_1.ungzip(data, { to: 'string' });
92
+ resolve(result);
93
+ }
94
+ catch (error) {
95
+ reject('unable to decompress' + error);
96
+ }
97
+ })];
98
+ });
99
+ }); };
100
+ //# sourceMappingURL=utils.native.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.native.js","sourceRoot":"","sources":["../../../src/Providers/AWSLexProviderHelper/utils.native.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;GAWG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,mCAAiC;AACjC,6BAA8B;AAEjB,QAAA,OAAO,GAAG,UAAO,MAAc;;QAC3C,IAAI,CAAC,CAAC,MAAM,YAAY,IAAI,CAAC,EAAE;YAC9B,sBAAO,OAAO,CAAC,MAAM,CAAC,sBAAsB,CAAC,EAAC;SAC9C;QAED,sBAAO,IAAI,OAAO,CAAC,UAAO,OAAO,EAAE,MAAM;;;oBACxC,IAAI;wBACG,uBAAqB,IAAI,UAAU,EAAE,CAAC;wBAC5C,oBAAkB,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;wBACzC,oBAAkB,CAAC,MAAM,GAAG;;;gCACrB,OAAO,GAAG,oBAAkB,CAAC,MAAgB,CAAC;gCAE9C,UAAU,GAAG,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;gCAExC,kBAAkB,GAAG,2BAAmB,CAAC,UAAU,CAAC,CAAC;gCAC3D,OAAO,CAAC,kBAAkB,CAAC,CAAC;;;6BAC5B,CAAC;qBACF;oBAAC,OAAO,KAAK,EAAE;wBACf,MAAM,CAAC,yCAAyC,GAAG,KAAK,CAAC,CAAC;qBAC1D;;;iBACD,CAAC,EAAC;;KACH,CAAC;AAEW,QAAA,mBAAmB,GAAG,UAAC,MAAc;IACjD,IAAM,YAAY,GAAW,gBAAM,CAAC,MAAM,CAAC,CAAC;IAC5C,OAAO,UAAU,CAAC,IAAI,CAAC,YAAY,EAAE,UAAA,CAAC,IAAI,OAAA,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,EAAf,CAAe,CAAC,CAAC;AAC5D,CAAC,CAAC;AAEW,QAAA,sBAAsB,GAAG,UACrC,IAAgB;;QAEhB,sBAAO,IAAI,OAAO,CAAC,UAAC,OAAO,EAAE,MAAM;gBAClC,IAAI;oBACH,IAAM,MAAM,GAAW,aAAM,CAAC,IAAI,EAAE,EAAE,EAAE,EAAE,QAAQ,EAAE,CAAC,CAAC;oBACtD,OAAO,CAAC,MAAM,CAAC,CAAC;iBAChB;gBAAC,OAAO,KAAK,EAAE;oBACf,MAAM,CAAC,sBAAsB,GAAG,KAAK,CAAC,CAAC;iBACvC;YACF,CAAC,CAAC,EAAC;;KACH,CAAC"}
@@ -0,0 +1,58 @@
1
+ import { AbstractInteractionsProvider } from './InteractionsProvider';
2
+ import { InteractionsOptions, AWSLexV2ProviderOptions, InteractionsResponse, InteractionsMessage } from '../types';
3
+ export declare class AWSLexV2Provider extends AbstractInteractionsProvider {
4
+ private _lexRuntimeServiceV2Client;
5
+ private _botsCompleteCallback;
6
+ /**
7
+ * Initialize Interactions with AWS configurations
8
+ * @param {InteractionsOptions} options - Configuration object for Interactions
9
+ */
10
+ constructor(options?: InteractionsOptions);
11
+ /**
12
+ * get provider name of the plugin
13
+ * @returns {string} name of the provider
14
+ */
15
+ getProviderName(): string;
16
+ /**
17
+ * Configure Interactions part with aws configuration
18
+ * @param {AWSLexV2ProviderOptions} config - Configuration of the Interactions
19
+ * @return {AWSLexV2ProviderOptions} - Current configuration
20
+ */
21
+ configure(config?: AWSLexV2ProviderOptions): AWSLexV2ProviderOptions;
22
+ /**
23
+ * Send a message to a bot
24
+ * @async
25
+ * @param {string} botname - Bot name to send the message
26
+ * @param {string | InteractionsMessage} message - message to send to the bot
27
+ * @return {Promise<InteractionsResponse>} A promise resolves to the response from the bot
28
+ */
29
+ sendMessage(botname: string, message: string | InteractionsMessage): Promise<InteractionsResponse>;
30
+ /**
31
+ * Attach a onComplete callback function to a bot.
32
+ * The callback is called once the bot's intent is fulfilled
33
+ * @param {string} botname - Bot name to attach the onComplete callback
34
+ * @param {(err: Error | null, confirmation: InteractionsResponse) => void} callback - called when Intent Fulfilled
35
+ */
36
+ onComplete(botname: string, callback: (err: Error | null, confirmation: InteractionsResponse) => void): void;
37
+ /**
38
+ * @private
39
+ * call onComplete callback for a bot if configured
40
+ */
41
+ private _reportBotStatus;
42
+ /**
43
+ * Format UtteranceCommandOutput's response
44
+ * decompress attributes
45
+ * update audioStream format
46
+ */
47
+ private _formatUtteranceCommandOutput;
48
+ /**
49
+ * handle client's `RecognizeTextCommand`
50
+ * used for sending simple text message
51
+ */
52
+ private _handleRecognizeTextCommand;
53
+ /**
54
+ * handle client's `RecognizeUtteranceCommand`
55
+ * used for obj text or obj voice message
56
+ */
57
+ private _handleRecognizeUtteranceCommand;
58
+ }
@@ -0,0 +1,351 @@
1
+ "use strict";
2
+ var __extends = (this && this.__extends) || (function () {
3
+ var extendStatics = function (d, b) {
4
+ extendStatics = Object.setPrototypeOf ||
5
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
+ function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
7
+ return extendStatics(d, b);
8
+ };
9
+ return function (d, b) {
10
+ extendStatics(d, b);
11
+ function __() { this.constructor = d; }
12
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
13
+ };
14
+ })();
15
+ var __assign = (this && this.__assign) || function () {
16
+ __assign = Object.assign || function(t) {
17
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
18
+ s = arguments[i];
19
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
20
+ t[p] = s[p];
21
+ }
22
+ return t;
23
+ };
24
+ return __assign.apply(this, arguments);
25
+ };
26
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
27
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
28
+ return new (P || (P = Promise))(function (resolve, reject) {
29
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
30
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
31
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
32
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
33
+ });
34
+ };
35
+ var __generator = (this && this.__generator) || function (thisArg, body) {
36
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
37
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
38
+ function verb(n) { return function (v) { return step([n, v]); }; }
39
+ function step(op) {
40
+ if (f) throw new TypeError("Generator is already executing.");
41
+ while (_) try {
42
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
43
+ if (y = 0, t) op = [op[0] & 2, t.value];
44
+ switch (op[0]) {
45
+ case 0: case 1: t = op; break;
46
+ case 4: _.label++; return { value: op[1], done: false };
47
+ case 5: _.label++; y = op[1]; op = [0]; continue;
48
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
49
+ default:
50
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
51
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
52
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
53
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
54
+ if (t[2]) _.ops.pop();
55
+ _.trys.pop(); continue;
56
+ }
57
+ op = body.call(thisArg, _);
58
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
59
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
60
+ }
61
+ };
62
+ Object.defineProperty(exports, "__esModule", { value: true });
63
+ /*
64
+ * Copyright 2017-2022 Amazon.com, Inc. or its affiliates. All Rights Reserved.
65
+ *
66
+ * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
67
+ * the License. A copy of the License is located at
68
+ *
69
+ * http://aws.amazon.com/apache2.0/
70
+ *
71
+ * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
72
+ * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
73
+ * and limitations under the License.
74
+ */
75
+ var InteractionsProvider_1 = require("./InteractionsProvider");
76
+ var client_lex_runtime_v2_1 = require("@aws-sdk/client-lex-runtime-v2");
77
+ var core_1 = require("@aws-amplify/core");
78
+ var utils_1 = require("./AWSLexProviderHelper/utils");
79
+ var commonUtils_1 = require("./AWSLexProviderHelper/commonUtils");
80
+ var logger = new core_1.ConsoleLogger('AWSLexV2Provider');
81
+ var AWSLexV2Provider = /** @class */ (function (_super) {
82
+ __extends(AWSLexV2Provider, _super);
83
+ /**
84
+ * Initialize Interactions with AWS configurations
85
+ * @param {InteractionsOptions} options - Configuration object for Interactions
86
+ */
87
+ function AWSLexV2Provider(options) {
88
+ if (options === void 0) { options = {}; }
89
+ var _this = _super.call(this, options) || this;
90
+ _this._botsCompleteCallback = {};
91
+ return _this;
92
+ }
93
+ /**
94
+ * get provider name of the plugin
95
+ * @returns {string} name of the provider
96
+ */
97
+ AWSLexV2Provider.prototype.getProviderName = function () {
98
+ return 'AWSLexV2Provider';
99
+ };
100
+ /**
101
+ * Configure Interactions part with aws configuration
102
+ * @param {AWSLexV2ProviderOptions} config - Configuration of the Interactions
103
+ * @return {AWSLexV2ProviderOptions} - Current configuration
104
+ */
105
+ AWSLexV2Provider.prototype.configure = function (config) {
106
+ if (config === void 0) { config = {}; }
107
+ var propertiesToTest = [
108
+ 'name',
109
+ 'botId',
110
+ 'aliasId',
111
+ 'localeId',
112
+ 'providerName',
113
+ 'region',
114
+ ];
115
+ Object.keys(config).forEach(function (botKey) {
116
+ var botConfig = config[botKey];
117
+ // is bot config correct
118
+ if (!propertiesToTest.every(function (x) { return x in botConfig; })) {
119
+ throw new Error('invalid bot configuration');
120
+ }
121
+ });
122
+ return _super.prototype.configure.call(this, config);
123
+ };
124
+ /**
125
+ * Send a message to a bot
126
+ * @async
127
+ * @param {string} botname - Bot name to send the message
128
+ * @param {string | InteractionsMessage} message - message to send to the bot
129
+ * @return {Promise<InteractionsResponse>} A promise resolves to the response from the bot
130
+ */
131
+ AWSLexV2Provider.prototype.sendMessage = function (botname, message) {
132
+ return __awaiter(this, void 0, void 0, function () {
133
+ var credentials, error_1, response, reqBaseParams;
134
+ return __generator(this, function (_a) {
135
+ switch (_a.label) {
136
+ case 0:
137
+ // check if bot exists
138
+ if (!this._config[botname]) {
139
+ return [2 /*return*/, Promise.reject('Bot ' + botname + ' does not exist')];
140
+ }
141
+ _a.label = 1;
142
+ case 1:
143
+ _a.trys.push([1, 3, , 4]);
144
+ return [4 /*yield*/, core_1.Credentials.get()];
145
+ case 2:
146
+ credentials = _a.sent();
147
+ return [3 /*break*/, 4];
148
+ case 3:
149
+ error_1 = _a.sent();
150
+ return [2 /*return*/, Promise.reject('No credentials')];
151
+ case 4:
152
+ this._lexRuntimeServiceV2Client = new client_lex_runtime_v2_1.LexRuntimeV2Client({
153
+ region: this._config[botname].region,
154
+ credentials: credentials,
155
+ customUserAgent: core_1.getAmplifyUserAgent(),
156
+ });
157
+ reqBaseParams = {
158
+ botAliasId: this._config[botname].aliasId,
159
+ botId: this._config[botname].botId,
160
+ localeId: this._config[botname].localeId,
161
+ sessionId: credentials.identityId,
162
+ };
163
+ if (!(typeof message === 'string')) return [3 /*break*/, 6];
164
+ return [4 /*yield*/, this._handleRecognizeTextCommand(botname, message, reqBaseParams)];
165
+ case 5:
166
+ response = _a.sent();
167
+ return [3 /*break*/, 8];
168
+ case 6: return [4 /*yield*/, this._handleRecognizeUtteranceCommand(botname, message, reqBaseParams)];
169
+ case 7:
170
+ response = _a.sent();
171
+ _a.label = 8;
172
+ case 8: return [2 /*return*/, response];
173
+ }
174
+ });
175
+ });
176
+ };
177
+ /**
178
+ * Attach a onComplete callback function to a bot.
179
+ * The callback is called once the bot's intent is fulfilled
180
+ * @param {string} botname - Bot name to attach the onComplete callback
181
+ * @param {(err: Error | null, confirmation: InteractionsResponse) => void} callback - called when Intent Fulfilled
182
+ */
183
+ AWSLexV2Provider.prototype.onComplete = function (botname, callback) {
184
+ // does bot exist
185
+ if (!this._config[botname]) {
186
+ throw new Error('Bot ' + botname + ' does not exist');
187
+ }
188
+ this._botsCompleteCallback[botname] = callback;
189
+ };
190
+ /**
191
+ * @private
192
+ * call onComplete callback for a bot if configured
193
+ */
194
+ AWSLexV2Provider.prototype._reportBotStatus = function (data, botname) {
195
+ var _this = this;
196
+ var _a, _b, _c, _d, _e, _f;
197
+ var sessionState = data === null || data === void 0 ? void 0 : data.sessionState;
198
+ // Check if state is fulfilled to resolve onFullfilment promise
199
+ logger.debug('postContent state', (_a = sessionState === null || sessionState === void 0 ? void 0 : sessionState.intent) === null || _a === void 0 ? void 0 : _a.state);
200
+ var isConfigOnCompleteAttached = typeof ((_b = this._config) === null || _b === void 0 ? void 0 : _b[botname].onComplete) === 'function';
201
+ var isApiOnCompleteAttached = typeof ((_c = this._botsCompleteCallback) === null || _c === void 0 ? void 0 : _c[botname]) === 'function';
202
+ // no onComplete callbacks added
203
+ if (!isConfigOnCompleteAttached && !isApiOnCompleteAttached)
204
+ return;
205
+ if (((_d = sessionState === null || sessionState === void 0 ? void 0 : sessionState.intent) === null || _d === void 0 ? void 0 : _d.state) === 'ReadyForFulfillment' ||
206
+ ((_e = sessionState === null || sessionState === void 0 ? void 0 : sessionState.intent) === null || _e === void 0 ? void 0 : _e.state) === 'Fulfilled') {
207
+ if (isApiOnCompleteAttached) {
208
+ setTimeout(function () { var _a; return (_a = _this._botsCompleteCallback) === null || _a === void 0 ? void 0 : _a[botname](null, data); }, 0);
209
+ }
210
+ if (isConfigOnCompleteAttached) {
211
+ setTimeout(function () { return _this._config[botname].onComplete(null, data); }, 0);
212
+ }
213
+ }
214
+ if (((_f = sessionState === null || sessionState === void 0 ? void 0 : sessionState.intent) === null || _f === void 0 ? void 0 : _f.state) === 'Failed') {
215
+ var error_2 = new Error('Bot conversation failed');
216
+ if (isApiOnCompleteAttached) {
217
+ setTimeout(function () { return _this._botsCompleteCallback[botname](error_2); }, 0);
218
+ }
219
+ if (isConfigOnCompleteAttached) {
220
+ setTimeout(function () { return _this._config[botname].onComplete(error_2); }, 0);
221
+ }
222
+ }
223
+ };
224
+ /**
225
+ * Format UtteranceCommandOutput's response
226
+ * decompress attributes
227
+ * update audioStream format
228
+ */
229
+ AWSLexV2Provider.prototype._formatUtteranceCommandOutput = function (data) {
230
+ return __awaiter(this, void 0, void 0, function () {
231
+ var response, _a, _b, _c;
232
+ return __generator(this, function (_d) {
233
+ switch (_d.label) {
234
+ case 0:
235
+ _a = [__assign({}, data)];
236
+ _b = {};
237
+ return [4 /*yield*/, commonUtils_1.unGzipBase64AsJson(data.messages)];
238
+ case 1:
239
+ _b.messages = _d.sent();
240
+ return [4 /*yield*/, commonUtils_1.unGzipBase64AsJson(data.sessionState)];
241
+ case 2:
242
+ _b.sessionState = _d.sent();
243
+ return [4 /*yield*/, commonUtils_1.unGzipBase64AsJson(data.interpretations)];
244
+ case 3:
245
+ _b.interpretations = _d.sent();
246
+ return [4 /*yield*/, commonUtils_1.unGzipBase64AsJson(data.requestAttributes)];
247
+ case 4:
248
+ _b.requestAttributes = _d.sent();
249
+ return [4 /*yield*/, commonUtils_1.unGzipBase64AsJson(data.inputTranscript)];
250
+ case 5:
251
+ _b.inputTranscript = _d.sent();
252
+ if (!data.audioStream) return [3 /*break*/, 7];
253
+ return [4 /*yield*/, utils_1.convert(data.audioStream)];
254
+ case 6:
255
+ _c = _d.sent();
256
+ return [3 /*break*/, 8];
257
+ case 7:
258
+ _c = undefined;
259
+ _d.label = 8;
260
+ case 8:
261
+ response = __assign.apply(void 0, _a.concat([(_b.audioStream = _c, _b)]));
262
+ return [2 /*return*/, response];
263
+ }
264
+ });
265
+ });
266
+ };
267
+ /**
268
+ * handle client's `RecognizeTextCommand`
269
+ * used for sending simple text message
270
+ */
271
+ AWSLexV2Provider.prototype._handleRecognizeTextCommand = function (botname, data, baseParams) {
272
+ return __awaiter(this, void 0, void 0, function () {
273
+ var params, recognizeTextCommand, data_1, err_1;
274
+ return __generator(this, function (_a) {
275
+ switch (_a.label) {
276
+ case 0:
277
+ logger.debug('postText to lex2', data);
278
+ params = __assign(__assign({}, baseParams), { text: data });
279
+ _a.label = 1;
280
+ case 1:
281
+ _a.trys.push([1, 3, , 4]);
282
+ recognizeTextCommand = new client_lex_runtime_v2_1.RecognizeTextCommand(params);
283
+ return [4 /*yield*/, this._lexRuntimeServiceV2Client.send(recognizeTextCommand)];
284
+ case 2:
285
+ data_1 = _a.sent();
286
+ this._reportBotStatus(data_1, botname);
287
+ return [2 /*return*/, data_1];
288
+ case 3:
289
+ err_1 = _a.sent();
290
+ return [2 /*return*/, Promise.reject(err_1)];
291
+ case 4: return [2 /*return*/];
292
+ }
293
+ });
294
+ });
295
+ };
296
+ /**
297
+ * handle client's `RecognizeUtteranceCommand`
298
+ * used for obj text or obj voice message
299
+ */
300
+ AWSLexV2Provider.prototype._handleRecognizeUtteranceCommand = function (botname, data, baseParams) {
301
+ return __awaiter(this, void 0, void 0, function () {
302
+ var content, messageType, params, inputStream, _a, recognizeUtteranceCommand, data_2, response, err_2;
303
+ return __generator(this, function (_b) {
304
+ switch (_b.label) {
305
+ case 0:
306
+ content = data.content, messageType = data.options.messageType;
307
+ logger.debug('postContent to lex2', data);
308
+ if (!(messageType === 'voice')) return [3 /*break*/, 4];
309
+ if (typeof content !== 'object') {
310
+ return [2 /*return*/, Promise.reject('invalid content type')];
311
+ }
312
+ if (!(content instanceof Uint8Array)) return [3 /*break*/, 1];
313
+ _a = content;
314
+ return [3 /*break*/, 3];
315
+ case 1: return [4 /*yield*/, utils_1.convert(content)];
316
+ case 2:
317
+ _a = _b.sent();
318
+ _b.label = 3;
319
+ case 3:
320
+ inputStream = _a;
321
+ params = __assign(__assign({}, baseParams), { requestContentType: 'audio/x-l16; sample-rate=16000; channel-count=1', inputStream: inputStream });
322
+ return [3 /*break*/, 5];
323
+ case 4:
324
+ // text input
325
+ if (typeof content !== 'string')
326
+ return [2 /*return*/, Promise.reject('invalid content type')];
327
+ params = __assign(__assign({}, baseParams), { requestContentType: 'text/plain; charset=utf-8', inputStream: content });
328
+ _b.label = 5;
329
+ case 5:
330
+ _b.trys.push([5, 8, , 9]);
331
+ recognizeUtteranceCommand = new client_lex_runtime_v2_1.RecognizeUtteranceCommand(params);
332
+ return [4 /*yield*/, this._lexRuntimeServiceV2Client.send(recognizeUtteranceCommand)];
333
+ case 6:
334
+ data_2 = _b.sent();
335
+ return [4 /*yield*/, this._formatUtteranceCommandOutput(data_2)];
336
+ case 7:
337
+ response = _b.sent();
338
+ this._reportBotStatus(response, botname);
339
+ return [2 /*return*/, response];
340
+ case 8:
341
+ err_2 = _b.sent();
342
+ return [2 /*return*/, Promise.reject(err_2)];
343
+ case 9: return [2 /*return*/];
344
+ }
345
+ });
346
+ });
347
+ };
348
+ return AWSLexV2Provider;
349
+ }(InteractionsProvider_1.AbstractInteractionsProvider));
350
+ exports.AWSLexV2Provider = AWSLexV2Provider;
351
+ //# sourceMappingURL=AWSLexV2Provider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AWSLexV2Provider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C;wBAE/C,MAAM,yBACF,UAAU,KACb,kBAAkB,EAAE,2BAA2B,EAC/C,WAAW,EAAE,OAAO,GACpB,CAAC;;;;wBAKI,yBAAyB,GAAG,IAAI,iDAAyB,CAAC,MAAM,CAAC,CAAC;wBAC3D,qBAAM,IAAI,CAAC,0BAA0B,CAAC,IAAI,CACtD,yBAAyB,CACzB,EAAA;;wBAFK,SAAO,SAEZ;wBAEgB,qBAAM,IAAI,CAAC,6BAA6B,CAAC,MAAI,CAAC,EAAA;;wBAAzD,QAAQ,GAAG,SAA8C;wBAC/D,IAAI,CAAC,gBAAgB,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;wBACzC,sBAAO,QAAQ,EAAC;;;wBAEhB,sBAAO,OAAO,CAAC,MAAM,CAAC,KAAG,CAAC,EAAC;;;;;KAE5B;IACF,uBAAC;AAAD,CAAC,AArRD,CAAsC,mDAA4B,GAqRjE;AArRY,4CAAgB"}
@@ -1,2 +1,3 @@
1
1
  export * from './AWSLexProvider';
2
+ export * from './AWSLexV2Provider';
2
3
  export * from './InteractionsProvider';
@@ -16,5 +16,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
16
16
  * and limitations under the License.
17
17
  */
18
18
  __export(require("./AWSLexProvider"));
19
+ __export(require("./AWSLexV2Provider"));
19
20
  __export(require("./InteractionsProvider"));
20
21
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/Providers/index.ts"],"names":[],"mappings":";;;;;AAAA;;;;;;;;;;;GAWG;AACH,sCAAiC;AACjC,4CAAuC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/Providers/index.ts"],"names":[],"mappings":";;;;;AAAA;;;;;;;;;;;GAWG;AACH,sCAAiC;AACjC,wCAAmC;AACnC,4CAAuC"}
package/lib/index.d.ts CHANGED
@@ -4,5 +4,7 @@ import { Interactions } from './Interactions';
4
4
  */
5
5
  export default Interactions;
6
6
  export * from './types';
7
+ export * from './Providers/InteractionsProvider';
7
8
  export * from './Providers/AWSLexProvider';
9
+ export * from './Providers/AWSLexV2Provider';
8
10
  export { Interactions };
package/lib/index.js CHANGED
@@ -21,5 +21,7 @@ exports.Interactions = Interactions_1.Interactions;
21
21
  * @deprecated use named import
22
22
  */
23
23
  exports.default = Interactions_1.Interactions;
24
+ __export(require("./Providers/InteractionsProvider"));
24
25
  __export(require("./Providers/AWSLexProvider"));
26
+ __export(require("./Providers/AWSLexV2Provider"));
25
27
  //# sourceMappingURL=index.js.map
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;AAAA;;;;;;;;;;;GAWG;AACH,+CAA8C;AAUrC,uBAVA,2BAAY,CAUA;AARrB;;GAEG;AACH,kBAAe,2BAAY,CAAC;AAG5B,gDAA2C"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;AAAA;;;;;;;;;;;GAWG;AACH,+CAA8C;AAYrC,uBAZA,2BAAY,CAYA;AAVrB;;GAEG;AACH,kBAAe,2BAAY,CAAC;AAG5B,sDAAiD;AACjD,gDAA2C;AAC3C,kDAA6C"}
@@ -1,6 +1,7 @@
1
+ import { InteractionsOptions } from './Interactions';
1
2
  import { InteractionsResponse } from './Response';
2
3
  export interface InteractionsProvider {
3
- configure(config: object): object;
4
+ configure(config: InteractionsOptions): InteractionsOptions;
4
5
  getCategory(): string;
5
6
  getProviderName(): string;
6
7
  sendMessage(botname: string, message: string | Object): Promise<object>;
@@ -0,0 +1,10 @@
1
+ export interface AWSLexProviderOption {
2
+ name: string;
3
+ alias: string;
4
+ region: string;
5
+ providerName?: string;
6
+ onComplete?(botname: string, callback: (err: any, confirmation: any) => void): void;
7
+ }
8
+ export interface AWSLexProviderOptions {
9
+ [key: string]: AWSLexProviderOption;
10
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=AWSLexProvider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AWSLexProvider.js","sourceRoot":"","sources":["../../../src/types/Providers/AWSLexProvider.ts"],"names":[],"mappings":""}
@@ -0,0 +1,12 @@
1
+ export interface AWSLexV2ProviderOption {
2
+ name: string;
3
+ botId: string;
4
+ aliasId: string;
5
+ localeId: string;
6
+ region: string;
7
+ providerName: string;
8
+ onComplete?(botname: string, callback: (err: any, confirmation: any) => void): void;
9
+ }
10
+ export interface AWSLexV2ProviderOptions {
11
+ [key: string]: AWSLexV2ProviderOption;
12
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=AWSLexV2Provider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AWSLexV2Provider.js","sourceRoot":"","sources":["../../../src/types/Providers/AWSLexV2Provider.ts"],"names":[],"mappings":""}
@@ -1,3 +1,5 @@
1
1
  export * from './Interactions';
2
2
  export * from './Provider';
3
+ export * from './Providers/AWSLexProvider';
4
+ export * from './Providers/AWSLexV2Provider';
3
5
  export * from './Response';
@@ -7,12 +7,12 @@ export declare class InteractionsClass {
7
7
  *
8
8
  * @param {InteractionsOptions} options - Configuration object for Interactions
9
9
  */
10
- constructor(options: InteractionsOptions);
10
+ constructor(options?: InteractionsOptions);
11
11
  getModuleName(): string;
12
12
  /**
13
13
  *
14
14
  * @param {InteractionsOptions} options - Configuration object for Interactions
15
- * @return {Object} - The current configuration
15
+ * @return {InteractionsOptions} - The current configuration
16
16
  */
17
17
  configure(options: InteractionsOptions): InteractionsOptions;
18
18
  addPluggable(pluggable: InteractionsProvider): void;