@xapp/stentor-alexa 1.86.2 → 1.86.4
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.
|
@@ -8,7 +8,7 @@ const stentor_locales_1 = require("stentor-locales");
|
|
|
8
8
|
const stentor_utils_1 = require("stentor-utils");
|
|
9
9
|
const stentor_alexa_lib_1 = require("@xapp/stentor-alexa-lib");
|
|
10
10
|
const TranslateToAlexaSlot_1 = require("./TranslateToAlexaSlot");
|
|
11
|
-
const
|
|
11
|
+
const utils_1 = require("./utils");
|
|
12
12
|
exports.DEFAULT_IS_LIST_EXPANSION = 6;
|
|
13
13
|
class TranslateToAlexaIntent extends patterns_1.Translator {
|
|
14
14
|
constructor(props = {}) {
|
|
@@ -39,7 +39,7 @@ class TranslateToAlexaIntent extends patterns_1.Translator {
|
|
|
39
39
|
// These will be found and replaced in the utterances later on
|
|
40
40
|
const expandedUtteranceReplacements = {};
|
|
41
41
|
// Expand if we need to
|
|
42
|
-
(flattenedIntent.slots || []).forEach(slot => {
|
|
42
|
+
(flattenedIntent.slots || []).forEach((slot) => {
|
|
43
43
|
const isList = slot.isList;
|
|
44
44
|
if (isList) {
|
|
45
45
|
// 0. Remember the original & setup the replacement
|
|
@@ -79,7 +79,7 @@ class TranslateToAlexaIntent extends patterns_1.Translator {
|
|
|
79
79
|
}
|
|
80
80
|
});
|
|
81
81
|
const slots = [];
|
|
82
|
-
expandedSlots.forEach(slot => {
|
|
82
|
+
expandedSlots.forEach((slot) => {
|
|
83
83
|
if (slot.type === stentor_interaction_model_1.ENTITY_DATE_TIME) {
|
|
84
84
|
// THIS ONE IS SPECIAL LIKE isList
|
|
85
85
|
// It is converted to two slots
|
|
@@ -121,11 +121,11 @@ class TranslateToAlexaIntent extends patterns_1.Translator {
|
|
|
121
121
|
// We will push the samples here
|
|
122
122
|
const samples = [];
|
|
123
123
|
// Iterate through the utterances as we may need to replace the slots
|
|
124
|
-
generatedUtterances.forEach(utterance => {
|
|
124
|
+
generatedUtterances.forEach((utterance) => {
|
|
125
125
|
// Grab the slots from the utterance
|
|
126
126
|
const slotNamesWithUtterance = (0, stentor_interaction_model_1.getSlotNames)(utterance);
|
|
127
127
|
// grab the slots that need replacing from the current utterance
|
|
128
|
-
const replaceWithinUtterance = intersection(slotNamesWithUtterance, toBeReplaced);
|
|
128
|
+
const replaceWithinUtterance = (0, utils_1.intersection)(slotNamesWithUtterance, toBeReplaced);
|
|
129
129
|
if (replaceWithinUtterance.length > 0) {
|
|
130
130
|
const replacedUtterances = THE_ALGORITHM(utterance, replaceWithinUtterance, expandedUtteranceReplacements);
|
|
131
131
|
samples.push.apply(samples, replacedUtterances);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TranslateToAlexaIntent.js","sourceRoot":"","sources":["../../src/Translators/TranslateToAlexaIntent.ts"],"names":[],"mappings":";;;AAAA,oCAAoC;AACpC,6CAA4C;AAC5C,yEAKmC;AACnC,qDAA2C;AAE3C,iDAAyD;AACzD,+
|
|
1
|
+
{"version":3,"file":"TranslateToAlexaIntent.js","sourceRoot":"","sources":["../../src/Translators/TranslateToAlexaIntent.ts"],"names":[],"mappings":";;;AAAA,oCAAoC;AACpC,6CAA4C;AAC5C,yEAKmC;AACnC,qDAA2C;AAE3C,iDAAyD;AACzD,+DAMiC;AACjC,iEAA8D;AAC9D,mCAAuC;AAE1B,QAAA,yBAAyB,GAAG,CAAC,CAAC;AAY3C,MAAa,sBAAuB,SAAQ,qBAA+B;IAIvE,YAAY,QAA+B,EAAE;QACzC,KAAK,EAAE,CAAC;QACR,MAAM,EAAE,oBAAoB,EAAE,cAAc,EAAE,GAAG,KAAK,CAAC;QAEvD,IAAI,CAAC,oBAAoB,GAAG,oBAAoB,IAAI,IAAI,8CAA0B,EAAE,CAAC;QACrF,IAAI,CAAC,cAAc,GAAG,cAAc,IAAI,IAAI,2CAAoB,EAAE,CAAC;IACvE,CAAC;IAED;;;;;;;;;;OAUG;IACH,SAAS,CA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,CAAC,CAAC;gBAC1E,eAAe,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;YAC3C,CAAC;QACL,CAAC;QAED,OAAO,eAAe,CAAC;IAC3B,CAAC;IACD,OAAO,OAAO,CAAC,CAAC,SAAS,CAAC,EAAE,qBAAqB,EAAE,YAAY,CAAC,CAAC;AACrE,CAAC"}
|
|
@@ -6,3 +6,14 @@
|
|
|
6
6
|
* @returns {boolean}
|
|
7
7
|
*/
|
|
8
8
|
export declare function isAmazonBuiltInIntent(intent: string): boolean;
|
|
9
|
+
/**
|
|
10
|
+
* Values present in every provided array.
|
|
11
|
+
*
|
|
12
|
+
* Order follows the first array and duplicates are dropped, matching the
|
|
13
|
+
* `lodash.intersection` behavior this replaced.
|
|
14
|
+
*
|
|
15
|
+
* @export
|
|
16
|
+
* @param {T[][]} arrays
|
|
17
|
+
* @returns {T[]}
|
|
18
|
+
*/
|
|
19
|
+
export declare function intersection<T>(...arrays: T[][]): T[];
|
package/lib/Translators/utils.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.isAmazonBuiltInIntent = isAmazonBuiltInIntent;
|
|
4
|
+
exports.intersection = intersection;
|
|
4
5
|
/*! Copyright (c) 2019, XAPPmedia */
|
|
5
6
|
const stentor_alexa_lib_1 = require("@xapp/stentor-alexa-lib");
|
|
6
7
|
/**
|
|
@@ -13,4 +14,28 @@ const stentor_alexa_lib_1 = require("@xapp/stentor-alexa-lib");
|
|
|
13
14
|
function isAmazonBuiltInIntent(intent) {
|
|
14
15
|
return stentor_alexa_lib_1.INTENT_TRANSLATION[intent] !== undefined;
|
|
15
16
|
}
|
|
17
|
+
/**
|
|
18
|
+
* Values present in every provided array.
|
|
19
|
+
*
|
|
20
|
+
* Order follows the first array and duplicates are dropped, matching the
|
|
21
|
+
* `lodash.intersection` behavior this replaced.
|
|
22
|
+
*
|
|
23
|
+
* @export
|
|
24
|
+
* @param {T[][]} arrays
|
|
25
|
+
* @returns {T[]}
|
|
26
|
+
*/
|
|
27
|
+
function intersection(...arrays) {
|
|
28
|
+
const [first, ...rest] = arrays;
|
|
29
|
+
if (!first) {
|
|
30
|
+
return [];
|
|
31
|
+
}
|
|
32
|
+
const found = new Set();
|
|
33
|
+
return first.filter((value) => {
|
|
34
|
+
if (found.has(value) || !rest.every((array) => array.includes(value))) {
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
found.add(value);
|
|
38
|
+
return true;
|
|
39
|
+
});
|
|
40
|
+
}
|
|
16
41
|
//# sourceMappingURL=utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/Translators/utils.ts"],"names":[],"mappings":";;AAUA,sDAEC;
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/Translators/utils.ts"],"names":[],"mappings":";;AAUA,sDAEC;AAYD,oCAiBC;AAzCD,oCAAoC;AACpC,+DAA6D;AAE7D;;;;;;GAMG;AACH,SAAgB,qBAAqB,CAAC,MAAc;IAChD,OAAO,sCAAkB,CAAC,MAAM,CAAC,KAAK,SAAS,CAAC;AACpD,CAAC;AAED;;;;;;;;;GASG;AACH,SAAgB,YAAY,CAAI,GAAG,MAAa;IAC5C,MAAM,CAAC,KAAK,EAAE,GAAG,IAAI,CAAC,GAAG,MAAM,CAAC;IAEhC,IAAI,CAAC,KAAK,EAAE,CAAC;QACT,OAAO,EAAE,CAAC;IACd,CAAC;IAED,MAAM,KAAK,GAAG,IAAI,GAAG,EAAK,CAAC;IAE3B,OAAO,KAAK,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE;QAC1B,IAAI,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC;YACpE,OAAO,KAAK,CAAC;QACjB,CAAC;QAED,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QACjB,OAAO,IAAI,CAAC;IAChB,CAAC,CAAC,CAAC;AACP,CAAC"}
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
7
|
-
"version": "1.86.
|
|
7
|
+
"version": "1.86.4",
|
|
8
8
|
"description": "Alexa channel for stentor",
|
|
9
9
|
"types": "lib/index",
|
|
10
10
|
"main": "lib/index",
|
|
@@ -17,33 +17,31 @@
|
|
|
17
17
|
"devDependencies": {
|
|
18
18
|
"@types/chai": "5.2.3",
|
|
19
19
|
"@types/chai-as-promised": "7.1.8",
|
|
20
|
-
"@types/lodash.intersection": "4.4.9",
|
|
21
20
|
"@types/node": "24.13.3",
|
|
22
21
|
"@xapp/config": "0.3.0",
|
|
23
22
|
"chai": "4.5.0",
|
|
24
23
|
"chai-as-promised": "7.1.2",
|
|
25
24
|
"fetch-mock": "9.11.0",
|
|
26
|
-
"mocha": "11.
|
|
27
|
-
"stentor-constants": "1.74.
|
|
28
|
-
"stentor-interaction-model": "1.74.
|
|
29
|
-
"stentor-locales": "1.74.
|
|
30
|
-
"stentor-logger": "1.74.
|
|
31
|
-
"stentor-media": "1.74.
|
|
32
|
-
"stentor-models": "1.
|
|
33
|
-
"stentor-request": "1.74.
|
|
34
|
-
"stentor-response": "1.74.
|
|
35
|
-
"stentor-utils": "1.
|
|
25
|
+
"mocha": "11.8.0",
|
|
26
|
+
"stentor-constants": "1.74.3",
|
|
27
|
+
"stentor-interaction-model": "1.74.5",
|
|
28
|
+
"stentor-locales": "1.74.5",
|
|
29
|
+
"stentor-logger": "1.74.5",
|
|
30
|
+
"stentor-media": "1.74.6",
|
|
31
|
+
"stentor-models": "1.77.0",
|
|
32
|
+
"stentor-request": "1.74.5",
|
|
33
|
+
"stentor-response": "1.74.6",
|
|
34
|
+
"stentor-utils": "1.75.1",
|
|
36
35
|
"ts-node": "10.9.2",
|
|
37
36
|
"typescript": "5.9.3"
|
|
38
37
|
},
|
|
39
38
|
"dependencies": {
|
|
40
39
|
"@xapp/patterns": "2.0.3",
|
|
41
|
-
"@xapp/stentor-alexa-lib": "1.86.
|
|
40
|
+
"@xapp/stentor-alexa-lib": "1.86.4",
|
|
42
41
|
"alexa-verifier": "2.0.2",
|
|
43
42
|
"amazon-date-parser": "0.3.0",
|
|
44
43
|
"ask-sdk-model": "1.86.0",
|
|
45
|
-
"jsonpath-plus": "10.4.0"
|
|
46
|
-
"lodash.intersection": "4.4.0"
|
|
44
|
+
"jsonpath-plus": "10.4.0"
|
|
47
45
|
},
|
|
48
46
|
"peerDependencies": {
|
|
49
47
|
"stentor-constants": "1.x",
|