@sprucelabs/spruce-conversation-plugin 48.0.5 → 49.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/build/__tests__/behavioral/RespondingToMessages.test.js +2 -9
- package/build/__tests__/implementation/TopicScriptPlayer.test.js +1 -1
- package/build/conversations/ConversationCoordinator.js +12 -1
- package/build/esm/plugins/conversation.plugin.js +8 -6
- package/build/interfaces/fieldHandlers/EmailFieldHandler.js +1 -7
- package/build/plugins/conversation.plugin.js +18 -7
- package/build/tests/AbstractConversationTest.js +1 -4
- package/build/tests/messageTest.utility.js +1 -8
- package/build/topics/TopicScriptPlayer.js +1 -5
- package/package.json +19 -19
- package/tsconfig.json +7 -4
|
@@ -92,17 +92,10 @@ class RespondingToMessagesTest extends AbstractConversationTest_1.default {
|
|
|
92
92
|
const client = await this.boot();
|
|
93
93
|
const results = await client.emit('did-message::v2020_12_25', {
|
|
94
94
|
target: {},
|
|
95
|
-
payload: {
|
|
96
|
-
...options,
|
|
97
|
-
message: this.buildMessage({
|
|
98
|
-
body: 'I wanna book an appointment!',
|
|
99
|
-
source: {
|
|
95
|
+
payload: Object.assign(Object.assign({}, options), { message: this.buildMessage(Object.assign({ body: 'I wanna book an appointment!', source: {
|
|
100
96
|
isCore: null,
|
|
101
97
|
personId: '12345',
|
|
102
|
-
},
|
|
103
|
-
...options === null || options === void 0 ? void 0 : options.message,
|
|
104
|
-
}),
|
|
105
|
-
},
|
|
98
|
+
} }, options === null || options === void 0 ? void 0 : options.message)) }),
|
|
106
99
|
});
|
|
107
100
|
return results;
|
|
108
101
|
}
|
|
@@ -341,7 +341,7 @@ class TopicScriptPlayerTest extends AbstractConversationTest_1.default {
|
|
|
341
341
|
});
|
|
342
342
|
}
|
|
343
343
|
static async sendMessage(player, message) {
|
|
344
|
-
return player.handleMessage(this.buildMessage({ source: { personId: '1234' },
|
|
344
|
+
return player.handleMessage(this.buildMessage(Object.assign({ source: { personId: '1234' } }, message)));
|
|
345
345
|
}
|
|
346
346
|
}
|
|
347
347
|
__decorate([
|
|
@@ -1,4 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
+
var t = {};
|
|
4
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
+
t[p] = s[p];
|
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
+
t[p[i]] = s[p[i]];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
2
13
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
14
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
15
|
};
|
|
@@ -48,7 +59,7 @@ class ConversationCoordinator {
|
|
|
48
59
|
validTopics: this.topics.map((t) => t.key),
|
|
49
60
|
});
|
|
50
61
|
}
|
|
51
|
-
const
|
|
62
|
+
const target = __rest(message.source, []);
|
|
52
63
|
delete target.isCore;
|
|
53
64
|
if (!this.player || this.lastTopic !== matchedTopic.key) {
|
|
54
65
|
this.lastTopic = matchedTopic.key;
|
|
@@ -45,7 +45,7 @@ export class ConversationFeature {
|
|
|
45
45
|
const topics = yield this.loadTopics();
|
|
46
46
|
if (topics.length === 0) {
|
|
47
47
|
this.log.info('No Topics found to test. Testing cancelled...');
|
|
48
|
-
this.notifyBooted();
|
|
48
|
+
yield this.notifyBooted();
|
|
49
49
|
}
|
|
50
50
|
else {
|
|
51
51
|
yield this.startScriptTesterAndNotifyBoot(topics);
|
|
@@ -56,7 +56,7 @@ export class ConversationFeature {
|
|
|
56
56
|
const client = yield this.connectToApi();
|
|
57
57
|
yield this.startConversationCoordinator(client);
|
|
58
58
|
this.log.info('Conversations loaded. Ready to chat when you are. 🤘');
|
|
59
|
-
this.notifyBooted();
|
|
59
|
+
yield this.notifyBooted();
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
62
|
catch (err) {
|
|
@@ -73,9 +73,11 @@ export class ConversationFeature {
|
|
|
73
73
|
}
|
|
74
74
|
notifyBooted() {
|
|
75
75
|
var _a;
|
|
76
|
-
this
|
|
77
|
-
|
|
78
|
-
|
|
76
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
77
|
+
this.isExecuting = false;
|
|
78
|
+
this._isBooted = true;
|
|
79
|
+
yield ((_a = this.bootHandler) === null || _a === void 0 ? void 0 : _a.call(this));
|
|
80
|
+
});
|
|
79
81
|
}
|
|
80
82
|
startScriptTesterAndNotifyBoot(topics) {
|
|
81
83
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -100,7 +102,7 @@ export class ConversationFeature {
|
|
|
100
102
|
}
|
|
101
103
|
}));
|
|
102
104
|
});
|
|
103
|
-
this.notifyBooted();
|
|
105
|
+
yield this.notifyBooted();
|
|
104
106
|
yield promise;
|
|
105
107
|
});
|
|
106
108
|
}
|
|
@@ -24,13 +24,7 @@ class EmailFieldHandler {
|
|
|
24
24
|
const errs = emailField.validate(value);
|
|
25
25
|
if (errs.length > 0) {
|
|
26
26
|
if (attempt === 0) {
|
|
27
|
-
return this.go({
|
|
28
|
-
...options,
|
|
29
|
-
definition: {
|
|
30
|
-
...options.definition,
|
|
31
|
-
label: random_utility_1.default.rand(this.repairs),
|
|
32
|
-
},
|
|
33
|
-
}, attempt + 1);
|
|
27
|
+
return this.go(Object.assign(Object.assign({}, options), { definition: Object.assign(Object.assign({}, options.definition), { label: random_utility_1.default.rand(this.repairs) }) }), attempt + 1);
|
|
34
28
|
}
|
|
35
29
|
else {
|
|
36
30
|
throw new SpruceError_1.default({ code: 'ABORT' });
|
|
@@ -1,4 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
+
var t = {};
|
|
4
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
+
t[p] = s[p];
|
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
+
t[p[i]] = s[p[i]];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
2
13
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
14
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
15
|
};
|
|
@@ -30,7 +41,7 @@ class ConversationFeature {
|
|
|
30
41
|
const topics = await this.loadTopics();
|
|
31
42
|
if (topics.length === 0) {
|
|
32
43
|
this.log.info('No Topics found to test. Testing cancelled...');
|
|
33
|
-
this.notifyBooted();
|
|
44
|
+
await this.notifyBooted();
|
|
34
45
|
}
|
|
35
46
|
else {
|
|
36
47
|
await this.startScriptTesterAndNotifyBoot(topics);
|
|
@@ -41,7 +52,7 @@ class ConversationFeature {
|
|
|
41
52
|
const client = await this.connectToApi();
|
|
42
53
|
await this.startConversationCoordinator(client);
|
|
43
54
|
this.log.info('Conversations loaded. Ready to chat when you are. 🤘');
|
|
44
|
-
this.notifyBooted();
|
|
55
|
+
await this.notifyBooted();
|
|
45
56
|
}
|
|
46
57
|
}
|
|
47
58
|
catch (err) {
|
|
@@ -53,11 +64,11 @@ class ConversationFeature {
|
|
|
53
64
|
const topics = await TopicLoader_1.default.loadTopics(this.skill.activeDir);
|
|
54
65
|
return topics;
|
|
55
66
|
}
|
|
56
|
-
notifyBooted() {
|
|
67
|
+
async notifyBooted() {
|
|
57
68
|
var _a;
|
|
58
69
|
this.isExecuting = false;
|
|
59
70
|
this._isBooted = true;
|
|
60
|
-
(_a = this.bootHandler) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
71
|
+
await ((_a = this.bootHandler) === null || _a === void 0 ? void 0 : _a.call(this));
|
|
61
72
|
}
|
|
62
73
|
async startScriptTesterAndNotifyBoot(topics) {
|
|
63
74
|
const tester = await ScriptTester_1.default.Tester({ topics });
|
|
@@ -81,7 +92,7 @@ class ConversationFeature {
|
|
|
81
92
|
}
|
|
82
93
|
});
|
|
83
94
|
});
|
|
84
|
-
this.notifyBooted();
|
|
95
|
+
await this.notifyBooted();
|
|
85
96
|
await promise;
|
|
86
97
|
}
|
|
87
98
|
async startConversationCoordinator(client) {
|
|
@@ -100,7 +111,7 @@ class ConversationFeature {
|
|
|
100
111
|
topicLookupPath: this.skill.activeDir,
|
|
101
112
|
sendMessageHandler: async (message) => {
|
|
102
113
|
try {
|
|
103
|
-
const { target,
|
|
114
|
+
const { target } = message, values = __rest(message, ["target"]);
|
|
104
115
|
const results = await client.emit('send-message::v2020_12_25', {
|
|
105
116
|
target,
|
|
106
117
|
payload: {
|
|
@@ -163,7 +174,7 @@ class ConversationFeature {
|
|
|
163
174
|
try {
|
|
164
175
|
this.skill.getFeatureByCode('event');
|
|
165
176
|
}
|
|
166
|
-
catch {
|
|
177
|
+
catch (_a) {
|
|
167
178
|
throw new SpruceError_1.default({
|
|
168
179
|
code: 'MISSING_DEPENDENCIES',
|
|
169
180
|
dependencies: ['event.plugin'],
|
|
@@ -27,10 +27,7 @@ class AbstractConversationTest extends spruce_test_fixtures_1.AbstractSpruceFixt
|
|
|
27
27
|
}
|
|
28
28
|
static async Skill(options) {
|
|
29
29
|
const { plugins = [spruce_event_plugin_1.plugin, conversation_plugin_1.default] } = options !== null && options !== void 0 ? options : {};
|
|
30
|
-
return super.Skill({
|
|
31
|
-
plugins,
|
|
32
|
-
...options,
|
|
33
|
-
});
|
|
30
|
+
return super.Skill(Object.assign({ plugins }, options));
|
|
34
31
|
}
|
|
35
32
|
static resolveTestPath(...pathAfterTestDirsAndFiles) {
|
|
36
33
|
return this.resolvePath(__dirname, '..', '__tests__', 'testDirsAndFiles', ...pathAfterTestDirsAndFiles);
|
|
@@ -2,14 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const messageTestUtility = {
|
|
4
4
|
buildMessage(values) {
|
|
5
|
-
return {
|
|
6
|
-
id: '1234',
|
|
7
|
-
dateCreated: new Date().getTime(),
|
|
8
|
-
target: {},
|
|
9
|
-
source: {},
|
|
10
|
-
classification: 'incoming',
|
|
11
|
-
...values,
|
|
12
|
-
};
|
|
5
|
+
return Object.assign({ id: '1234', dateCreated: new Date().getTime(), target: {}, source: {}, classification: 'incoming' }, values);
|
|
13
6
|
},
|
|
14
7
|
};
|
|
15
8
|
exports.default = messageTestUtility;
|
|
@@ -136,11 +136,7 @@ class TopicScriptPlayer {
|
|
|
136
136
|
return random_utility_1.default.rand(line);
|
|
137
137
|
}
|
|
138
138
|
async sendMessage(message) {
|
|
139
|
-
await this.sendMessageHandler({
|
|
140
|
-
...message,
|
|
141
|
-
target: this.target,
|
|
142
|
-
classification: 'transactional',
|
|
143
|
-
});
|
|
139
|
+
await this.sendMessageHandler(Object.assign(Object.assign({}, message), { target: this.target, classification: 'transactional' }));
|
|
144
140
|
}
|
|
145
141
|
}
|
|
146
142
|
exports.TopicScriptPlayer = TopicScriptPlayer;
|
package/package.json
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"@types/inquirer"
|
|
14
14
|
]
|
|
15
15
|
},
|
|
16
|
-
"version": "
|
|
16
|
+
"version": "49.0.0",
|
|
17
17
|
"files": [
|
|
18
18
|
"build/**/*",
|
|
19
19
|
"!build/__tests__",
|
|
@@ -64,15 +64,15 @@
|
|
|
64
64
|
},
|
|
65
65
|
"dependencies": {
|
|
66
66
|
"@nlpjs/nlu": "^4.23.5",
|
|
67
|
-
"@sprucelabs/error": "^5.0.
|
|
68
|
-
"@sprucelabs/mercury-core-events": "^12.0.
|
|
69
|
-
"@sprucelabs/schema": "^28.4.
|
|
70
|
-
"@sprucelabs/spruce-core-schemas": "^34.2.
|
|
71
|
-
"@sprucelabs/spruce-event-plugin": "^
|
|
72
|
-
"@sprucelabs/spruce-event-utils": "^27.0.
|
|
73
|
-
"@sprucelabs/spruce-skill-booter": "^
|
|
74
|
-
"@sprucelabs/spruce-skill-utils": "^26.4.
|
|
75
|
-
"@sprucelabs/spruce-test-fixtures": "^
|
|
67
|
+
"@sprucelabs/error": "^5.0.503",
|
|
68
|
+
"@sprucelabs/mercury-core-events": "^12.0.175",
|
|
69
|
+
"@sprucelabs/schema": "^28.4.33",
|
|
70
|
+
"@sprucelabs/spruce-core-schemas": "^34.2.80",
|
|
71
|
+
"@sprucelabs/spruce-event-plugin": "^49.0.0",
|
|
72
|
+
"@sprucelabs/spruce-event-utils": "^27.0.152",
|
|
73
|
+
"@sprucelabs/spruce-skill-booter": "^49.0.0",
|
|
74
|
+
"@sprucelabs/spruce-skill-utils": "^26.4.55",
|
|
75
|
+
"@sprucelabs/spruce-test-fixtures": "^49.0.0",
|
|
76
76
|
"fuzzyset": "^1.0.7",
|
|
77
77
|
"globby": "^11.0.4",
|
|
78
78
|
"inquirer": "^8.2.4",
|
|
@@ -80,27 +80,27 @@
|
|
|
80
80
|
"random": "^3.0.6"
|
|
81
81
|
},
|
|
82
82
|
"devDependencies": {
|
|
83
|
-
"@sprucelabs/esm-postbuild": "^1.0.
|
|
84
|
-
"@sprucelabs/jest-json-reporter": "^6.0.
|
|
85
|
-
"@sprucelabs/mercury-client": "^31.0.
|
|
86
|
-
"@sprucelabs/resolve-path-aliases": "^1.1.
|
|
83
|
+
"@sprucelabs/esm-postbuild": "^1.0.568",
|
|
84
|
+
"@sprucelabs/jest-json-reporter": "^6.0.461",
|
|
85
|
+
"@sprucelabs/mercury-client": "^31.0.173",
|
|
86
|
+
"@sprucelabs/resolve-path-aliases": "^1.1.91",
|
|
87
87
|
"@sprucelabs/semantic-release": "^4.0.8",
|
|
88
|
-
"@sprucelabs/test": "^7.7.
|
|
89
|
-
"@sprucelabs/test-utils": "^3.1.
|
|
88
|
+
"@sprucelabs/test": "^7.7.353",
|
|
89
|
+
"@sprucelabs/test-utils": "^3.1.72",
|
|
90
90
|
"@types/fuzzyset": "^1.0.4",
|
|
91
91
|
"@types/inquirer": "^8.2.1",
|
|
92
92
|
"@types/node": "17.0.5",
|
|
93
93
|
"chokidar-cli": "^3.0.0",
|
|
94
94
|
"concurrently": "^7.3.0",
|
|
95
95
|
"eslint": "^8.23.0",
|
|
96
|
-
"eslint-config-spruce": "^10.11.
|
|
96
|
+
"eslint-config-spruce": "^10.11.4",
|
|
97
97
|
"jest": "^29.0.1",
|
|
98
98
|
"jest-circus": "^29.0.1",
|
|
99
99
|
"prettier": "^2.7.1",
|
|
100
100
|
"ts-node": "^10.9.1",
|
|
101
101
|
"tsc-watch": "^5.0.3",
|
|
102
102
|
"tsconfig-paths": "^4.1.0",
|
|
103
|
-
"typescript": "4.
|
|
103
|
+
"typescript": "^4.8.2"
|
|
104
104
|
},
|
|
105
105
|
"jest": {
|
|
106
106
|
"maxWorkers": 2,
|
|
@@ -119,5 +119,5 @@
|
|
|
119
119
|
"^#spruce/(.*)$": "<rootDir>/build/.spruce/$1"
|
|
120
120
|
}
|
|
121
121
|
},
|
|
122
|
-
"gitHead": "
|
|
122
|
+
"gitHead": "1cea752895f2216052e5bed10e3c297600ff8ab1"
|
|
123
123
|
}
|
package/tsconfig.json
CHANGED
|
@@ -1,24 +1,27 @@
|
|
|
1
1
|
{
|
|
2
2
|
"compilerOptions": {
|
|
3
|
+
"skipLibCheck": true,
|
|
3
4
|
"module": "commonjs",
|
|
4
5
|
"esModuleInterop": true,
|
|
5
|
-
"target": "
|
|
6
|
+
"target": "ES2017",
|
|
6
7
|
"lib": [
|
|
7
8
|
"DOM",
|
|
8
|
-
"
|
|
9
|
+
"es2017",
|
|
10
|
+
"ES2020"
|
|
9
11
|
],
|
|
10
12
|
"declaration": true,
|
|
11
13
|
"noImplicitAny": true,
|
|
14
|
+
"allowJs": true,
|
|
12
15
|
"forceConsistentCasingInFileNames": true,
|
|
13
16
|
"noImplicitReturns": true,
|
|
14
17
|
"strict": true,
|
|
15
18
|
"noUnusedLocals": true,
|
|
16
19
|
"resolveJsonModule": true,
|
|
17
20
|
"moduleResolution": "node",
|
|
18
|
-
"experimentalDecorators": true,
|
|
19
21
|
"sourceMap": false,
|
|
20
22
|
"outDir": "build",
|
|
21
23
|
"baseUrl": "src",
|
|
24
|
+
"experimentalDecorators": true,
|
|
22
25
|
"paths": {
|
|
23
26
|
"#spruce/*": [
|
|
24
27
|
".spruce/*"
|
|
@@ -36,4 +39,4 @@
|
|
|
36
39
|
"build",
|
|
37
40
|
"esm"
|
|
38
41
|
]
|
|
39
|
-
}
|
|
42
|
+
}
|