@aws-amplify/interactions 4.0.48 → 4.0.49-next.20
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.
- package/CHANGELOG.md +78 -0
- package/dist/aws-amplify-interactions.js +30438 -8762
- package/dist/aws-amplify-interactions.js.map +1 -1
- package/dist/aws-amplify-interactions.min.js +166 -5
- package/dist/aws-amplify-interactions.min.js.map +1 -1
- package/lib/Interactions.d.ts +2 -2
- package/lib/Interactions.js +41 -68
- package/lib/Interactions.js.map +1 -1
- package/lib/Providers/AWSLexProvider.d.ts +16 -3
- package/lib/Providers/AWSLexProvider.js +106 -119
- package/lib/Providers/AWSLexProvider.js.map +1 -1
- package/lib/Providers/AWSLexProviderHelper/commonUtils.d.ts +1 -0
- package/lib/Providers/AWSLexProviderHelper/commonUtils.js +39 -0
- package/lib/Providers/AWSLexProviderHelper/commonUtils.js.map +1 -0
- package/lib/Providers/AWSLexProviderHelper/utils.d.ts +3 -0
- package/lib/Providers/AWSLexProviderHelper/utils.js +48 -0
- package/lib/Providers/AWSLexProviderHelper/utils.js.map +1 -0
- package/lib/Providers/AWSLexProviderHelper/utils.native.d.ts +3 -0
- package/lib/Providers/AWSLexProviderHelper/utils.native.js +65 -0
- package/lib/Providers/AWSLexProviderHelper/utils.native.js.map +1 -0
- package/lib/Providers/AWSLexV2Provider.d.ts +58 -0
- package/lib/Providers/AWSLexV2Provider.js +292 -0
- package/lib/Providers/AWSLexV2Provider.js.map +1 -0
- package/lib/Providers/InteractionsProvider.js +3 -13
- package/lib/Providers/InteractionsProvider.js.map +1 -1
- package/lib/Providers/index.d.ts +1 -0
- package/lib/Providers/index.js +4 -5
- package/lib/Providers/index.js.map +1 -1
- package/lib/index.d.ts +2 -0
- package/lib/index.js +4 -4
- package/lib/index.js.map +1 -1
- package/lib/types/Provider.d.ts +2 -1
- package/lib/types/Providers/AWSLexProvider.d.ts +10 -0
- package/lib/types/Providers/AWSLexProvider.js +3 -0
- package/lib/types/Providers/AWSLexProvider.js.map +1 -0
- package/lib/types/Providers/AWSLexV2Provider.d.ts +12 -0
- package/lib/types/Providers/AWSLexV2Provider.js +3 -0
- package/lib/types/Providers/AWSLexV2Provider.js.map +1 -0
- package/lib/types/index.d.ts +2 -0
- package/lib-esm/Interactions.d.ts +2 -2
- package/lib-esm/Interactions.js +38 -65
- package/lib-esm/Interactions.js.map +1 -1
- package/lib-esm/Providers/AWSLexProvider.d.ts +16 -3
- package/lib-esm/Providers/AWSLexProvider.js +102 -115
- package/lib-esm/Providers/AWSLexProvider.js.map +1 -1
- package/lib-esm/Providers/AWSLexProviderHelper/commonUtils.d.ts +1 -0
- package/lib-esm/Providers/AWSLexProviderHelper/commonUtils.js +37 -0
- package/lib-esm/Providers/AWSLexProviderHelper/commonUtils.js.map +1 -0
- package/lib-esm/Providers/AWSLexProviderHelper/utils.d.ts +3 -0
- package/lib-esm/Providers/AWSLexProviderHelper/utils.js +46 -0
- package/lib-esm/Providers/AWSLexProviderHelper/utils.js.map +1 -0
- package/lib-esm/Providers/AWSLexProviderHelper/utils.native.d.ts +3 -0
- package/lib-esm/Providers/AWSLexProviderHelper/utils.native.js +63 -0
- package/lib-esm/Providers/AWSLexProviderHelper/utils.native.js.map +1 -0
- package/lib-esm/Providers/AWSLexV2Provider.d.ts +58 -0
- package/lib-esm/Providers/AWSLexV2Provider.js +290 -0
- package/lib-esm/Providers/AWSLexV2Provider.js.map +1 -0
- package/lib-esm/Providers/InteractionsProvider.js +1 -11
- package/lib-esm/Providers/InteractionsProvider.js.map +1 -1
- package/lib-esm/Providers/index.d.ts +1 -0
- package/lib-esm/Providers/index.js +1 -0
- package/lib-esm/Providers/index.js.map +1 -1
- package/lib-esm/index.d.ts +2 -0
- package/lib-esm/index.js +2 -0
- package/lib-esm/index.js.map +1 -1
- package/lib-esm/types/Provider.d.ts +2 -1
- package/lib-esm/types/Providers/AWSLexProvider.d.ts +10 -0
- package/lib-esm/types/Providers/AWSLexProvider.js +1 -0
- package/lib-esm/types/Providers/AWSLexProvider.js.map +1 -0
- package/lib-esm/types/Providers/AWSLexV2Provider.d.ts +12 -0
- package/lib-esm/types/Providers/AWSLexV2Provider.js +1 -0
- package/lib-esm/types/Providers/AWSLexV2Provider.js.map +1 -0
- package/lib-esm/types/index.d.ts +2 -0
- package/package.json +9 -4
- package/src/Interactions.ts +43 -21
- package/src/Providers/AWSLexProvider.ts +70 -23
- package/src/Providers/AWSLexProviderHelper/commonUtils.ts +27 -0
- package/src/Providers/AWSLexProviderHelper/utils.native.ts +56 -0
- package/src/Providers/AWSLexProviderHelper/utils.ts +39 -0
- package/src/Providers/AWSLexV2Provider.ts +343 -0
- package/src/Providers/index.ts +1 -0
- package/src/index.ts +2 -0
- package/src/types/Provider.ts +1 -1
- package/src/types/Providers/AWSLexProvider.ts +23 -0
- package/src/types/Providers/AWSLexV2Provider.ts +25 -0
- package/src/types/index.ts +2 -0
- package/lib/Providers/AWSLexProviderHelper/convert.d.ts +0 -3
- package/lib/Providers/AWSLexProviderHelper/convert.js +0 -13
- package/lib/Providers/AWSLexProviderHelper/convert.js.map +0 -1
- package/lib/Providers/AWSLexProviderHelper/convert.native.d.ts +0 -1
- package/lib/Providers/AWSLexProviderHelper/convert.native.js +0 -56
- package/lib/Providers/AWSLexProviderHelper/convert.native.js.map +0 -1
- package/lib-esm/Providers/AWSLexProviderHelper/convert.d.ts +0 -3
- package/lib-esm/Providers/AWSLexProviderHelper/convert.js +0 -11
- package/lib-esm/Providers/AWSLexProviderHelper/convert.js.map +0 -1
- package/lib-esm/Providers/AWSLexProviderHelper/convert.native.d.ts +0 -1
- package/lib-esm/Providers/AWSLexProviderHelper/convert.native.js +0 -54
- package/lib-esm/Providers/AWSLexProviderHelper/convert.native.js.map +0 -1
- package/src/Providers/AWSLexProviderHelper/convert.native.ts +0 -13
- package/src/Providers/AWSLexProviderHelper/convert.ts +0 -12
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2017-2022 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
|
|
5
|
+
* the License. A copy of the License is located at
|
|
6
|
+
*
|
|
7
|
+
* http://aws.amazon.com/apache2.0/
|
|
8
|
+
*
|
|
9
|
+
* or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
|
10
|
+
* CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
|
|
11
|
+
* and limitations under the License.
|
|
12
|
+
*/
|
|
13
|
+
import { __awaiter, __generator } from "tslib";
|
|
14
|
+
import { gunzip, strFromU8 } from 'fflate';
|
|
15
|
+
export var convert = function (stream) { return __awaiter(void 0, void 0, void 0, function () {
|
|
16
|
+
return __generator(this, function (_a) {
|
|
17
|
+
if (stream instanceof Blob || stream instanceof ReadableStream) {
|
|
18
|
+
return [2 /*return*/, new Response(stream)
|
|
19
|
+
.arrayBuffer()
|
|
20
|
+
.then(function (buffer) { return new Uint8Array(buffer); })];
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
return [2 /*return*/, Promise.reject('Invalid content type')];
|
|
24
|
+
}
|
|
25
|
+
return [2 /*return*/];
|
|
26
|
+
});
|
|
27
|
+
}); };
|
|
28
|
+
export var base64ToArrayBuffer = function (base64) {
|
|
29
|
+
return Uint8Array.from(window.atob(base64), function (c) { return c.charCodeAt(0); });
|
|
30
|
+
};
|
|
31
|
+
export var gzipDecompressToString = function (data) { return __awaiter(void 0, void 0, void 0, function () {
|
|
32
|
+
return __generator(this, function (_a) {
|
|
33
|
+
switch (_a.label) {
|
|
34
|
+
case 0: return [4 /*yield*/, new Promise(function (resolve, reject) {
|
|
35
|
+
gunzip(data, function (err, resp) {
|
|
36
|
+
if (err)
|
|
37
|
+
reject(err);
|
|
38
|
+
else
|
|
39
|
+
resolve(strFromU8(resp));
|
|
40
|
+
});
|
|
41
|
+
})];
|
|
42
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
}); };
|
|
46
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/Providers/AWSLexProviderHelper/utils.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;;AAEH,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AAE3C,MAAM,CAAC,IAAM,OAAO,GAAG,UAAO,MAAc;;QAC3C,IAAI,MAAM,YAAY,IAAI,IAAI,MAAM,YAAY,cAAc,EAAE;YAC/D,sBAAO,IAAI,QAAQ,CAAC,MAAM,CAAC;qBACzB,WAAW,EAAE;qBACb,IAAI,CAAC,UAAA,MAAM,IAAI,OAAA,IAAI,UAAU,CAAC,MAAM,CAAC,EAAtB,CAAsB,CAAC,EAAC;SACzC;aAAM;YACN,sBAAO,OAAO,CAAC,MAAM,CAAC,sBAAsB,CAAC,EAAC;SAC9C;;;KACD,CAAC;AAEF,MAAM,CAAC,IAAM,mBAAmB,GAAG,UAAC,MAAc;IACjD,OAAO,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,UAAA,CAAC,IAAI,OAAA,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,EAAf,CAAe,CAAC,CAAC;AACnE,CAAC,CAAC;AAEF,MAAM,CAAC,IAAM,sBAAsB,GAAG,UACrC,IAAgB;;;oBAET,qBAAM,IAAI,OAAO,CAAC,UAAC,OAAO,EAAE,MAAM;oBACxC,MAAM,CAAC,IAAI,EAAE,UAAC,GAAG,EAAE,IAAI;wBACtB,IAAI,GAAG;4BAAE,MAAM,CAAC,GAAG,CAAC,CAAC;;4BAChB,OAAO,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC;oBAC/B,CAAC,CAAC,CAAC;gBACJ,CAAC,CAAC,EAAA;oBALF,sBAAO,SAKL,EAAC;;;KACH,CAAC"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2017-2022 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
|
|
5
|
+
* the License. A copy of the License is located at
|
|
6
|
+
*
|
|
7
|
+
* http://aws.amazon.com/apache2.0/
|
|
8
|
+
*
|
|
9
|
+
* or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
|
10
|
+
* CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
|
|
11
|
+
* and limitations under the License.
|
|
12
|
+
*/
|
|
13
|
+
import { __awaiter, __generator } from "tslib";
|
|
14
|
+
import { decode } from 'base-64';
|
|
15
|
+
import { ungzip } from 'pako';
|
|
16
|
+
export var convert = function (stream) { return __awaiter(void 0, void 0, void 0, function () {
|
|
17
|
+
return __generator(this, function (_a) {
|
|
18
|
+
if (!(stream instanceof Blob)) {
|
|
19
|
+
return [2 /*return*/, Promise.reject('Invalid content type')];
|
|
20
|
+
}
|
|
21
|
+
return [2 /*return*/, new Promise(function (resolve, reject) { return __awaiter(void 0, void 0, void 0, function () {
|
|
22
|
+
var fileReaderInstance_1;
|
|
23
|
+
return __generator(this, function (_a) {
|
|
24
|
+
try {
|
|
25
|
+
fileReaderInstance_1 = new FileReader();
|
|
26
|
+
fileReaderInstance_1.readAsDataURL(stream);
|
|
27
|
+
fileReaderInstance_1.onload = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
28
|
+
var blobURL, base64Blob, decodedArrayBuffer;
|
|
29
|
+
return __generator(this, function (_a) {
|
|
30
|
+
blobURL = fileReaderInstance_1.result;
|
|
31
|
+
base64Blob = blobURL.split(/,(.*)/s)[1];
|
|
32
|
+
decodedArrayBuffer = base64ToArrayBuffer(base64Blob);
|
|
33
|
+
resolve(decodedArrayBuffer);
|
|
34
|
+
return [2 /*return*/];
|
|
35
|
+
});
|
|
36
|
+
}); };
|
|
37
|
+
}
|
|
38
|
+
catch (error) {
|
|
39
|
+
reject('unable to convert blob to arrayBuffer: ' + error);
|
|
40
|
+
}
|
|
41
|
+
return [2 /*return*/];
|
|
42
|
+
});
|
|
43
|
+
}); })];
|
|
44
|
+
});
|
|
45
|
+
}); };
|
|
46
|
+
export var base64ToArrayBuffer = function (base64) {
|
|
47
|
+
var binaryString = decode(base64);
|
|
48
|
+
return Uint8Array.from(binaryString, function (c) { return c.charCodeAt(0); });
|
|
49
|
+
};
|
|
50
|
+
export var gzipDecompressToString = function (data) { return __awaiter(void 0, void 0, void 0, function () {
|
|
51
|
+
return __generator(this, function (_a) {
|
|
52
|
+
return [2 /*return*/, new Promise(function (resolve, reject) {
|
|
53
|
+
try {
|
|
54
|
+
var result = ungzip(data, { to: 'string' });
|
|
55
|
+
resolve(result);
|
|
56
|
+
}
|
|
57
|
+
catch (error) {
|
|
58
|
+
reject('unable to decompress' + error);
|
|
59
|
+
}
|
|
60
|
+
})];
|
|
61
|
+
});
|
|
62
|
+
}); };
|
|
63
|
+
//# 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,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAE9B,MAAM,CAAC,IAAM,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;;;oBAC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, 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,290 @@
|
|
|
1
|
+
import { __assign, __awaiter, __extends, __generator } from "tslib";
|
|
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
|
+
import { AbstractInteractionsProvider } from './InteractionsProvider';
|
|
15
|
+
import { LexRuntimeV2Client, RecognizeTextCommand, RecognizeUtteranceCommand, } from '@aws-sdk/client-lex-runtime-v2';
|
|
16
|
+
import { ConsoleLogger as Logger, Credentials, getAmplifyUserAgent, } from '@aws-amplify/core';
|
|
17
|
+
import { convert } from './AWSLexProviderHelper/utils';
|
|
18
|
+
import { unGzipBase64AsJson } from './AWSLexProviderHelper/commonUtils';
|
|
19
|
+
var logger = new Logger('AWSLexV2Provider');
|
|
20
|
+
var AWSLexV2Provider = /** @class */ (function (_super) {
|
|
21
|
+
__extends(AWSLexV2Provider, _super);
|
|
22
|
+
/**
|
|
23
|
+
* Initialize Interactions with AWS configurations
|
|
24
|
+
* @param {InteractionsOptions} options - Configuration object for Interactions
|
|
25
|
+
*/
|
|
26
|
+
function AWSLexV2Provider(options) {
|
|
27
|
+
if (options === void 0) { options = {}; }
|
|
28
|
+
var _this = _super.call(this, options) || this;
|
|
29
|
+
_this._botsCompleteCallback = {};
|
|
30
|
+
return _this;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* get provider name of the plugin
|
|
34
|
+
* @returns {string} name of the provider
|
|
35
|
+
*/
|
|
36
|
+
AWSLexV2Provider.prototype.getProviderName = function () {
|
|
37
|
+
return 'AWSLexV2Provider';
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* Configure Interactions part with aws configuration
|
|
41
|
+
* @param {AWSLexV2ProviderOptions} config - Configuration of the Interactions
|
|
42
|
+
* @return {AWSLexV2ProviderOptions} - Current configuration
|
|
43
|
+
*/
|
|
44
|
+
AWSLexV2Provider.prototype.configure = function (config) {
|
|
45
|
+
if (config === void 0) { config = {}; }
|
|
46
|
+
var propertiesToTest = [
|
|
47
|
+
'name',
|
|
48
|
+
'botId',
|
|
49
|
+
'aliasId',
|
|
50
|
+
'localeId',
|
|
51
|
+
'providerName',
|
|
52
|
+
'region',
|
|
53
|
+
];
|
|
54
|
+
Object.keys(config).forEach(function (botKey) {
|
|
55
|
+
var botConfig = config[botKey];
|
|
56
|
+
// is bot config correct
|
|
57
|
+
if (!propertiesToTest.every(function (x) { return x in botConfig; })) {
|
|
58
|
+
throw new Error('invalid bot configuration');
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
return _super.prototype.configure.call(this, config);
|
|
62
|
+
};
|
|
63
|
+
/**
|
|
64
|
+
* Send a message to a bot
|
|
65
|
+
* @async
|
|
66
|
+
* @param {string} botname - Bot name to send the message
|
|
67
|
+
* @param {string | InteractionsMessage} message - message to send to the bot
|
|
68
|
+
* @return {Promise<InteractionsResponse>} A promise resolves to the response from the bot
|
|
69
|
+
*/
|
|
70
|
+
AWSLexV2Provider.prototype.sendMessage = function (botname, message) {
|
|
71
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
72
|
+
var credentials, error_1, response, reqBaseParams;
|
|
73
|
+
return __generator(this, function (_a) {
|
|
74
|
+
switch (_a.label) {
|
|
75
|
+
case 0:
|
|
76
|
+
// check if bot exists
|
|
77
|
+
if (!this._config[botname]) {
|
|
78
|
+
return [2 /*return*/, Promise.reject('Bot ' + botname + ' does not exist')];
|
|
79
|
+
}
|
|
80
|
+
_a.label = 1;
|
|
81
|
+
case 1:
|
|
82
|
+
_a.trys.push([1, 3, , 4]);
|
|
83
|
+
return [4 /*yield*/, Credentials.get()];
|
|
84
|
+
case 2:
|
|
85
|
+
credentials = _a.sent();
|
|
86
|
+
return [3 /*break*/, 4];
|
|
87
|
+
case 3:
|
|
88
|
+
error_1 = _a.sent();
|
|
89
|
+
return [2 /*return*/, Promise.reject('No credentials')];
|
|
90
|
+
case 4:
|
|
91
|
+
this._lexRuntimeServiceV2Client = new LexRuntimeV2Client({
|
|
92
|
+
region: this._config[botname].region,
|
|
93
|
+
credentials: credentials,
|
|
94
|
+
customUserAgent: getAmplifyUserAgent(),
|
|
95
|
+
});
|
|
96
|
+
reqBaseParams = {
|
|
97
|
+
botAliasId: this._config[botname].aliasId,
|
|
98
|
+
botId: this._config[botname].botId,
|
|
99
|
+
localeId: this._config[botname].localeId,
|
|
100
|
+
sessionId: credentials.identityId,
|
|
101
|
+
};
|
|
102
|
+
if (!(typeof message === 'string')) return [3 /*break*/, 6];
|
|
103
|
+
return [4 /*yield*/, this._handleRecognizeTextCommand(botname, message, reqBaseParams)];
|
|
104
|
+
case 5:
|
|
105
|
+
response = _a.sent();
|
|
106
|
+
return [3 /*break*/, 8];
|
|
107
|
+
case 6: return [4 /*yield*/, this._handleRecognizeUtteranceCommand(botname, message, reqBaseParams)];
|
|
108
|
+
case 7:
|
|
109
|
+
response = _a.sent();
|
|
110
|
+
_a.label = 8;
|
|
111
|
+
case 8: return [2 /*return*/, response];
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
});
|
|
115
|
+
};
|
|
116
|
+
/**
|
|
117
|
+
* Attach a onComplete callback function to a bot.
|
|
118
|
+
* The callback is called once the bot's intent is fulfilled
|
|
119
|
+
* @param {string} botname - Bot name to attach the onComplete callback
|
|
120
|
+
* @param {(err: Error | null, confirmation: InteractionsResponse) => void} callback - called when Intent Fulfilled
|
|
121
|
+
*/
|
|
122
|
+
AWSLexV2Provider.prototype.onComplete = function (botname, callback) {
|
|
123
|
+
// does bot exist
|
|
124
|
+
if (!this._config[botname]) {
|
|
125
|
+
throw new Error('Bot ' + botname + ' does not exist');
|
|
126
|
+
}
|
|
127
|
+
this._botsCompleteCallback[botname] = callback;
|
|
128
|
+
};
|
|
129
|
+
/**
|
|
130
|
+
* @private
|
|
131
|
+
* call onComplete callback for a bot if configured
|
|
132
|
+
*/
|
|
133
|
+
AWSLexV2Provider.prototype._reportBotStatus = function (data, botname) {
|
|
134
|
+
var _this = this;
|
|
135
|
+
var _a, _b, _c, _d, _e, _f;
|
|
136
|
+
var sessionState = data === null || data === void 0 ? void 0 : data.sessionState;
|
|
137
|
+
// Check if state is fulfilled to resolve onFullfilment promise
|
|
138
|
+
logger.debug('postContent state', (_a = sessionState === null || sessionState === void 0 ? void 0 : sessionState.intent) === null || _a === void 0 ? void 0 : _a.state);
|
|
139
|
+
var isConfigOnCompleteAttached = typeof ((_b = this._config) === null || _b === void 0 ? void 0 : _b[botname].onComplete) === 'function';
|
|
140
|
+
var isApiOnCompleteAttached = typeof ((_c = this._botsCompleteCallback) === null || _c === void 0 ? void 0 : _c[botname]) === 'function';
|
|
141
|
+
// no onComplete callbacks added
|
|
142
|
+
if (!isConfigOnCompleteAttached && !isApiOnCompleteAttached)
|
|
143
|
+
return;
|
|
144
|
+
if (((_d = sessionState === null || sessionState === void 0 ? void 0 : sessionState.intent) === null || _d === void 0 ? void 0 : _d.state) === 'ReadyForFulfillment' ||
|
|
145
|
+
((_e = sessionState === null || sessionState === void 0 ? void 0 : sessionState.intent) === null || _e === void 0 ? void 0 : _e.state) === 'Fulfilled') {
|
|
146
|
+
if (isApiOnCompleteAttached) {
|
|
147
|
+
setTimeout(function () { var _a; return (_a = _this._botsCompleteCallback) === null || _a === void 0 ? void 0 : _a[botname](null, data); }, 0);
|
|
148
|
+
}
|
|
149
|
+
if (isConfigOnCompleteAttached) {
|
|
150
|
+
setTimeout(function () { return _this._config[botname].onComplete(null, data); }, 0);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
if (((_f = sessionState === null || sessionState === void 0 ? void 0 : sessionState.intent) === null || _f === void 0 ? void 0 : _f.state) === 'Failed') {
|
|
154
|
+
var error_2 = new Error('Bot conversation failed');
|
|
155
|
+
if (isApiOnCompleteAttached) {
|
|
156
|
+
setTimeout(function () { return _this._botsCompleteCallback[botname](error_2); }, 0);
|
|
157
|
+
}
|
|
158
|
+
if (isConfigOnCompleteAttached) {
|
|
159
|
+
setTimeout(function () { return _this._config[botname].onComplete(error_2); }, 0);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
};
|
|
163
|
+
/**
|
|
164
|
+
* Format UtteranceCommandOutput's response
|
|
165
|
+
* decompress attributes
|
|
166
|
+
* update audioStream format
|
|
167
|
+
*/
|
|
168
|
+
AWSLexV2Provider.prototype._formatUtteranceCommandOutput = function (data) {
|
|
169
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
170
|
+
var response, _a, _b, _c;
|
|
171
|
+
return __generator(this, function (_d) {
|
|
172
|
+
switch (_d.label) {
|
|
173
|
+
case 0:
|
|
174
|
+
_a = [__assign({}, data)];
|
|
175
|
+
_b = {};
|
|
176
|
+
return [4 /*yield*/, unGzipBase64AsJson(data.messages)];
|
|
177
|
+
case 1:
|
|
178
|
+
_b.messages = _d.sent();
|
|
179
|
+
return [4 /*yield*/, unGzipBase64AsJson(data.sessionState)];
|
|
180
|
+
case 2:
|
|
181
|
+
_b.sessionState = _d.sent();
|
|
182
|
+
return [4 /*yield*/, unGzipBase64AsJson(data.interpretations)];
|
|
183
|
+
case 3:
|
|
184
|
+
_b.interpretations = _d.sent();
|
|
185
|
+
return [4 /*yield*/, unGzipBase64AsJson(data.requestAttributes)];
|
|
186
|
+
case 4:
|
|
187
|
+
_b.requestAttributes = _d.sent();
|
|
188
|
+
return [4 /*yield*/, unGzipBase64AsJson(data.inputTranscript)];
|
|
189
|
+
case 5:
|
|
190
|
+
_b.inputTranscript = _d.sent();
|
|
191
|
+
if (!data.audioStream) return [3 /*break*/, 7];
|
|
192
|
+
return [4 /*yield*/, convert(data.audioStream)];
|
|
193
|
+
case 6:
|
|
194
|
+
_c = _d.sent();
|
|
195
|
+
return [3 /*break*/, 8];
|
|
196
|
+
case 7:
|
|
197
|
+
_c = undefined;
|
|
198
|
+
_d.label = 8;
|
|
199
|
+
case 8:
|
|
200
|
+
response = __assign.apply(void 0, _a.concat([(_b.audioStream = _c, _b)]));
|
|
201
|
+
return [2 /*return*/, response];
|
|
202
|
+
}
|
|
203
|
+
});
|
|
204
|
+
});
|
|
205
|
+
};
|
|
206
|
+
/**
|
|
207
|
+
* handle client's `RecognizeTextCommand`
|
|
208
|
+
* used for sending simple text message
|
|
209
|
+
*/
|
|
210
|
+
AWSLexV2Provider.prototype._handleRecognizeTextCommand = function (botname, data, baseParams) {
|
|
211
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
212
|
+
var params, recognizeTextCommand, data_1, err_1;
|
|
213
|
+
return __generator(this, function (_a) {
|
|
214
|
+
switch (_a.label) {
|
|
215
|
+
case 0:
|
|
216
|
+
logger.debug('postText to lex2', data);
|
|
217
|
+
params = __assign(__assign({}, baseParams), { text: data });
|
|
218
|
+
_a.label = 1;
|
|
219
|
+
case 1:
|
|
220
|
+
_a.trys.push([1, 3, , 4]);
|
|
221
|
+
recognizeTextCommand = new RecognizeTextCommand(params);
|
|
222
|
+
return [4 /*yield*/, this._lexRuntimeServiceV2Client.send(recognizeTextCommand)];
|
|
223
|
+
case 2:
|
|
224
|
+
data_1 = _a.sent();
|
|
225
|
+
this._reportBotStatus(data_1, botname);
|
|
226
|
+
return [2 /*return*/, data_1];
|
|
227
|
+
case 3:
|
|
228
|
+
err_1 = _a.sent();
|
|
229
|
+
return [2 /*return*/, Promise.reject(err_1)];
|
|
230
|
+
case 4: return [2 /*return*/];
|
|
231
|
+
}
|
|
232
|
+
});
|
|
233
|
+
});
|
|
234
|
+
};
|
|
235
|
+
/**
|
|
236
|
+
* handle client's `RecognizeUtteranceCommand`
|
|
237
|
+
* used for obj text or obj voice message
|
|
238
|
+
*/
|
|
239
|
+
AWSLexV2Provider.prototype._handleRecognizeUtteranceCommand = function (botname, data, baseParams) {
|
|
240
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
241
|
+
var content, messageType, params, inputStream, _a, recognizeUtteranceCommand, data_2, response, err_2;
|
|
242
|
+
return __generator(this, function (_b) {
|
|
243
|
+
switch (_b.label) {
|
|
244
|
+
case 0:
|
|
245
|
+
content = data.content, messageType = data.options.messageType;
|
|
246
|
+
logger.debug('postContent to lex2', data);
|
|
247
|
+
if (!(messageType === 'voice')) return [3 /*break*/, 4];
|
|
248
|
+
if (typeof content !== 'object') {
|
|
249
|
+
return [2 /*return*/, Promise.reject('invalid content type')];
|
|
250
|
+
}
|
|
251
|
+
if (!(content instanceof Uint8Array)) return [3 /*break*/, 1];
|
|
252
|
+
_a = content;
|
|
253
|
+
return [3 /*break*/, 3];
|
|
254
|
+
case 1: return [4 /*yield*/, convert(content)];
|
|
255
|
+
case 2:
|
|
256
|
+
_a = _b.sent();
|
|
257
|
+
_b.label = 3;
|
|
258
|
+
case 3:
|
|
259
|
+
inputStream = _a;
|
|
260
|
+
params = __assign(__assign({}, baseParams), { requestContentType: 'audio/x-l16; sample-rate=16000; channel-count=1', inputStream: inputStream });
|
|
261
|
+
return [3 /*break*/, 5];
|
|
262
|
+
case 4:
|
|
263
|
+
// text input
|
|
264
|
+
if (typeof content !== 'string')
|
|
265
|
+
return [2 /*return*/, Promise.reject('invalid content type')];
|
|
266
|
+
params = __assign(__assign({}, baseParams), { requestContentType: 'text/plain; charset=utf-8', inputStream: content });
|
|
267
|
+
_b.label = 5;
|
|
268
|
+
case 5:
|
|
269
|
+
_b.trys.push([5, 8, , 9]);
|
|
270
|
+
recognizeUtteranceCommand = new RecognizeUtteranceCommand(params);
|
|
271
|
+
return [4 /*yield*/, this._lexRuntimeServiceV2Client.send(recognizeUtteranceCommand)];
|
|
272
|
+
case 6:
|
|
273
|
+
data_2 = _b.sent();
|
|
274
|
+
return [4 /*yield*/, this._formatUtteranceCommandOutput(data_2)];
|
|
275
|
+
case 7:
|
|
276
|
+
response = _b.sent();
|
|
277
|
+
this._reportBotStatus(response, botname);
|
|
278
|
+
return [2 /*return*/, response];
|
|
279
|
+
case 8:
|
|
280
|
+
err_2 = _b.sent();
|
|
281
|
+
return [2 /*return*/, Promise.reject(err_2)];
|
|
282
|
+
case 9: return [2 /*return*/];
|
|
283
|
+
}
|
|
284
|
+
});
|
|
285
|
+
});
|
|
286
|
+
};
|
|
287
|
+
return AWSLexV2Provider;
|
|
288
|
+
}(AbstractInteractionsProvider));
|
|
289
|
+
export { AWSLexV2Provider };
|
|
290
|
+
//# sourceMappingURL=AWSLexV2Provider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AWSLexV2Provider.js","sourceRoot":"","sources":["../../src/Providers/AWSLexV2Provider.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EAAE,4BAA4B,EAAE,MAAM,wBAAwB,CAAC;AAOtE,OAAO,EACN,kBAAkB,EAClB,oBAAoB,EAGpB,yBAAyB,GAGzB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EACN,aAAa,IAAI,MAAM,EACvB,W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pB,CAAC;;;;wBAKI,yBAAyB,GAAG,IAAI,yBAAyB,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,4BAA4B,GAqRjE"}
|
|
@@ -10,17 +10,7 @@
|
|
|
10
10
|
* CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
|
|
11
11
|
* and limitations under the License.
|
|
12
12
|
*/
|
|
13
|
-
|
|
14
|
-
__assign = Object.assign || function(t) {
|
|
15
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
16
|
-
s = arguments[i];
|
|
17
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
18
|
-
t[p] = s[p];
|
|
19
|
-
}
|
|
20
|
-
return t;
|
|
21
|
-
};
|
|
22
|
-
return __assign.apply(this, arguments);
|
|
23
|
-
};
|
|
13
|
+
import { __assign } from "tslib";
|
|
24
14
|
import { ConsoleLogger as Logger } from '@aws-amplify/core';
|
|
25
15
|
var logger = new Logger('AbstractInteractionsProvider');
|
|
26
16
|
var AbstractInteractionsProvider = /** @class */ (function () {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InteractionsProvider.js","sourceRoot":"","sources":["../../src/Providers/InteractionsProvider.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG
|
|
1
|
+
{"version":3,"file":"InteractionsProvider.js","sourceRoot":"","sources":["../../src/Providers/InteractionsProvider.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;;AAQH,OAAO,EAAE,aAAa,IAAI,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAE5D,IAAM,MAAM,GAAG,IAAI,MAAM,CAAC,8BAA8B,CAAC,CAAC;AAE1D;IAIC,sCAAY,OAAiC;QAAjC,wBAAA,EAAA,YAAiC;QAC5C,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACxB,CAAC;IAED,gDAAS,GAAT,UAAU,MAAgC;QAAhC,uBAAA,EAAA,WAAgC;QACzC,IAAI,CAAC,OAAO,yBAAQ,IAAI,CAAC,OAAO,GAAK,MAAM,CAAE,CAAC;QAE9C,MAAM,CAAC,KAAK,CAAC,eAAa,IAAI,CAAC,eAAe,EAAI,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;QAElE,OAAO,IAAI,CAAC,OAAO,CAAC;IACrB,CAAC;IAED,kDAAW,GAAX;QACC,OAAO,cAAc,CAAC;IACvB,CAAC;IAID,sBAAc,iDAAO;aAArB;YACC,oBAAY,IAAI,CAAC,OAAO,EAAG;QAC5B,CAAC;;;OAAA;IAWF,mCAAC;AAAD,CAAC,AAnCD,IAmCC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/Providers/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,cAAc,kBAAkB,CAAC;AACjC,cAAc,wBAAwB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/Providers/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,wBAAwB,CAAC"}
|
package/lib-esm/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-esm/index.js
CHANGED
|
@@ -15,6 +15,8 @@ import { Interactions } from './Interactions';
|
|
|
15
15
|
* @deprecated use named import
|
|
16
16
|
*/
|
|
17
17
|
export default Interactions;
|
|
18
|
+
export * from './Providers/InteractionsProvider';
|
|
18
19
|
export * from './Providers/AWSLexProvider';
|
|
20
|
+
export * from './Providers/AWSLexV2Provider';
|
|
19
21
|
export { Interactions };
|
|
20
22
|
//# sourceMappingURL=index.js.map
|
package/lib-esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C;;GAEG;AACH,eAAe,YAAY,CAAC;AAG5B,cAAc,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C;;GAEG;AACH,eAAe,YAAY,CAAC;AAG5B,cAAc,kCAAkC,CAAC;AACjD,cAAc,4BAA4B,CAAC;AAC3C,cAAc,8BAA8B,CAAC;AAE7C,OAAO,EAAE,YAAY,EAAE,CAAC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { InteractionsOptions } from './Interactions';
|
|
1
2
|
import { InteractionsResponse } from './Response';
|
|
2
3
|
export interface InteractionsProvider {
|
|
3
|
-
configure(config:
|
|
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 @@
|
|
|
1
|
+
//# 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 @@
|
|
|
1
|
+
//# sourceMappingURL=AWSLexV2Provider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AWSLexV2Provider.js","sourceRoot":"","sources":["../../../src/types/Providers/AWSLexV2Provider.ts"],"names":[],"mappings":""}
|
package/lib-esm/types/index.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aws-amplify/interactions",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.49-next.20+072846a9f",
|
|
4
4
|
"description": "Interactions category of aws-amplify",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"module": "./lib-esm/index.js",
|
|
@@ -41,8 +41,13 @@
|
|
|
41
41
|
},
|
|
42
42
|
"homepage": "https://aws-amplify.github.io/",
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@aws-amplify/core": "4.6.
|
|
45
|
-
"@aws-sdk/client-lex-runtime-service": "3.6.1"
|
|
44
|
+
"@aws-amplify/core": "4.6.2-next.20+072846a9f",
|
|
45
|
+
"@aws-sdk/client-lex-runtime-service": "3.6.1",
|
|
46
|
+
"@aws-sdk/client-lex-runtime-v2": "3.171.0",
|
|
47
|
+
"base-64": "1.0.0",
|
|
48
|
+
"fflate": "0.7.3",
|
|
49
|
+
"pako": "2.0.4",
|
|
50
|
+
"tslib": "^2.0.0"
|
|
46
51
|
},
|
|
47
52
|
"jest": {
|
|
48
53
|
"globals": {
|
|
@@ -88,5 +93,5 @@
|
|
|
88
93
|
"lib-esm"
|
|
89
94
|
]
|
|
90
95
|
},
|
|
91
|
-
"gitHead": "
|
|
96
|
+
"gitHead": "072846a9f0bd91f145e58aca2fca91a6478286b0"
|
|
92
97
|
}
|