@sprucelabs/spruce-conversation-plugin 62.0.1 → 62.0.3
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/build/.spruce/errors/errors.types.d.ts +8 -8
- package/build/.spruce/errors/options.types.d.ts +2 -2
- package/build/__tests__/behavioral/KillingASkill.test.js +1 -1
- package/build/__tests__/behavioral/RegisteringConversationsOnBoot.test.js +4 -2
- package/build/__tests__/behavioral/RespondingToMessages.test.js +1 -1
- package/build/__tests__/implementation/ConversationCoordinator.test.js +24 -6
- package/build/__tests__/implementation/MessageGraphicsInterface/EmailField.test.js +3 -1
- package/build/__tests__/implementation/MessageGraphicsInterface/TextField.test.js +3 -1
- package/build/__tests__/implementation/ScriptTester.test.js +3 -4
- package/build/__tests__/implementation/TopicScriptPlayer.test.js +5 -1
- package/build/__tests__/implementation/TopicSuggester.test.js +7 -1
- package/build/__tests__/testDirsAndFiles/good/conversations/cancelAppointment.topic.js +5 -1
- package/build/__tests__/testDirsAndFiles/skill/build/conversations/cancelAppointment.topic.js +5 -1
- package/build/__tests__/testDirsAndFiles/skill/build/conversations/favoriteColor.topic.js +4 -1
- package/build/__tests__/testDirsAndFiles/skill/build/conversations/favoriteColorTopicChanger.topic.js +4 -1
- package/build/__tests__/testDirsAndFiles/skill-with-script-that-throws/build/conversations/cancelAppointment.topic.js +5 -1
- package/build/esm/.spruce/errors/errors.types.d.ts +8 -8
- package/build/esm/.spruce/errors/options.types.d.ts +2 -2
- package/build/esm/__tests__/behavioral/KillingASkill.test.js +1 -1
- package/build/esm/__tests__/behavioral/RegisteringConversationsOnBoot.test.js +4 -2
- package/build/esm/__tests__/behavioral/RespondingToMessages.test.js +1 -1
- package/build/esm/__tests__/implementation/ConversationCoordinator.test.js +24 -6
- package/build/esm/__tests__/implementation/MessageGraphicsInterface/EmailField.test.js +3 -1
- package/build/esm/__tests__/implementation/MessageGraphicsInterface/TextField.test.js +3 -1
- package/build/esm/__tests__/implementation/ScriptTester.test.js +1 -2
- package/build/esm/__tests__/implementation/TopicScriptPlayer.test.js +5 -1
- package/build/esm/__tests__/implementation/TopicSuggester.test.js +7 -1
- package/build/esm/__tests__/testDirsAndFiles/good/conversations/cancelAppointment.topic.js +5 -1
- package/build/esm/__tests__/testDirsAndFiles/skill/build/conversations/cancelAppointment.topic.js +5 -1
- package/build/esm/__tests__/testDirsAndFiles/skill/build/conversations/favoriteColor.topic.js +4 -1
- package/build/esm/__tests__/testDirsAndFiles/skill/build/conversations/favoriteColorTopicChanger.topic.js +4 -1
- package/build/esm/__tests__/testDirsAndFiles/skill-with-script-that-throws/build/conversations/cancelAppointment.topic.js +5 -1
- package/build/esm/plugins/conversation.plugin.js +25 -20
- package/build/esm/tests/AbstractGraphicsInterfaceTest.js +4 -1
- package/build/esm/tests/ScriptTester.js +19 -7
- package/build/esm/topics/TopicLoader.js +3 -1
- package/build/esm/topics/TopicScriptPlayer.js +2 -1
- package/build/esm/topics/TopicSuggester.js +5 -1
- package/build/esm/types/conversation.types.d.ts +6 -10
- package/build/esm/utilities/suggester.utility.d.ts +2 -2
- package/build/plugins/conversation.plugin.js +25 -20
- package/build/tests/AbstractGraphicsInterfaceTest.js +4 -1
- package/build/tests/ScriptTester.js +19 -7
- package/build/topics/TopicLoader.js +3 -1
- package/build/topics/TopicScriptPlayer.js +2 -1
- package/build/topics/TopicSuggester.js +5 -1
- package/build/types/conversation.types.d.ts +6 -10
- package/build/utilities/suggester.utility.d.ts +2 -2
- package/package.json +20 -22
|
@@ -2,8 +2,8 @@ import { default as SchemaEntity } from '@sprucelabs/schema';
|
|
|
2
2
|
import * as SpruceSchema from '@sprucelabs/schema';
|
|
3
3
|
export declare namespace SpruceErrors.Conversation {
|
|
4
4
|
interface TopicNotFound {
|
|
5
|
-
suppliedTopic: string;
|
|
6
|
-
validTopics: string[];
|
|
5
|
+
'suppliedTopic': string;
|
|
6
|
+
'validTopics': string[];
|
|
7
7
|
}
|
|
8
8
|
interface TopicNotFoundSchema extends SpruceSchema.Schema {
|
|
9
9
|
id: 'topicNotFound';
|
|
@@ -11,13 +11,13 @@ export declare namespace SpruceErrors.Conversation {
|
|
|
11
11
|
name: 'Topic not found';
|
|
12
12
|
fields: {
|
|
13
13
|
/** . */
|
|
14
|
-
suppliedTopic: {
|
|
14
|
+
'suppliedTopic': {
|
|
15
15
|
type: 'text';
|
|
16
16
|
isRequired: true;
|
|
17
17
|
options: undefined;
|
|
18
18
|
};
|
|
19
19
|
/** . */
|
|
20
|
-
validTopics: {
|
|
20
|
+
'validTopics': {
|
|
21
21
|
type: 'text';
|
|
22
22
|
isRequired: true;
|
|
23
23
|
isArray: true;
|
|
@@ -40,7 +40,7 @@ export declare namespace SpruceErrors.Conversation {
|
|
|
40
40
|
}
|
|
41
41
|
export declare namespace SpruceErrors.Conversation {
|
|
42
42
|
interface MissingDependencies {
|
|
43
|
-
dependencies: string[];
|
|
43
|
+
'dependencies': string[];
|
|
44
44
|
}
|
|
45
45
|
interface MissingDependenciesSchema extends SpruceSchema.Schema {
|
|
46
46
|
id: 'missingDependencies';
|
|
@@ -48,7 +48,7 @@ export declare namespace SpruceErrors.Conversation {
|
|
|
48
48
|
name: 'Missing dependencies';
|
|
49
49
|
fields: {
|
|
50
50
|
/** . */
|
|
51
|
-
dependencies: {
|
|
51
|
+
'dependencies': {
|
|
52
52
|
type: 'text';
|
|
53
53
|
isRequired: true;
|
|
54
54
|
isArray: true;
|
|
@@ -61,7 +61,7 @@ export declare namespace SpruceErrors.Conversation {
|
|
|
61
61
|
export declare namespace SpruceErrors.Conversation {
|
|
62
62
|
interface InvalidTopic {
|
|
63
63
|
/** . The script that I was attempting to load. Ends in .topic */
|
|
64
|
-
topicScript: string;
|
|
64
|
+
'topicScript': string;
|
|
65
65
|
}
|
|
66
66
|
interface InvalidTopicSchema extends SpruceSchema.Schema {
|
|
67
67
|
id: 'invalidTopic';
|
|
@@ -69,7 +69,7 @@ export declare namespace SpruceErrors.Conversation {
|
|
|
69
69
|
name: 'Invalid topic';
|
|
70
70
|
fields: {
|
|
71
71
|
/** . The script that I was attempting to load. Ends in .topic */
|
|
72
|
-
topicScript: {
|
|
72
|
+
'topicScript': {
|
|
73
73
|
type: 'text';
|
|
74
74
|
isRequired: true;
|
|
75
75
|
hint: 'The script that I was attempting to load. Ends in .topic';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { SpruceErrors } from "./errors.types";
|
|
2
|
+
import { ErrorOptions as ISpruceErrorOptions } from "@sprucelabs/error";
|
|
3
3
|
export interface TopicNotFoundErrorOptions extends SpruceErrors.Conversation.TopicNotFound, ISpruceErrorOptions {
|
|
4
4
|
code: 'TOPIC_NOT_FOUND';
|
|
5
5
|
}
|
|
@@ -9,9 +9,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
9
9
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
const spruce_test_fixtures_1 = require("@sprucelabs/spruce-test-fixtures");
|
|
12
13
|
const test_utils_1 = require("@sprucelabs/test-utils");
|
|
13
14
|
const AbstractConversationTest_1 = __importDefault(require("../../tests/AbstractConversationTest"));
|
|
14
|
-
const spruce_test_fixtures_1 = require("@sprucelabs/spruce-test-fixtures");
|
|
15
15
|
spruce_test_fixtures_1.MercuryFixture.setShouldRequireLocalListeners(false);
|
|
16
16
|
class KillingASkillTest extends AbstractConversationTest_1.default {
|
|
17
17
|
static async killingASkillKillsConversation() {
|
|
@@ -10,11 +10,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
const spruce_event_utils_1 = require("@sprucelabs/spruce-event-utils");
|
|
13
|
+
const spruce_test_fixtures_1 = require("@sprucelabs/spruce-test-fixtures");
|
|
13
14
|
const test_utils_1 = require("@sprucelabs/test-utils");
|
|
14
15
|
const test_utils_2 = require("@sprucelabs/test-utils");
|
|
15
16
|
const conversation_plugin_1 = __importDefault(require("../../plugins/conversation.plugin"));
|
|
16
17
|
const AbstractConversationTest_1 = __importDefault(require("../../tests/AbstractConversationTest"));
|
|
17
|
-
const spruce_test_fixtures_1 = require("@sprucelabs/spruce-test-fixtures");
|
|
18
18
|
spruce_test_fixtures_1.MercuryFixture.setShouldRequireLocalListeners(false);
|
|
19
19
|
class RegisteringConversationsOnBootTest extends AbstractConversationTest_1.default {
|
|
20
20
|
static async throwsWhenExecutingIfEventPluginMissing() {
|
|
@@ -35,7 +35,9 @@ class RegisteringConversationsOnBootTest extends AbstractConversationTest_1.defa
|
|
|
35
35
|
this.assertExpectedTopics(topics);
|
|
36
36
|
}
|
|
37
37
|
static async skillShutsDownWhenConvosFailToRegister() {
|
|
38
|
-
const { skill } = await super.bootSkill({
|
|
38
|
+
const { skill } = await super.bootSkill({
|
|
39
|
+
shouldSuppressBootErrors: true,
|
|
40
|
+
});
|
|
39
41
|
test_utils_1.assert.isFalse(skill.isRunning());
|
|
40
42
|
this.clearSkillBootErrors();
|
|
41
43
|
}
|
|
@@ -10,9 +10,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
const spruce_event_utils_1 = require("@sprucelabs/spruce-event-utils");
|
|
13
|
+
const spruce_test_fixtures_1 = require("@sprucelabs/spruce-test-fixtures");
|
|
13
14
|
const test_utils_1 = require("@sprucelabs/test-utils");
|
|
14
15
|
const AbstractConversationTest_1 = __importDefault(require("../../tests/AbstractConversationTest"));
|
|
15
|
-
const spruce_test_fixtures_1 = require("@sprucelabs/spruce-test-fixtures");
|
|
16
16
|
spruce_test_fixtures_1.MercuryFixture.setShouldRequireLocalListeners(false);
|
|
17
17
|
class RespondingToMessagesTest extends AbstractConversationTest_1.default {
|
|
18
18
|
static async beforeEach() {
|
|
@@ -41,7 +41,10 @@ class TopicCoordinatorTest extends AbstractConversationTest_1.default {
|
|
|
41
41
|
});
|
|
42
42
|
}
|
|
43
43
|
static async respondsWithSuggestedTopicsToFirstMessage() {
|
|
44
|
-
const results = await this.coordinator.handleMessage(this.buildMessage({
|
|
44
|
+
const results = await this.coordinator.handleMessage(this.buildMessage({
|
|
45
|
+
body: 'help me book!',
|
|
46
|
+
source: { personId: '1234' },
|
|
47
|
+
}));
|
|
45
48
|
test_utils_1.assert.isArray(results.suggestedTopics);
|
|
46
49
|
test_utils_1.assert.isLength(results.suggestedTopics, 3);
|
|
47
50
|
}
|
|
@@ -51,7 +54,10 @@ class TopicCoordinatorTest extends AbstractConversationTest_1.default {
|
|
|
51
54
|
sendMessageHandler: async () => { },
|
|
52
55
|
getContext: () => this.skillContext,
|
|
53
56
|
});
|
|
54
|
-
const results = await coordinator.handleMessage(this.buildMessage({
|
|
57
|
+
const results = await coordinator.handleMessage(this.buildMessage({
|
|
58
|
+
body: 'help me book!',
|
|
59
|
+
source: { personId: '1234' },
|
|
60
|
+
}));
|
|
55
61
|
test_utils_1.assert.isArray(results.suggestedTopics);
|
|
56
62
|
test_utils_1.assert.isLength(results.suggestedTopics, 0);
|
|
57
63
|
}
|
|
@@ -96,26 +102,38 @@ class TopicCoordinatorTest extends AbstractConversationTest_1.default {
|
|
|
96
102
|
test_utils_1.assert.isEqual((_a = this.sentMessages[0]) === null || _a === void 0 ? void 0 : _a.body, 'string 1');
|
|
97
103
|
test_utils_1.assert.isEqual((_b = this.sentMessages[1]) === null || _b === void 0 ? void 0 : _b.body, 'prompt 1');
|
|
98
104
|
this.sentMessages = [];
|
|
99
|
-
await this.coordinator.handleMessage(this.buildMessage({
|
|
105
|
+
await this.coordinator.handleMessage(this.buildMessage({
|
|
106
|
+
body: 'answer 1',
|
|
107
|
+
source: { personId: '1234' },
|
|
108
|
+
}), 'mixedStringsAndCallbacks');
|
|
100
109
|
await this.wait(100);
|
|
101
110
|
test_utils_1.assert.isLength(this.sentMessages, 3);
|
|
102
111
|
test_utils_1.assert.isEqual((_c = this.sentMessages[0]) === null || _c === void 0 ? void 0 : _c.body, 'answer 1');
|
|
103
112
|
test_utils_1.assert.isEqual((_d = this.sentMessages[1]) === null || _d === void 0 ? void 0 : _d.body, 'string 2');
|
|
104
113
|
test_utils_1.assert.isEqual((_e = this.sentMessages[2]) === null || _e === void 0 ? void 0 : _e.body, 'prompt 2');
|
|
105
114
|
this.sentMessages = [];
|
|
106
|
-
await this.coordinator.handleMessage(this.buildMessage({
|
|
115
|
+
await this.coordinator.handleMessage(this.buildMessage({
|
|
116
|
+
body: 'answer 2',
|
|
117
|
+
source: { personId: '1234' },
|
|
118
|
+
}), 'mixedStringsAndCallbacks');
|
|
107
119
|
test_utils_1.assert.isLength(this.sentMessages, 2);
|
|
108
120
|
test_utils_1.assert.isEqual((_f = this.sentMessages[0]) === null || _f === void 0 ? void 0 : _f.body, 'answer 2');
|
|
109
121
|
test_utils_1.assert.isEqual((_g = this.sentMessages[1]) === null || _g === void 0 ? void 0 : _g.body, 'and done');
|
|
110
122
|
this.sentMessages = [];
|
|
111
|
-
await this.coordinator.handleMessage(this.buildMessage({
|
|
123
|
+
await this.coordinator.handleMessage(this.buildMessage({
|
|
124
|
+
body: 'answer 1',
|
|
125
|
+
source: { personId: '1234' },
|
|
126
|
+
}), 'mixedStringsAndCallbacks');
|
|
112
127
|
await this.wait(100);
|
|
113
128
|
test_utils_1.assert.isLength(this.sentMessages, 2);
|
|
114
129
|
test_utils_1.assert.isEqual((_h = this.sentMessages[0]) === null || _h === void 0 ? void 0 : _h.body, 'string 1');
|
|
115
130
|
test_utils_1.assert.isEqual((_j = this.sentMessages[1]) === null || _j === void 0 ? void 0 : _j.body, 'prompt 1');
|
|
116
131
|
}
|
|
117
132
|
static async passesThroughContextGetter(context) {
|
|
118
|
-
await this.coordinator.handleMessage(this.buildMessage({
|
|
133
|
+
await this.coordinator.handleMessage(this.buildMessage({
|
|
134
|
+
body: 'answer 2',
|
|
135
|
+
source: { personId: '1234' },
|
|
136
|
+
}), 'bookAppointment');
|
|
119
137
|
this.skillContext = context;
|
|
120
138
|
const player = this.coordinator.getPlayer();
|
|
121
139
|
test_utils_1.assert.isTruthy(player);
|
|
@@ -18,7 +18,9 @@ class TextFieldTest extends AbstractGraphicsInterfaceTest_1.default {
|
|
|
18
18
|
type: 'email',
|
|
19
19
|
label: 'Tell me about your life.',
|
|
20
20
|
});
|
|
21
|
-
test_utils_1.assert.doesInclude(this.sentMessages, {
|
|
21
|
+
test_utils_1.assert.doesInclude(this.sentMessages, {
|
|
22
|
+
body: 'Tell me about your life.',
|
|
23
|
+
});
|
|
22
24
|
}
|
|
23
25
|
static async noPromptSendsNoMessage() {
|
|
24
26
|
void this.ui.prompt({
|
|
@@ -17,7 +17,9 @@ class TextFieldTest extends AbstractGraphicsInterfaceTest_1.default {
|
|
|
17
17
|
type: 'text',
|
|
18
18
|
label: 'Tell me about your life.',
|
|
19
19
|
});
|
|
20
|
-
test_utils_1.assert.doesInclude(this.sentMessages, {
|
|
20
|
+
test_utils_1.assert.doesInclude(this.sentMessages, {
|
|
21
|
+
body: 'Tell me about your life.',
|
|
22
|
+
});
|
|
21
23
|
}
|
|
22
24
|
static async noPromptSendsNoMessage() {
|
|
23
25
|
void this.ui.prompt({
|
|
@@ -33,14 +33,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
33
33
|
};
|
|
34
34
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
35
|
const test_utils_1 = require("@sprucelabs/test-utils");
|
|
36
|
-
const test_utils_2 = require("@sprucelabs/test-utils");
|
|
37
36
|
const AbstractConversationTest_1 = __importDefault(require("../../tests/AbstractConversationTest"));
|
|
38
37
|
const ScriptTester_1 = __importStar(require("../../tests/ScriptTester"));
|
|
39
38
|
class ScriptTesterTest extends AbstractConversationTest_1.default {
|
|
40
39
|
static async throwsWithoutScript() {
|
|
41
40
|
//@ts-ignore
|
|
42
41
|
const err = await test_utils_1.assert.doesThrowAsync(() => ScriptTester_1.default.Tester());
|
|
43
|
-
|
|
42
|
+
test_utils_1.errorAssert.assertError(err, 'MISSING_PARAMETERS', {
|
|
44
43
|
parameters: ['script'],
|
|
45
44
|
});
|
|
46
45
|
}
|
|
@@ -88,7 +87,7 @@ class ScriptTesterTest extends AbstractConversationTest_1.default {
|
|
|
88
87
|
promptHandler: async () => '',
|
|
89
88
|
});
|
|
90
89
|
const err = await test_utils_1.assert.doesThrowAsync(() => tester.handleInput('taco'));
|
|
91
|
-
|
|
90
|
+
test_utils_1.errorAssert.assertError(err, 'TESTER_NOT_STARTED');
|
|
92
91
|
}
|
|
93
92
|
static async selectingBadScriptToStartThrows() {
|
|
94
93
|
const tester = await this.Tester({
|
|
@@ -100,7 +99,7 @@ class ScriptTesterTest extends AbstractConversationTest_1.default {
|
|
|
100
99
|
promptHandler: async () => '',
|
|
101
100
|
});
|
|
102
101
|
const err = await test_utils_1.assert.doesThrowAsync(() => tester.go());
|
|
103
|
-
|
|
102
|
+
test_utils_1.errorAssert.assertError(err, 'TOPIC_NOT_FOUND', {
|
|
104
103
|
suppliedTopic: 'oeuou',
|
|
105
104
|
validTopics: ['bookAppointment', 'cancelAppointment'],
|
|
106
105
|
});
|
|
@@ -233,7 +233,11 @@ class TopicScriptPlayerTest extends AbstractConversationTest_1.default {
|
|
|
233
233
|
static async randomOnOptions() {
|
|
234
234
|
const messages = [];
|
|
235
235
|
const remaining = { one: true, two: true, three: true };
|
|
236
|
-
const possibilities = [
|
|
236
|
+
const possibilities = [
|
|
237
|
+
'one',
|
|
238
|
+
'two',
|
|
239
|
+
'three',
|
|
240
|
+
];
|
|
237
241
|
const player = this.Player({
|
|
238
242
|
sendMessageHandler: async (message) => {
|
|
239
243
|
messages.push(message.body);
|
|
@@ -57,7 +57,13 @@ class TopicSuggesterTest extends test_utils_1.default {
|
|
|
57
57
|
{
|
|
58
58
|
key: 'scheduleShft',
|
|
59
59
|
label: 'Shift',
|
|
60
|
-
utterances: [
|
|
60
|
+
utterances: [
|
|
61
|
+
'shift',
|
|
62
|
+
'block my time',
|
|
63
|
+
'break',
|
|
64
|
+
'hours',
|
|
65
|
+
'schedule',
|
|
66
|
+
],
|
|
61
67
|
},
|
|
62
68
|
{
|
|
63
69
|
key: 'bookAppointment',
|
|
@@ -2,7 +2,11 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const topicDefinition = {
|
|
4
4
|
label: 'Cancel appointment',
|
|
5
|
-
utterances: [
|
|
5
|
+
utterances: [
|
|
6
|
+
'Cancel appointment',
|
|
7
|
+
'Can i cancel my appointment?',
|
|
8
|
+
'cancel',
|
|
9
|
+
],
|
|
6
10
|
script: ['how are you?', 'Lemme find your appointment!'],
|
|
7
11
|
};
|
|
8
12
|
exports.default = topicDefinition;
|
package/build/__tests__/testDirsAndFiles/skill/build/conversations/cancelAppointment.topic.js
CHANGED
|
@@ -2,7 +2,11 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const topicDefinition = {
|
|
4
4
|
label: 'Cancel appointment',
|
|
5
|
-
utterances: [
|
|
5
|
+
utterances: [
|
|
6
|
+
'Cancel appointment',
|
|
7
|
+
'Can i cancel my appointment?',
|
|
8
|
+
'cancel',
|
|
9
|
+
],
|
|
6
10
|
script: ['how are you?', 'Lemme find your appointment!'],
|
|
7
11
|
};
|
|
8
12
|
exports.default = topicDefinition;
|
|
@@ -6,7 +6,10 @@ const topicDefinition = {
|
|
|
6
6
|
script: [
|
|
7
7
|
'what is your favorite color?',
|
|
8
8
|
async (options) => {
|
|
9
|
-
const answer = await options.ui.prompt({
|
|
9
|
+
const answer = await options.ui.prompt({
|
|
10
|
+
type: 'text',
|
|
11
|
+
isRequired: true,
|
|
12
|
+
});
|
|
10
13
|
options.ui.renderLine(answer);
|
|
11
14
|
return {
|
|
12
15
|
transitionConversationTo: 'discovery',
|
|
@@ -6,7 +6,10 @@ const topicDefinition = {
|
|
|
6
6
|
script: [
|
|
7
7
|
'what is your favorite color?',
|
|
8
8
|
async (options) => {
|
|
9
|
-
const answer = await options.ui.prompt({
|
|
9
|
+
const answer = await options.ui.prompt({
|
|
10
|
+
type: 'text',
|
|
11
|
+
isRequired: true,
|
|
12
|
+
});
|
|
10
13
|
options.ui.renderLine(answer);
|
|
11
14
|
return {
|
|
12
15
|
transitionConversationTo: 'discovery',
|
|
@@ -2,7 +2,11 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const topicDefinition = {
|
|
4
4
|
label: 'Cancel appointment',
|
|
5
|
-
utterances: [
|
|
5
|
+
utterances: [
|
|
6
|
+
'Cancel appointment',
|
|
7
|
+
'Can i cancel my appointment?',
|
|
8
|
+
'cancel',
|
|
9
|
+
],
|
|
6
10
|
script: [
|
|
7
11
|
() => {
|
|
8
12
|
throw new Error('In Script');
|
|
@@ -2,8 +2,8 @@ import { default as SchemaEntity } from '@sprucelabs/schema';
|
|
|
2
2
|
import * as SpruceSchema from '@sprucelabs/schema';
|
|
3
3
|
export declare namespace SpruceErrors.Conversation {
|
|
4
4
|
interface TopicNotFound {
|
|
5
|
-
suppliedTopic: string;
|
|
6
|
-
validTopics: string[];
|
|
5
|
+
'suppliedTopic': string;
|
|
6
|
+
'validTopics': string[];
|
|
7
7
|
}
|
|
8
8
|
interface TopicNotFoundSchema extends SpruceSchema.Schema {
|
|
9
9
|
id: 'topicNotFound';
|
|
@@ -11,13 +11,13 @@ export declare namespace SpruceErrors.Conversation {
|
|
|
11
11
|
name: 'Topic not found';
|
|
12
12
|
fields: {
|
|
13
13
|
/** . */
|
|
14
|
-
suppliedTopic: {
|
|
14
|
+
'suppliedTopic': {
|
|
15
15
|
type: 'text';
|
|
16
16
|
isRequired: true;
|
|
17
17
|
options: undefined;
|
|
18
18
|
};
|
|
19
19
|
/** . */
|
|
20
|
-
validTopics: {
|
|
20
|
+
'validTopics': {
|
|
21
21
|
type: 'text';
|
|
22
22
|
isRequired: true;
|
|
23
23
|
isArray: true;
|
|
@@ -40,7 +40,7 @@ export declare namespace SpruceErrors.Conversation {
|
|
|
40
40
|
}
|
|
41
41
|
export declare namespace SpruceErrors.Conversation {
|
|
42
42
|
interface MissingDependencies {
|
|
43
|
-
dependencies: string[];
|
|
43
|
+
'dependencies': string[];
|
|
44
44
|
}
|
|
45
45
|
interface MissingDependenciesSchema extends SpruceSchema.Schema {
|
|
46
46
|
id: 'missingDependencies';
|
|
@@ -48,7 +48,7 @@ export declare namespace SpruceErrors.Conversation {
|
|
|
48
48
|
name: 'Missing dependencies';
|
|
49
49
|
fields: {
|
|
50
50
|
/** . */
|
|
51
|
-
dependencies: {
|
|
51
|
+
'dependencies': {
|
|
52
52
|
type: 'text';
|
|
53
53
|
isRequired: true;
|
|
54
54
|
isArray: true;
|
|
@@ -61,7 +61,7 @@ export declare namespace SpruceErrors.Conversation {
|
|
|
61
61
|
export declare namespace SpruceErrors.Conversation {
|
|
62
62
|
interface InvalidTopic {
|
|
63
63
|
/** . The script that I was attempting to load. Ends in .topic */
|
|
64
|
-
topicScript: string;
|
|
64
|
+
'topicScript': string;
|
|
65
65
|
}
|
|
66
66
|
interface InvalidTopicSchema extends SpruceSchema.Schema {
|
|
67
67
|
id: 'invalidTopic';
|
|
@@ -69,7 +69,7 @@ export declare namespace SpruceErrors.Conversation {
|
|
|
69
69
|
name: 'Invalid topic';
|
|
70
70
|
fields: {
|
|
71
71
|
/** . The script that I was attempting to load. Ends in .topic */
|
|
72
|
-
topicScript: {
|
|
72
|
+
'topicScript': {
|
|
73
73
|
type: 'text';
|
|
74
74
|
isRequired: true;
|
|
75
75
|
hint: 'The script that I was attempting to load. Ends in .topic';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { SpruceErrors } from "./errors.types";
|
|
2
|
+
import { ErrorOptions as ISpruceErrorOptions } from "@sprucelabs/error";
|
|
3
3
|
export interface TopicNotFoundErrorOptions extends SpruceErrors.Conversation.TopicNotFound, ISpruceErrorOptions {
|
|
4
4
|
code: 'TOPIC_NOT_FOUND';
|
|
5
5
|
}
|
|
@@ -13,9 +13,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
13
13
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
14
14
|
});
|
|
15
15
|
};
|
|
16
|
+
import { MercuryFixture } from '@sprucelabs/spruce-test-fixtures';
|
|
16
17
|
import { test, assert } from '@sprucelabs/test-utils';
|
|
17
18
|
import AbstractConversationTest from '../../tests/AbstractConversationTest.js';
|
|
18
|
-
import { MercuryFixture } from '@sprucelabs/spruce-test-fixtures';
|
|
19
19
|
MercuryFixture.setShouldRequireLocalListeners(false);
|
|
20
20
|
export default class KillingASkillTest extends AbstractConversationTest {
|
|
21
21
|
static killingASkillKillsConversation() {
|
|
@@ -14,11 +14,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
14
14
|
});
|
|
15
15
|
};
|
|
16
16
|
import { eventResponseUtil } from '@sprucelabs/spruce-event-utils';
|
|
17
|
+
import { MercuryFixture } from '@sprucelabs/spruce-test-fixtures';
|
|
17
18
|
import { test, assert, generateId } from '@sprucelabs/test-utils';
|
|
18
19
|
import { errorAssert } from '@sprucelabs/test-utils';
|
|
19
20
|
import plugin from '../../plugins/conversation.plugin.js';
|
|
20
21
|
import AbstractConversationTest from '../../tests/AbstractConversationTest.js';
|
|
21
|
-
import { MercuryFixture } from '@sprucelabs/spruce-test-fixtures';
|
|
22
22
|
MercuryFixture.setShouldRequireLocalListeners(false);
|
|
23
23
|
export default class RegisteringConversationsOnBootTest extends AbstractConversationTest {
|
|
24
24
|
static throwsWhenExecutingIfEventPluginMissing() {
|
|
@@ -49,7 +49,9 @@ export default class RegisteringConversationsOnBootTest extends AbstractConversa
|
|
|
49
49
|
bootSkill: { get: () => super.bootSkill }
|
|
50
50
|
});
|
|
51
51
|
return __awaiter(this, void 0, void 0, function* () {
|
|
52
|
-
const { skill } = yield _super.bootSkill.call(this, {
|
|
52
|
+
const { skill } = yield _super.bootSkill.call(this, {
|
|
53
|
+
shouldSuppressBootErrors: true,
|
|
54
|
+
});
|
|
53
55
|
assert.isFalse(skill.isRunning());
|
|
54
56
|
this.clearSkillBootErrors();
|
|
55
57
|
});
|
|
@@ -14,9 +14,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
14
14
|
});
|
|
15
15
|
};
|
|
16
16
|
import { eventResponseUtil } from '@sprucelabs/spruce-event-utils';
|
|
17
|
+
import { MercuryFixture } from '@sprucelabs/spruce-test-fixtures';
|
|
17
18
|
import { test, assert } from '@sprucelabs/test-utils';
|
|
18
19
|
import AbstractConversationTest from '../../tests/AbstractConversationTest.js';
|
|
19
|
-
import { MercuryFixture } from '@sprucelabs/spruce-test-fixtures';
|
|
20
20
|
MercuryFixture.setShouldRequireLocalListeners(false);
|
|
21
21
|
export default class RespondingToMessagesTest extends AbstractConversationTest {
|
|
22
22
|
static beforeEach() {
|
|
@@ -57,7 +57,10 @@ class TopicCoordinatorTest extends AbstractConversationTest {
|
|
|
57
57
|
}
|
|
58
58
|
static respondsWithSuggestedTopicsToFirstMessage() {
|
|
59
59
|
return __awaiter(this, void 0, void 0, function* () {
|
|
60
|
-
const results = yield this.coordinator.handleMessage(this.buildMessage({
|
|
60
|
+
const results = yield this.coordinator.handleMessage(this.buildMessage({
|
|
61
|
+
body: 'help me book!',
|
|
62
|
+
source: { personId: '1234' },
|
|
63
|
+
}));
|
|
61
64
|
assert.isArray(results.suggestedTopics);
|
|
62
65
|
assert.isLength(results.suggestedTopics, 3);
|
|
63
66
|
});
|
|
@@ -69,7 +72,10 @@ class TopicCoordinatorTest extends AbstractConversationTest {
|
|
|
69
72
|
sendMessageHandler: () => __awaiter(this, void 0, void 0, function* () { }),
|
|
70
73
|
getContext: () => this.skillContext,
|
|
71
74
|
});
|
|
72
|
-
const results = yield coordinator.handleMessage(this.buildMessage({
|
|
75
|
+
const results = yield coordinator.handleMessage(this.buildMessage({
|
|
76
|
+
body: 'help me book!',
|
|
77
|
+
source: { personId: '1234' },
|
|
78
|
+
}));
|
|
73
79
|
assert.isArray(results.suggestedTopics);
|
|
74
80
|
assert.isLength(results.suggestedTopics, 0);
|
|
75
81
|
});
|
|
@@ -122,19 +128,28 @@ class TopicCoordinatorTest extends AbstractConversationTest {
|
|
|
122
128
|
assert.isEqual((_a = this.sentMessages[0]) === null || _a === void 0 ? void 0 : _a.body, 'string 1');
|
|
123
129
|
assert.isEqual((_b = this.sentMessages[1]) === null || _b === void 0 ? void 0 : _b.body, 'prompt 1');
|
|
124
130
|
this.sentMessages = [];
|
|
125
|
-
yield this.coordinator.handleMessage(this.buildMessage({
|
|
131
|
+
yield this.coordinator.handleMessage(this.buildMessage({
|
|
132
|
+
body: 'answer 1',
|
|
133
|
+
source: { personId: '1234' },
|
|
134
|
+
}), 'mixedStringsAndCallbacks');
|
|
126
135
|
yield this.wait(100);
|
|
127
136
|
assert.isLength(this.sentMessages, 3);
|
|
128
137
|
assert.isEqual((_c = this.sentMessages[0]) === null || _c === void 0 ? void 0 : _c.body, 'answer 1');
|
|
129
138
|
assert.isEqual((_d = this.sentMessages[1]) === null || _d === void 0 ? void 0 : _d.body, 'string 2');
|
|
130
139
|
assert.isEqual((_e = this.sentMessages[2]) === null || _e === void 0 ? void 0 : _e.body, 'prompt 2');
|
|
131
140
|
this.sentMessages = [];
|
|
132
|
-
yield this.coordinator.handleMessage(this.buildMessage({
|
|
141
|
+
yield this.coordinator.handleMessage(this.buildMessage({
|
|
142
|
+
body: 'answer 2',
|
|
143
|
+
source: { personId: '1234' },
|
|
144
|
+
}), 'mixedStringsAndCallbacks');
|
|
133
145
|
assert.isLength(this.sentMessages, 2);
|
|
134
146
|
assert.isEqual((_f = this.sentMessages[0]) === null || _f === void 0 ? void 0 : _f.body, 'answer 2');
|
|
135
147
|
assert.isEqual((_g = this.sentMessages[1]) === null || _g === void 0 ? void 0 : _g.body, 'and done');
|
|
136
148
|
this.sentMessages = [];
|
|
137
|
-
yield this.coordinator.handleMessage(this.buildMessage({
|
|
149
|
+
yield this.coordinator.handleMessage(this.buildMessage({
|
|
150
|
+
body: 'answer 1',
|
|
151
|
+
source: { personId: '1234' },
|
|
152
|
+
}), 'mixedStringsAndCallbacks');
|
|
138
153
|
yield this.wait(100);
|
|
139
154
|
assert.isLength(this.sentMessages, 2);
|
|
140
155
|
assert.isEqual((_h = this.sentMessages[0]) === null || _h === void 0 ? void 0 : _h.body, 'string 1');
|
|
@@ -143,7 +158,10 @@ class TopicCoordinatorTest extends AbstractConversationTest {
|
|
|
143
158
|
}
|
|
144
159
|
static passesThroughContextGetter(context) {
|
|
145
160
|
return __awaiter(this, void 0, void 0, function* () {
|
|
146
|
-
yield this.coordinator.handleMessage(this.buildMessage({
|
|
161
|
+
yield this.coordinator.handleMessage(this.buildMessage({
|
|
162
|
+
body: 'answer 2',
|
|
163
|
+
source: { personId: '1234' },
|
|
164
|
+
}), 'bookAppointment');
|
|
147
165
|
this.skillContext = context;
|
|
148
166
|
const player = this.coordinator.getPlayer();
|
|
149
167
|
assert.isTruthy(player);
|
|
@@ -23,7 +23,9 @@ export default class TextFieldTest extends AbstractGraphicsInterfaceTest {
|
|
|
23
23
|
type: 'email',
|
|
24
24
|
label: 'Tell me about your life.',
|
|
25
25
|
});
|
|
26
|
-
assert.doesInclude(this.sentMessages, {
|
|
26
|
+
assert.doesInclude(this.sentMessages, {
|
|
27
|
+
body: 'Tell me about your life.',
|
|
28
|
+
});
|
|
27
29
|
});
|
|
28
30
|
}
|
|
29
31
|
static noPromptSendsNoMessage() {
|
|
@@ -22,7 +22,9 @@ export default class TextFieldTest extends AbstractGraphicsInterfaceTest {
|
|
|
22
22
|
type: 'text',
|
|
23
23
|
label: 'Tell me about your life.',
|
|
24
24
|
});
|
|
25
|
-
assert.doesInclude(this.sentMessages, {
|
|
25
|
+
assert.doesInclude(this.sentMessages, {
|
|
26
|
+
body: 'Tell me about your life.',
|
|
27
|
+
});
|
|
26
28
|
});
|
|
27
29
|
}
|
|
28
30
|
static noPromptSendsNoMessage() {
|
|
@@ -13,8 +13,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
13
13
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
14
14
|
});
|
|
15
15
|
};
|
|
16
|
-
import { test, assert } from '@sprucelabs/test-utils';
|
|
17
|
-
import { errorAssert } from '@sprucelabs/test-utils';
|
|
16
|
+
import { test, assert, errorAssert } from '@sprucelabs/test-utils';
|
|
18
17
|
import AbstractConversationTest from '../../tests/AbstractConversationTest.js';
|
|
19
18
|
import ScriptTester, { END_OF_LINE, generateTransitionMessage, } from '../../tests/ScriptTester.js';
|
|
20
19
|
class ScriptTesterTest extends AbstractConversationTest {
|
|
@@ -260,7 +260,11 @@ export default class TopicScriptPlayerTest extends AbstractConversationTest {
|
|
|
260
260
|
return __awaiter(this, void 0, void 0, function* () {
|
|
261
261
|
const messages = [];
|
|
262
262
|
const remaining = { one: true, two: true, three: true };
|
|
263
|
-
const possibilities = [
|
|
263
|
+
const possibilities = [
|
|
264
|
+
'one',
|
|
265
|
+
'two',
|
|
266
|
+
'three',
|
|
267
|
+
];
|
|
264
268
|
const player = this.Player({
|
|
265
269
|
sendMessageHandler: (message) => __awaiter(this, void 0, void 0, function* () {
|
|
266
270
|
messages.push(message.body);
|
|
@@ -46,7 +46,13 @@ export default class TopicSuggesterTest extends AbstractSpruceTest {
|
|
|
46
46
|
{
|
|
47
47
|
key: 'scheduleShft',
|
|
48
48
|
label: 'Shift',
|
|
49
|
-
utterances: [
|
|
49
|
+
utterances: [
|
|
50
|
+
'shift',
|
|
51
|
+
'block my time',
|
|
52
|
+
'break',
|
|
53
|
+
'hours',
|
|
54
|
+
'schedule',
|
|
55
|
+
],
|
|
50
56
|
},
|
|
51
57
|
{
|
|
52
58
|
key: 'bookAppointment',
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
const topicDefinition = {
|
|
2
2
|
label: 'Cancel appointment',
|
|
3
|
-
utterances: [
|
|
3
|
+
utterances: [
|
|
4
|
+
'Cancel appointment',
|
|
5
|
+
'Can i cancel my appointment?',
|
|
6
|
+
'cancel',
|
|
7
|
+
],
|
|
4
8
|
script: ['how are you?', 'Lemme find your appointment!'],
|
|
5
9
|
};
|
|
6
10
|
export default topicDefinition;
|
package/build/esm/__tests__/testDirsAndFiles/skill/build/conversations/cancelAppointment.topic.js
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
const topicDefinition = {
|
|
2
2
|
label: 'Cancel appointment',
|
|
3
|
-
utterances: [
|
|
3
|
+
utterances: [
|
|
4
|
+
'Cancel appointment',
|
|
5
|
+
'Can i cancel my appointment?',
|
|
6
|
+
'cancel',
|
|
7
|
+
],
|
|
4
8
|
script: ['how are you?', 'Lemme find your appointment!'],
|
|
5
9
|
};
|
|
6
10
|
export default topicDefinition;
|
package/build/esm/__tests__/testDirsAndFiles/skill/build/conversations/favoriteColor.topic.js
CHANGED
|
@@ -13,7 +13,10 @@ const topicDefinition = {
|
|
|
13
13
|
script: [
|
|
14
14
|
'what is your favorite color?',
|
|
15
15
|
(options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
16
|
-
const answer = yield options.ui.prompt({
|
|
16
|
+
const answer = yield options.ui.prompt({
|
|
17
|
+
type: 'text',
|
|
18
|
+
isRequired: true,
|
|
19
|
+
});
|
|
17
20
|
options.ui.renderLine(answer);
|
|
18
21
|
return {
|
|
19
22
|
transitionConversationTo: 'discovery',
|