@aws-amplify/interactions 5.2.12-unstable.7762f1a.0 → 6.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -0
- package/lex-v1/package.json +7 -0
- package/lex-v2/package.json +7 -0
- package/lib/errors/InteractionsError.d.ts +4 -0
- package/lib/errors/InteractionsError.js +16 -0
- package/lib/errors/assertValidationError.d.ts +2 -0
- package/lib/errors/assertValidationError.js +18 -0
- package/lib/errors/index.d.ts +2 -0
- package/lib/errors/index.js +9 -0
- package/lib/errors/validation.d.ts +5 -0
- package/lib/errors/validation.js +14 -0
- package/lib/index.d.ts +2 -5
- package/lib/index.js +3 -9
- package/lib/lex-v1/AWSLexProvider.d.ts +20 -0
- package/lib/lex-v1/AWSLexProvider.js +119 -0
- package/lib/lex-v1/apis/index.d.ts +2 -0
- package/lib/lex-v1/apis/index.js +9 -0
- package/lib/lex-v1/apis/onComplete.d.ts +2 -0
- package/lib/lex-v1/apis/onComplete.js +15 -0
- package/lib/lex-v1/apis/send.d.ts +2 -0
- package/lib/lex-v1/apis/send.js +15 -0
- package/lib/lex-v1/index.d.ts +6 -0
- package/lib/lex-v1/index.js +13 -0
- package/lib/lex-v1/types/AWSLexProviderOption.d.ts +11 -0
- package/lib/{types/Response.js → lex-v1/types/AWSLexProviderOption.js} +0 -1
- package/lib/lex-v1/types/index.d.ts +3 -0
- package/lib/lex-v1/types/index.js +4 -0
- package/lib/lex-v1/types/inputs.d.ts +9 -0
- package/lib/lex-v1/types/inputs.js +4 -0
- package/lib/lex-v1/types/outputs.d.ts +5 -0
- package/lib/lex-v1/types/outputs.js +4 -0
- package/lib/lex-v1/utils/index.d.ts +1 -0
- package/lib/lex-v1/utils/index.js +7 -0
- package/lib/lex-v1/utils/resolveBotConfig.d.ts +2 -0
- package/lib/lex-v1/utils/resolveBotConfig.js +13 -0
- package/lib/lex-v2/AWSLexV2Provider.d.ts +52 -0
- package/lib/lex-v2/AWSLexV2Provider.js +166 -0
- package/lib/lex-v2/apis/index.d.ts +2 -0
- package/lib/lex-v2/apis/index.js +9 -0
- package/lib/lex-v2/apis/onComplete.d.ts +2 -0
- package/lib/lex-v2/apis/onComplete.js +15 -0
- package/lib/lex-v2/apis/send.d.ts +2 -0
- package/lib/lex-v2/apis/send.js +15 -0
- package/lib/lex-v2/index.d.ts +3 -0
- package/lib/lex-v2/index.js +10 -0
- package/lib/lex-v2/types/AWSLexV2ProviderOption.d.ts +13 -0
- package/lib/lex-v2/types/AWSLexV2ProviderOption.js +4 -0
- package/lib/lex-v2/types/index.d.ts +3 -0
- package/lib/lex-v2/types/index.js +4 -0
- package/lib/lex-v2/types/inputs.d.ts +9 -0
- package/lib/lex-v2/types/inputs.js +4 -0
- package/lib/lex-v2/types/outputs.d.ts +5 -0
- package/lib/lex-v2/types/outputs.js +4 -0
- package/lib/lex-v2/utils/index.d.ts +1 -0
- package/lib/lex-v2/utils/index.js +7 -0
- package/lib/lex-v2/utils/resolveBotConfig.d.ts +2 -0
- package/lib/lex-v2/utils/resolveBotConfig.js +13 -0
- package/lib/tsconfig.tsbuildinfo +1 -0
- package/lib/types/Interactions.d.ts +7 -6
- package/lib/types/Interactions.js +2 -1
- package/lib/types/index.d.ts +2 -5
- package/lib/types/index.js +2 -1
- package/lib/types/inputs.d.ts +9 -0
- package/lib/types/inputs.js +4 -0
- package/lib/types/outputs.d.ts +2 -0
- package/lib/types/outputs.js +4 -0
- package/lib/utils/commonUtils.d.ts +1 -0
- package/lib/utils/commonUtils.js +19 -0
- package/lib/utils/index.d.ts +2 -0
- package/lib/utils/index.js +11 -0
- package/lib/utils/utils.js +32 -0
- package/lib/utils/utils.native.js +45 -0
- package/lib-esm/errors/InteractionsError.d.ts +4 -0
- package/lib-esm/errors/InteractionsError.js +12 -0
- package/lib-esm/errors/assertValidationError.d.ts +2 -0
- package/lib-esm/errors/assertValidationError.js +14 -0
- package/lib-esm/errors/index.d.ts +2 -0
- package/lib-esm/errors/index.js +4 -0
- package/lib-esm/errors/validation.d.ts +5 -0
- package/lib-esm/errors/validation.js +11 -0
- package/lib-esm/index.d.ts +2 -5
- package/lib-esm/index.js +1 -5
- package/lib-esm/lex-v1/AWSLexProvider.d.ts +20 -0
- package/lib-esm/lex-v1/AWSLexProvider.js +116 -0
- package/lib-esm/lex-v1/apis/index.d.ts +2 -0
- package/lib-esm/lex-v1/apis/index.js +4 -0
- package/lib-esm/lex-v1/apis/onComplete.d.ts +2 -0
- package/lib-esm/lex-v1/apis/onComplete.js +11 -0
- package/lib-esm/lex-v1/apis/send.d.ts +2 -0
- package/lib-esm/lex-v1/apis/send.js +11 -0
- package/lib-esm/lex-v1/index.d.ts +6 -0
- package/lib-esm/lex-v1/index.js +10 -0
- package/lib-esm/lex-v1/types/AWSLexProviderOption.d.ts +11 -0
- package/lib-esm/{types/Response.js → lex-v1/types/AWSLexProviderOption.js} +1 -1
- package/lib-esm/lex-v1/types/index.d.ts +3 -0
- package/lib-esm/lex-v1/types/index.js +3 -0
- package/lib-esm/lex-v1/types/inputs.d.ts +9 -0
- package/lib-esm/lex-v1/types/inputs.js +3 -0
- package/lib-esm/lex-v1/types/outputs.d.ts +5 -0
- package/lib-esm/lex-v1/types/outputs.js +3 -0
- package/lib-esm/lex-v1/utils/index.d.ts +1 -0
- package/lib-esm/lex-v1/utils/index.js +3 -0
- package/lib-esm/lex-v1/utils/resolveBotConfig.d.ts +2 -0
- package/lib-esm/lex-v1/utils/resolveBotConfig.js +9 -0
- package/lib-esm/lex-v2/AWSLexV2Provider.d.ts +52 -0
- package/lib-esm/lex-v2/AWSLexV2Provider.js +163 -0
- package/lib-esm/lex-v2/apis/index.d.ts +2 -0
- package/lib-esm/lex-v2/apis/index.js +4 -0
- package/lib-esm/lex-v2/apis/onComplete.d.ts +2 -0
- package/lib-esm/lex-v2/apis/onComplete.js +11 -0
- package/lib-esm/lex-v2/apis/send.d.ts +2 -0
- package/lib-esm/lex-v2/apis/send.js +11 -0
- package/lib-esm/lex-v2/index.d.ts +3 -0
- package/lib-esm/lex-v2/index.js +7 -0
- package/lib-esm/lex-v2/types/AWSLexV2ProviderOption.d.ts +13 -0
- package/lib-esm/lex-v2/types/AWSLexV2ProviderOption.js +3 -0
- package/lib-esm/lex-v2/types/index.d.ts +3 -0
- package/lib-esm/lex-v2/types/index.js +3 -0
- package/lib-esm/lex-v2/types/inputs.d.ts +9 -0
- package/lib-esm/lex-v2/types/inputs.js +3 -0
- package/lib-esm/lex-v2/types/outputs.d.ts +5 -0
- package/lib-esm/lex-v2/types/outputs.js +3 -0
- package/lib-esm/lex-v2/utils/index.d.ts +1 -0
- package/lib-esm/lex-v2/utils/index.js +3 -0
- package/lib-esm/lex-v2/utils/resolveBotConfig.d.ts +2 -0
- package/lib-esm/lex-v2/utils/resolveBotConfig.js +9 -0
- package/lib-esm/tsconfig.tsbuildinfo +1 -0
- package/lib-esm/types/Interactions.d.ts +7 -6
- package/lib-esm/types/Interactions.js +3 -1
- package/lib-esm/types/index.d.ts +2 -5
- package/lib-esm/types/index.js +3 -1
- package/lib-esm/types/inputs.d.ts +9 -0
- package/lib-esm/types/inputs.js +3 -0
- package/lib-esm/types/outputs.d.ts +2 -0
- package/lib-esm/types/outputs.js +3 -0
- package/lib-esm/utils/commonUtils.d.ts +1 -0
- package/lib-esm/utils/commonUtils.js +15 -0
- package/lib-esm/utils/index.d.ts +2 -0
- package/lib-esm/utils/index.js +4 -0
- package/lib-esm/utils/utils.js +26 -0
- package/lib-esm/utils/utils.native.js +39 -0
- package/package.json +67 -28
- package/src/errors/InteractionsError.ts +18 -0
- package/src/errors/assertValidationError.ts +24 -0
- package/src/errors/index.ts +5 -0
- package/src/errors/validation.ts +15 -0
- package/src/index.ts +2 -5
- package/src/lex-v1/AWSLexProvider.ts +167 -0
- package/src/lex-v1/apis/index.ts +5 -0
- package/src/lex-v1/apis/onComplete.ts +21 -0
- package/src/lex-v1/apis/send.ts +21 -0
- package/src/lex-v1/index.ts +14 -0
- package/src/lex-v1/types/AWSLexProviderOption.ts +16 -0
- package/src/lex-v1/types/index.ts +6 -0
- package/src/lex-v1/types/inputs.ts +17 -0
- package/src/lex-v1/types/outputs.ts +9 -0
- package/src/{types/Response.ts → lex-v1/utils/index.ts} +1 -3
- package/src/lex-v1/utils/resolveBotConfig.ts +15 -0
- package/src/{Providers → lex-v2}/AWSLexV2Provider.ts +67 -137
- package/src/lex-v2/apis/index.ts +5 -0
- package/src/lex-v2/apis/onComplete.ts +21 -0
- package/src/lex-v2/apis/send.ts +21 -0
- package/src/lex-v2/index.ts +11 -0
- package/src/{types/Providers/AWSLexV2Provider.ts → lex-v2/types/AWSLexV2ProviderOption.ts} +7 -4
- package/src/lex-v2/types/index.ts +6 -0
- package/src/lex-v2/types/inputs.ts +17 -0
- package/src/lex-v2/types/outputs.ts +9 -0
- package/src/lex-v2/utils/index.ts +4 -0
- package/src/lex-v2/utils/resolveBotConfig.ts +15 -0
- package/src/types/Interactions.ts +9 -3
- package/src/types/index.ts +3 -5
- package/src/types/inputs.ts +17 -0
- package/src/types/outputs.ts +6 -0
- package/src/utils/index.ts +5 -0
- package/lib/.tsbuildinfo +0 -3
- package/lib/Interactions.d.ts +0 -24
- package/lib/Interactions.js +0 -123
- package/lib/Interactions.js.map +0 -1
- package/lib/Providers/AWSLexProvider.d.ts +0 -24
- package/lib/Providers/AWSLexProvider.js +0 -187
- package/lib/Providers/AWSLexProvider.js.map +0 -1
- package/lib/Providers/AWSLexProviderHelper/commonUtils.d.ts +0 -1
- package/lib/Providers/AWSLexProviderHelper/commonUtils.js +0 -29
- package/lib/Providers/AWSLexProviderHelper/commonUtils.js.map +0 -1
- package/lib/Providers/AWSLexProviderHelper/utils.js +0 -38
- package/lib/Providers/AWSLexProviderHelper/utils.js.map +0 -1
- package/lib/Providers/AWSLexProviderHelper/utils.native.js +0 -55
- package/lib/Providers/AWSLexProviderHelper/utils.native.js.map +0 -1
- package/lib/Providers/AWSLexV2Provider.d.ts +0 -58
- package/lib/Providers/AWSLexV2Provider.js +0 -282
- package/lib/Providers/AWSLexV2Provider.js.map +0 -1
- package/lib/Providers/InteractionsProvider.d.ts +0 -11
- package/lib/Providers/InteractionsProvider.js +0 -32
- package/lib/Providers/InteractionsProvider.js.map +0 -1
- package/lib/Providers/index.d.ts +0 -3
- package/lib/Providers/index.js +0 -11
- package/lib/Providers/index.js.map +0 -1
- package/lib/index.js.map +0 -1
- package/lib/types/Interactions.js.map +0 -1
- package/lib/types/Provider.d.ts +0 -12
- package/lib/types/Provider.js +0 -3
- package/lib/types/Provider.js.map +0 -1
- package/lib/types/Providers/AWSLexProvider.d.ts +0 -10
- package/lib/types/Providers/AWSLexProvider.js +0 -3
- package/lib/types/Providers/AWSLexProvider.js.map +0 -1
- package/lib/types/Providers/AWSLexV2Provider.d.ts +0 -12
- package/lib/types/Providers/AWSLexV2Provider.js +0 -3
- package/lib/types/Providers/AWSLexV2Provider.js.map +0 -1
- package/lib/types/Response.d.ts +0 -3
- package/lib/types/Response.js.map +0 -1
- package/lib/types/index.js.map +0 -1
- package/lib-esm/.tsbuildinfo +0 -3
- package/lib-esm/Interactions.d.ts +0 -24
- package/lib-esm/Interactions.js +0 -121
- package/lib-esm/Interactions.js.map +0 -1
- package/lib-esm/Providers/AWSLexProvider.d.ts +0 -24
- package/lib-esm/Providers/AWSLexProvider.js +0 -185
- package/lib-esm/Providers/AWSLexProvider.js.map +0 -1
- package/lib-esm/Providers/AWSLexProviderHelper/commonUtils.d.ts +0 -1
- package/lib-esm/Providers/AWSLexProviderHelper/commonUtils.js +0 -27
- package/lib-esm/Providers/AWSLexProviderHelper/commonUtils.js.map +0 -1
- package/lib-esm/Providers/AWSLexProviderHelper/utils.js +0 -36
- package/lib-esm/Providers/AWSLexProviderHelper/utils.js.map +0 -1
- package/lib-esm/Providers/AWSLexProviderHelper/utils.native.js +0 -53
- package/lib-esm/Providers/AWSLexProviderHelper/utils.native.js.map +0 -1
- package/lib-esm/Providers/AWSLexV2Provider.d.ts +0 -58
- package/lib-esm/Providers/AWSLexV2Provider.js +0 -280
- package/lib-esm/Providers/AWSLexV2Provider.js.map +0 -1
- package/lib-esm/Providers/InteractionsProvider.d.ts +0 -11
- package/lib-esm/Providers/InteractionsProvider.js +0 -30
- package/lib-esm/Providers/InteractionsProvider.js.map +0 -1
- package/lib-esm/Providers/index.d.ts +0 -3
- package/lib-esm/Providers/index.js +0 -6
- package/lib-esm/Providers/index.js.map +0 -1
- package/lib-esm/index.js.map +0 -1
- package/lib-esm/types/Interactions.js.map +0 -1
- package/lib-esm/types/Provider.d.ts +0 -12
- package/lib-esm/types/Provider.js +0 -1
- package/lib-esm/types/Provider.js.map +0 -1
- package/lib-esm/types/Providers/AWSLexProvider.d.ts +0 -10
- package/lib-esm/types/Providers/AWSLexProvider.js +0 -1
- package/lib-esm/types/Providers/AWSLexProvider.js.map +0 -1
- package/lib-esm/types/Providers/AWSLexV2Provider.d.ts +0 -12
- package/lib-esm/types/Providers/AWSLexV2Provider.js +0 -1
- package/lib-esm/types/Providers/AWSLexV2Provider.js.map +0 -1
- package/lib-esm/types/Response.d.ts +0 -3
- package/lib-esm/types/Response.js.map +0 -1
- package/lib-esm/types/index.js.map +0 -1
- package/src/Interactions.ts +0 -162
- package/src/Providers/AWSLexProvider.ts +0 -212
- package/src/Providers/InteractionsProvider.ts +0 -49
- package/src/Providers/index.ts +0 -5
- package/src/types/Provider.ts +0 -26
- package/src/types/Providers/AWSLexProvider.ts +0 -13
- /package/lib/{Providers/AWSLexProviderHelper → utils}/utils.d.ts +0 -0
- /package/lib/{Providers/AWSLexProviderHelper → utils}/utils.native.d.ts +0 -0
- /package/lib-esm/{Providers/AWSLexProviderHelper → utils}/utils.d.ts +0 -0
- /package/lib-esm/{Providers/AWSLexProviderHelper → utils}/utils.native.d.ts +0 -0
- /package/src/{Providers/AWSLexProviderHelper → utils}/commonUtils.ts +0 -0
- /package/src/{Providers/AWSLexProviderHelper → utils}/utils.native.ts +0 -0
- /package/src/{Providers/AWSLexProviderHelper → utils}/utils.ts +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aws-amplify/interactions",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "6.0.0",
|
|
4
4
|
"description": "Interactions category of aws-amplify",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"module": "./lib-esm/index.js",
|
|
@@ -8,10 +8,7 @@
|
|
|
8
8
|
"react-native": {
|
|
9
9
|
"./lib/index": "./lib-esm/index.js"
|
|
10
10
|
},
|
|
11
|
-
"sideEffects":
|
|
12
|
-
"./lib/Interactions.js",
|
|
13
|
-
"./lib-esm/Interactions.js"
|
|
14
|
-
],
|
|
11
|
+
"sideEffects": false,
|
|
15
12
|
"publishConfig": {
|
|
16
13
|
"access": "public"
|
|
17
14
|
},
|
|
@@ -19,16 +16,43 @@
|
|
|
19
16
|
"test": "npm run lint && jest -w 1 --coverage",
|
|
20
17
|
"test:size": "size-limit",
|
|
21
18
|
"build-with-test": "npm run clean && npm test && tsc && webpack",
|
|
22
|
-
"build:cjs": "
|
|
23
|
-
"build:esm": "
|
|
24
|
-
"build:cjs:watch": "
|
|
25
|
-
"build:esm:watch": "
|
|
19
|
+
"build:cjs": "rimraf lib && tsc -m commonjs --outDir lib && webpack && webpack --config ./webpack.config.dev.js",
|
|
20
|
+
"build:esm": "rimraf lib-esm && tsc -m esnext --outDir lib-esm",
|
|
21
|
+
"build:cjs:watch": "rimraf lib && tsc -m commonjs --outDir lib --watch",
|
|
22
|
+
"build:esm:watch": "rimraf lib-esm && tsc -m esnext --outDir lib-esm",
|
|
26
23
|
"build": "npm run clean && npm run build:esm && npm run build:cjs",
|
|
27
24
|
"clean": "npm run clean:size && rimraf lib-esm lib dist",
|
|
28
25
|
"clean:size": "rimraf dual-publish-tmp tmp*",
|
|
29
26
|
"format": "echo \"Not implemented\"",
|
|
30
27
|
"lint": "tslint 'src/**/*.ts' && npm run ts-coverage",
|
|
31
|
-
"ts-coverage": "typescript-coverage-report -p ./tsconfig.
|
|
28
|
+
"ts-coverage": "typescript-coverage-report -p ./tsconfig.json -t 88.6"
|
|
29
|
+
},
|
|
30
|
+
"typesVersions": {
|
|
31
|
+
">=4.2": {
|
|
32
|
+
"lex-v1": [
|
|
33
|
+
"./lib-esm/lex-v1/index.d.ts"
|
|
34
|
+
],
|
|
35
|
+
"lex-v2": [
|
|
36
|
+
"./lib-esm/lex-v2/index.d.ts"
|
|
37
|
+
]
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
"exports": {
|
|
41
|
+
".": {
|
|
42
|
+
"types": "./lib-esm/index.d.ts",
|
|
43
|
+
"import": "./lib-esm/index.js",
|
|
44
|
+
"require": "./lib/index.js"
|
|
45
|
+
},
|
|
46
|
+
"./lex-v1": {
|
|
47
|
+
"types": "./lib-esm/lex-v1/index.d.ts",
|
|
48
|
+
"import": "./lib-esm/lex-v1/index.js",
|
|
49
|
+
"require": "./lib/lex-v1/index.js"
|
|
50
|
+
},
|
|
51
|
+
"./lex-v2": {
|
|
52
|
+
"types": "./lib-esm/lex-v2/index.d.ts",
|
|
53
|
+
"import": "./lib-esm/lex-v2/index.js",
|
|
54
|
+
"require": "./lib/lex-v2/index.js"
|
|
55
|
+
}
|
|
32
56
|
},
|
|
33
57
|
"repository": {
|
|
34
58
|
"type": "git",
|
|
@@ -43,23 +67,41 @@
|
|
|
43
67
|
"files": [
|
|
44
68
|
"lib",
|
|
45
69
|
"lib-esm",
|
|
46
|
-
"src"
|
|
70
|
+
"src",
|
|
71
|
+
"lex-v1",
|
|
72
|
+
"lex-v2"
|
|
47
73
|
],
|
|
48
74
|
"dependencies": {
|
|
49
|
-
"@aws-
|
|
50
|
-
"@aws-sdk/client-lex-runtime-
|
|
51
|
-
"@aws-sdk/client-lex-runtime-v2": "3.186.3",
|
|
75
|
+
"@aws-sdk/client-lex-runtime-service": "3.398.0",
|
|
76
|
+
"@aws-sdk/client-lex-runtime-v2": "3.398.0",
|
|
52
77
|
"base-64": "1.0.0",
|
|
53
78
|
"fflate": "0.7.3",
|
|
54
79
|
"pako": "2.0.4",
|
|
55
|
-
"tslib": "^
|
|
80
|
+
"tslib": "^2.5.0",
|
|
81
|
+
"uuid": "^9.0.0"
|
|
82
|
+
},
|
|
83
|
+
"devDependencies": {
|
|
84
|
+
"@aws-amplify/core": "6.0.0",
|
|
85
|
+
"typescript": "^5.0.2"
|
|
56
86
|
},
|
|
57
87
|
"size-limit": [
|
|
58
88
|
{
|
|
59
|
-
"name": "Interactions (
|
|
89
|
+
"name": "Interactions (default to Lex v2)",
|
|
60
90
|
"path": "./lib-esm/index.js",
|
|
61
|
-
"import": "{ Amplify, Interactions
|
|
62
|
-
"limit": "
|
|
91
|
+
"import": "{ Amplify, Interactions }",
|
|
92
|
+
"limit": "52.00 kB"
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
"name": "Interactions (Lex v2)",
|
|
96
|
+
"path": "./lib-esm/lex-v2/index.js",
|
|
97
|
+
"import": "{ Amplify, Interactions }",
|
|
98
|
+
"limit": "52.00 kB"
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
"name": "Interactions (Lex v1)",
|
|
102
|
+
"path": "./lib-esm/lex-v1/index.js",
|
|
103
|
+
"import": "{ Amplify, Interactions }",
|
|
104
|
+
"limit": "47.00 kB"
|
|
63
105
|
}
|
|
64
106
|
],
|
|
65
107
|
"jest": {
|
|
@@ -67,20 +109,17 @@
|
|
|
67
109
|
"ts-jest": {
|
|
68
110
|
"diagnostics": false,
|
|
69
111
|
"tsConfig": {
|
|
70
|
-
"
|
|
71
|
-
|
|
72
|
-
"es2015",
|
|
73
|
-
"dom",
|
|
74
|
-
"esnext.asynciterable",
|
|
75
|
-
"es2017.object"
|
|
76
|
-
],
|
|
77
|
-
"allowJs": true
|
|
112
|
+
"allowJs": true,
|
|
113
|
+
"noEmitOnError": false
|
|
78
114
|
}
|
|
79
115
|
}
|
|
80
116
|
},
|
|
81
117
|
"transform": {
|
|
82
118
|
"^.+\\.(js|jsx|ts|tsx)$": "ts-jest"
|
|
83
119
|
},
|
|
120
|
+
"testPathIgnorePatterns": [
|
|
121
|
+
"/testUtils/"
|
|
122
|
+
],
|
|
84
123
|
"testRegex": "(/__tests__/.*|\\.(test|spec))\\.(tsx?|jsx?)$",
|
|
85
124
|
"moduleFileExtensions": [
|
|
86
125
|
"ts",
|
|
@@ -100,11 +139,11 @@
|
|
|
100
139
|
}
|
|
101
140
|
},
|
|
102
141
|
"coveragePathIgnorePatterns": [
|
|
103
|
-
"
|
|
142
|
+
"node_modules",
|
|
104
143
|
"dist",
|
|
105
144
|
"lib",
|
|
106
145
|
"lib-esm"
|
|
107
146
|
]
|
|
108
147
|
},
|
|
109
|
-
"gitHead": "
|
|
148
|
+
"gitHead": "d505105326d7f6214f6bd1e06eb20be3a3651377"
|
|
110
149
|
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
AmplifyError,
|
|
6
|
+
AmplifyErrorParams,
|
|
7
|
+
} from '@aws-amplify/core/internals/utils';
|
|
8
|
+
|
|
9
|
+
export class InteractionsError extends AmplifyError {
|
|
10
|
+
constructor(params: AmplifyErrorParams) {
|
|
11
|
+
super(params);
|
|
12
|
+
|
|
13
|
+
// Hack for making the custom error class work when transpiled to es5
|
|
14
|
+
// TODO: Delete the following 2 lines after we change the build target to >= es2015
|
|
15
|
+
this.constructor = InteractionsError;
|
|
16
|
+
Object.setPrototypeOf(this, InteractionsError.prototype);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
InteractionsValidationErrorCode,
|
|
6
|
+
validationErrorMap,
|
|
7
|
+
} from './validation';
|
|
8
|
+
import { InteractionsError } from './InteractionsError';
|
|
9
|
+
|
|
10
|
+
export function assertValidationError(
|
|
11
|
+
assertion: boolean,
|
|
12
|
+
name: InteractionsValidationErrorCode,
|
|
13
|
+
message?: string
|
|
14
|
+
): asserts assertion {
|
|
15
|
+
if (!assertion) {
|
|
16
|
+
const { message: defaultMessage, recoverySuggestion } =
|
|
17
|
+
validationErrorMap[name];
|
|
18
|
+
throw new InteractionsError({
|
|
19
|
+
name,
|
|
20
|
+
message: message ?? defaultMessage,
|
|
21
|
+
recoverySuggestion,
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import { AmplifyErrorMap } from '@aws-amplify/core/internals/utils';
|
|
5
|
+
|
|
6
|
+
export enum InteractionsValidationErrorCode {
|
|
7
|
+
NoBotConfig = 'NoBotConfig',
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export const validationErrorMap: AmplifyErrorMap<InteractionsValidationErrorCode> =
|
|
11
|
+
{
|
|
12
|
+
[InteractionsValidationErrorCode.NoBotConfig]: {
|
|
13
|
+
message: 'Missing configuration for the bot',
|
|
14
|
+
},
|
|
15
|
+
};
|
package/src/index.ts
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
-
export { Interactions } from './
|
|
5
|
-
export
|
|
6
|
-
export { AbstractInteractionsProvider } from './Providers/InteractionsProvider';
|
|
7
|
-
export { AWSLexProvider } from './Providers/AWSLexProvider';
|
|
8
|
-
export { AWSLexV2Provider } from './Providers/AWSLexV2Provider';
|
|
4
|
+
export { Interactions } from './lex-v2';
|
|
5
|
+
export { SendInput, OnCompleteInput, SendOutput } from './lex-v2/types';
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
import {
|
|
4
|
+
InteractionsOnCompleteCallback,
|
|
5
|
+
InteractionsMessage,
|
|
6
|
+
InteractionsResponse,
|
|
7
|
+
} from '../types/Interactions';
|
|
8
|
+
import {
|
|
9
|
+
DialogState,
|
|
10
|
+
LexRuntimeServiceClient,
|
|
11
|
+
PostContentCommand,
|
|
12
|
+
PostContentCommandInput,
|
|
13
|
+
PostContentCommandOutput,
|
|
14
|
+
PostTextCommand,
|
|
15
|
+
PostTextCommandInput,
|
|
16
|
+
PostTextCommandOutput,
|
|
17
|
+
} from '@aws-sdk/client-lex-runtime-service';
|
|
18
|
+
import { getAmplifyUserAgentObject } from '@aws-amplify/core/internals/utils';
|
|
19
|
+
import { ConsoleLogger, fetchAuthSession } from '@aws-amplify/core';
|
|
20
|
+
import { convert } from '../utils';
|
|
21
|
+
import { AWSLexProviderOption } from './types';
|
|
22
|
+
|
|
23
|
+
const logger = new ConsoleLogger('AWSLexProvider');
|
|
24
|
+
|
|
25
|
+
interface PostContentCommandOutputFormatted
|
|
26
|
+
extends Omit<PostContentCommandOutput, 'audioStream'> {
|
|
27
|
+
audioStream?: Uint8Array;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
type AWSLexProviderSendResponse =
|
|
31
|
+
| PostTextCommandOutput
|
|
32
|
+
| PostContentCommandOutputFormatted;
|
|
33
|
+
|
|
34
|
+
class AWSLexProvider {
|
|
35
|
+
private readonly _botsCompleteCallback: Record<
|
|
36
|
+
string,
|
|
37
|
+
InteractionsOnCompleteCallback
|
|
38
|
+
> = {};
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* @deprecated
|
|
42
|
+
* This is used internally by 'sendMessage' to call onComplete callback
|
|
43
|
+
* for a bot if configured
|
|
44
|
+
*/
|
|
45
|
+
reportBotStatus(
|
|
46
|
+
data: AWSLexProviderSendResponse,
|
|
47
|
+
{ name }: AWSLexProviderOption
|
|
48
|
+
) {
|
|
49
|
+
const callback = this._botsCompleteCallback[name];
|
|
50
|
+
if (!callback) {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
// Check if state is fulfilled to resolve onFullfilment promise
|
|
54
|
+
logger.debug('postContent state', data.dialogState);
|
|
55
|
+
|
|
56
|
+
switch (data.dialogState) {
|
|
57
|
+
case DialogState.READY_FOR_FULFILLMENT:
|
|
58
|
+
case DialogState.FULFILLED:
|
|
59
|
+
callback(undefined, data);
|
|
60
|
+
break;
|
|
61
|
+
case DialogState.FAILED:
|
|
62
|
+
callback(new Error('Bot conversation failed'));
|
|
63
|
+
break;
|
|
64
|
+
default:
|
|
65
|
+
break;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
async sendMessage(
|
|
70
|
+
botConfig: AWSLexProviderOption,
|
|
71
|
+
message: string | InteractionsMessage
|
|
72
|
+
): Promise<InteractionsResponse> {
|
|
73
|
+
// check if credentials are present
|
|
74
|
+
let session;
|
|
75
|
+
try {
|
|
76
|
+
session = await fetchAuthSession();
|
|
77
|
+
} catch (error) {
|
|
78
|
+
return Promise.reject('No credentials');
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
const { name, region, alias } = botConfig;
|
|
82
|
+
const client = new LexRuntimeServiceClient({
|
|
83
|
+
region,
|
|
84
|
+
credentials: session.credentials,
|
|
85
|
+
customUserAgent: getAmplifyUserAgentObject(),
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
let params: PostTextCommandInput | PostContentCommandInput;
|
|
89
|
+
if (typeof message === 'string') {
|
|
90
|
+
params = {
|
|
91
|
+
botAlias: alias,
|
|
92
|
+
botName: name,
|
|
93
|
+
inputText: message,
|
|
94
|
+
userId: session.identityId,
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
logger.debug('postText to lex', message);
|
|
98
|
+
try {
|
|
99
|
+
const postTextCommand = new PostTextCommand(params);
|
|
100
|
+
const data = await client.send(postTextCommand);
|
|
101
|
+
|
|
102
|
+
this.reportBotStatus(data, botConfig);
|
|
103
|
+
return data;
|
|
104
|
+
} catch (err) {
|
|
105
|
+
return Promise.reject(err);
|
|
106
|
+
}
|
|
107
|
+
} else {
|
|
108
|
+
const {
|
|
109
|
+
content,
|
|
110
|
+
options: { messageType },
|
|
111
|
+
} = message;
|
|
112
|
+
if (messageType === 'voice') {
|
|
113
|
+
if (typeof content !== 'object') {
|
|
114
|
+
return Promise.reject('invalid content type');
|
|
115
|
+
}
|
|
116
|
+
const inputStream =
|
|
117
|
+
content instanceof Uint8Array ? content : await convert(content);
|
|
118
|
+
|
|
119
|
+
params = {
|
|
120
|
+
botAlias: alias,
|
|
121
|
+
botName: name,
|
|
122
|
+
contentType: 'audio/x-l16; sample-rate=16000; channel-count=1',
|
|
123
|
+
userId: session.identityId,
|
|
124
|
+
accept: 'audio/mpeg',
|
|
125
|
+
inputStream,
|
|
126
|
+
};
|
|
127
|
+
} else {
|
|
128
|
+
if (typeof content !== 'string')
|
|
129
|
+
return Promise.reject('invalid content type');
|
|
130
|
+
|
|
131
|
+
params = {
|
|
132
|
+
botAlias: alias,
|
|
133
|
+
botName: name,
|
|
134
|
+
contentType: 'text/plain; charset=utf-8',
|
|
135
|
+
inputStream: content,
|
|
136
|
+
userId: session.identityId,
|
|
137
|
+
accept: 'audio/mpeg',
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
logger.debug('postContent to lex', message);
|
|
141
|
+
try {
|
|
142
|
+
const postContentCommand = new PostContentCommand(params);
|
|
143
|
+
const data = await client.send(postContentCommand);
|
|
144
|
+
|
|
145
|
+
const audioArray = data.audioStream
|
|
146
|
+
? await convert(data.audioStream)
|
|
147
|
+
: undefined;
|
|
148
|
+
|
|
149
|
+
const response = { ...data, ...{ audioStream: audioArray } };
|
|
150
|
+
|
|
151
|
+
this.reportBotStatus(response, botConfig);
|
|
152
|
+
return response;
|
|
153
|
+
} catch (err) {
|
|
154
|
+
return Promise.reject(err);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
onComplete(
|
|
160
|
+
{ name }: AWSLexProviderOption,
|
|
161
|
+
callback: InteractionsOnCompleteCallback
|
|
162
|
+
) {
|
|
163
|
+
this._botsCompleteCallback[name] = callback;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
export const lexProvider = new AWSLexProvider();
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import { OnCompleteInput } from '../types';
|
|
5
|
+
import { resolveBotConfig } from '../utils';
|
|
6
|
+
import { lexProvider } from '../AWSLexProvider';
|
|
7
|
+
import {
|
|
8
|
+
assertValidationError,
|
|
9
|
+
InteractionsValidationErrorCode,
|
|
10
|
+
} from '../../errors';
|
|
11
|
+
|
|
12
|
+
export const onComplete = (input: OnCompleteInput): void => {
|
|
13
|
+
const { botName, callback } = input;
|
|
14
|
+
const botConfig = resolveBotConfig(botName);
|
|
15
|
+
assertValidationError(
|
|
16
|
+
!!botConfig,
|
|
17
|
+
InteractionsValidationErrorCode.NoBotConfig,
|
|
18
|
+
`Bot ${botName} does not exist.`
|
|
19
|
+
);
|
|
20
|
+
lexProvider.onComplete(botConfig, callback);
|
|
21
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import { SendInput, SendOutput } from '../types';
|
|
5
|
+
import { resolveBotConfig } from '../utils';
|
|
6
|
+
import { lexProvider } from '../AWSLexProvider';
|
|
7
|
+
import {
|
|
8
|
+
assertValidationError,
|
|
9
|
+
InteractionsValidationErrorCode,
|
|
10
|
+
} from '../../errors';
|
|
11
|
+
|
|
12
|
+
export const send = async (input: SendInput): Promise<SendOutput> => {
|
|
13
|
+
const { botName, message } = input;
|
|
14
|
+
const botConfig = resolveBotConfig(botName);
|
|
15
|
+
assertValidationError(
|
|
16
|
+
!!botConfig,
|
|
17
|
+
InteractionsValidationErrorCode.NoBotConfig,
|
|
18
|
+
`Bot ${botName} does not exist.`
|
|
19
|
+
);
|
|
20
|
+
return lexProvider.sendMessage(botConfig, message);
|
|
21
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import { send, onComplete } from './apis';
|
|
5
|
+
import { IInteractions } from './types/AWSLexProviderOption';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @deprecated recommend to migrate to AWS Lex V2 instead
|
|
9
|
+
* */
|
|
10
|
+
export const Interactions: IInteractions = {
|
|
11
|
+
send,
|
|
12
|
+
onComplete,
|
|
13
|
+
};
|
|
14
|
+
export { SendInput, OnCompleteInput, SendOutput } from './types';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import { SendInput, OnCompleteInput } from './inputs';
|
|
5
|
+
import { SendOutput } from './outputs';
|
|
6
|
+
|
|
7
|
+
export interface AWSLexProviderOption {
|
|
8
|
+
name: string;
|
|
9
|
+
alias: string;
|
|
10
|
+
region: string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface IInteractions {
|
|
14
|
+
send(input: SendInput): Promise<SendOutput>;
|
|
15
|
+
onComplete(input: OnCompleteInput): void;
|
|
16
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
export { AWSLexProviderOption } from './AWSLexProviderOption';
|
|
5
|
+
export { SendInput, OnCompleteInput } from './inputs';
|
|
6
|
+
export { SendOutput } from './outputs';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
InteractionsSendInput,
|
|
6
|
+
InteractionsOnCompleteInput,
|
|
7
|
+
} from '../../types';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Input type for LexV1 send API.
|
|
11
|
+
*/
|
|
12
|
+
export type SendInput = InteractionsSendInput;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Input type for LexV1 onComplete API.
|
|
16
|
+
*/
|
|
17
|
+
export type OnCompleteInput = InteractionsOnCompleteInput;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import { InteractionsSendOutput } from '../../types';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Output type for LexV1 send API.
|
|
8
|
+
*/
|
|
9
|
+
export type SendOutput = InteractionsSendOutput;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import { AWSLexProviderOption } from '../types';
|
|
5
|
+
import { Amplify } from '@aws-amplify/core';
|
|
6
|
+
|
|
7
|
+
export const resolveBotConfig = (
|
|
8
|
+
botName: string
|
|
9
|
+
): AWSLexProviderOption | undefined => {
|
|
10
|
+
const { [botName]: botConfig = undefined } =
|
|
11
|
+
Amplify.getConfig().Interactions?.LexV1 ?? {};
|
|
12
|
+
if (botConfig !== undefined) {
|
|
13
|
+
return { ...botConfig, name: botName };
|
|
14
|
+
}
|
|
15
|
+
};
|