@tiledesk/tiledesk-server 3.0.1 → 3.2.1
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/.circleci/config.yml +1 -1
- package/CHANGELOG.md +47 -0
- package/Dockerfile +3 -2
- package/Dockerfile-en +3 -2
- package/Dockerfile-jobs +3 -2
- package/Dockerfile-profiler +3 -2
- package/README.md +15 -0
- package/app.js +12 -1
- package/bin/quota-reset +68 -0
- package/bin/quota-restore +86 -0
- package/channels/chat21/chat21Handler.js +50 -34
- package/channels/chat21/chat21JoinTracker.js +43 -0
- package/config/database.js +5 -5
- package/config/native_mcp/native_mcp_servers.json +1 -0
- package/controllers/chatbot.controller.js +80 -27
- package/controllers/intents.controller.js +42 -0
- package/docs/superpowers/plans/2026-09-15-webhook-chatbot-hitl-chat21-ionic.md +468 -0
- package/docs/superpowers/plans/2026-09-15-webhook-chatbot-hitl-design-studio.md +1349 -0
- package/docs/superpowers/plans/2026-09-15-webhook-chatbot-hitl-server.md +1694 -0
- package/docs/superpowers/plans/2026-09-15-webhook-chatbot-hitl-tybot.md +789 -0
- package/docs/superpowers/plans/2026-09-29-hitl-known-limits-server.md +83 -0
- package/docs/superpowers/plans/2026-09-29-hitl-known-limits-tybot.md +76 -0
- package/docs/superpowers/plans/2026-09-29-hitl-participant-removal-chat21-ionic.md +97 -0
- package/docs/superpowers/plans/2026-09-29-hitl-participant-removal-design-studio.md +72 -0
- package/docs/superpowers/plans/2026-09-29-hitl-participant-removal-server.md +223 -0
- package/docs/superpowers/plans/2026-09-29-hitl-participant-removal-tybot.md +121 -0
- package/docs/superpowers/plans/2026-09-29-hitl-pre-branch-ports.md +65 -0
- package/docs/superpowers/plans/2026-09-30-flow-start-points-design-studio.md +88 -0
- package/docs/superpowers/plans/2026-09-30-flow-start-points-server.md +103 -0
- package/docs/superpowers/plans/2026-09-30-flow-start-points-tybot.md +43 -0
- package/docs/superpowers/plans/2026-10-01-scheduled-start-point-design-studio.md +80 -0
- package/docs/superpowers/plans/2026-10-01-scheduled-start-point-runtime.md +39 -0
- package/docs/superpowers/plans/2026-10-01-scheduled-start-point-server.md +106 -0
- package/docs/superpowers/specs/2026-09-15-webhook-chatbot-hitl-design.md +715 -0
- package/docs/superpowers/specs/2026-09-30-flow-start-points-design.md +156 -0
- package/docs/superpowers/specs/2026-10-01-scheduled-start-point-design.md +303 -0
- package/docs/superpowers/todo/2026-09-14-webhook-chatbot-shared-code-fixes.md +191 -0
- package/event/botEvent.js +12 -1
- package/event/emailEvent.js +3 -0
- package/event/messageEvent.js +44 -0
- package/jobs.js +10 -0
- package/jobsManager.js +19 -0
- package/middleware/errorHandler.js +6 -2
- package/models/analyticResult.js +1 -1
- package/models/channelConstants.js +3 -2
- package/models/dataTable.js +16 -0
- package/models/location.js +6 -12
- package/models/quotaUsage.js +71 -0
- package/models/request.js +71 -61
- package/models/requestSnapshot.js +12 -0
- package/models/routerLogger.js +1 -1
- package/models/webhook.js +44 -0
- package/package.json +9 -7
- package/pubmodules/emailNotification/requestNotification.js +14 -22
- package/pubmodules/events/test/eventRoute.js +7 -6
- package/pubmodules/rules/conciergeBot.js +9 -4
- package/routes/auth.js +1 -12
- package/routes/campaigns.js +0 -13
- package/routes/dataTable.js +23 -3
- package/routes/faq_kb.js +12 -1
- package/routes/messagesRoot.js +0 -1
- package/routes/quotes.js +38 -1
- package/routes/request.js +81 -5
- package/routes/users.js +0 -1
- package/routes/webhook.js +160 -8
- package/routes/webhooks.js +276 -6
- package/routes/widgetLoader.js +6 -3
- package/services/QuoteManager.js +77 -16
- package/services/aiService.js +1 -1
- package/services/chatbotService.js +55 -1
- package/services/dataTableService.js +436 -42
- package/services/departmentService.js +60 -43
- package/services/dolphinSchedulerClient.js +116 -0
- package/services/emailService.js +6 -1
- package/services/hitlParticipantListener.js +260 -0
- package/services/participantInviteService.js +302 -0
- package/services/participantRemoveService.js +79 -0
- package/services/quotaSnapshotService.js +1167 -0
- package/services/requestService.js +102 -144
- package/services/scheduledStart/dolphinBackend.js +246 -0
- package/services/scheduledStart/schedulerBackend.js +101 -0
- package/services/scheduledStart/schedulerServiceClient.js +41 -0
- package/services/scheduledStartPublishListener.js +186 -0
- package/services/scheduledStartRules.js +173 -0
- package/services/scheduledStartService.js +130 -0
- package/services/startPointCleanupListener.js +30 -0
- package/services/startPointService.js +158 -0
- package/services/testWsService.js +1 -4
- package/services/updateRequestSnapshotQueued.js +8 -9
- package/services/webhookConversationService.js +185 -0
- package/services/webhookSettingsValidator.js +61 -0
- package/template/email/checkpointReachedEmail.html +5 -0
- package/test/agentPromptsRoute.test.js +3 -2
- package/test/agentTokensQuota.js +237 -0
- package/test/botEventHitlFallback.js +19 -0
- package/test/chat21HandlerJoinWiring.js +59 -0
- package/test/dataTablesRoute.test.js +649 -2
- package/test/dateUtils.test.js +0 -3
- package/test/departmentService.js +8 -12
- package/test/{fileRoute.js → deprecated/_deprecated_fileRoute} +2 -2
- package/test/{kbsettingsRoute.js → deprecated/_deprecated_kbsettingsRoute} +3 -3
- package/test/faqRoute.js +6 -1
- package/test/faqkbRoute.js +14 -10
- package/test/faqkbV3Route.js +1 -1
- package/test/filepRoute.js +4 -50
- package/test/hitlParticipantListener.js +446 -0
- package/test/hitlQueueWiring.js +191 -0
- package/test/hitlWaitingReset.js +124 -0
- package/test/inviteParticipantsRoute.js +492 -0
- package/test/kbRoute.js +1 -1
- package/test/messageRoute.js +33 -21
- package/test/nativemcp.test.js +7 -1
- package/test/openaiRoute.js +2 -8
- package/test/publishFailLoud.test.js +414 -0
- package/test/quotaSnapshots.js +1044 -0
- package/test/removeParticipantsRoute.js +186 -0
- package/test/requestService.js +24 -16
- package/test/requestServiceRemoveParticipant.js +144 -0
- package/test/requestVisibility.test.js +186 -0
- package/test/scheduledStartFacade.js +184 -0
- package/test/scheduledStartHandover.js +95 -0
- package/test/scheduledStartPublish.js +320 -0
- package/test/scheduledStartRoute.js +163 -0
- package/test/scheduledStartRules.js +177 -0
- package/test/scheduledStartRun.js +299 -0
- package/test/scheduledStartSchedulerBackend.js +116 -0
- package/test/scheduledStartService.js +290 -0
- package/test/startPointsCleanup.js +69 -0
- package/test/startPointsRegression.js +169 -0
- package/test/startPointsRoute.js +158 -0
- package/test/webhookConversationRoute.js +347 -0
- package/test/webhookConversationService.js +261 -0
- package/test/webhookConversationTestUtils.js +55 -0
- package/utils/aiUtils.js +95 -1
- package/utils/dataTableUtils.js +99 -9
- package/utils/intentFieldNames.js +192 -0
- package/utils/quotaCliUtil.js +43 -0
- package/utils/requestVisibility.js +355 -0
- package/websocket/webSocketServer.js +36 -31
- /package/test/{imageRoute.js → deprecated/_deprecated_imageRoute} +0 -0
|
@@ -8,7 +8,7 @@ var assert = require('chai').assert;
|
|
|
8
8
|
var config = require('../config/database');
|
|
9
9
|
var mongoose = require('mongoose');
|
|
10
10
|
var winston = require('../config/winston');
|
|
11
|
-
|
|
11
|
+
const RoleConstants = require('../models/roleConstants');
|
|
12
12
|
var Project_user = require("../models/project_user");
|
|
13
13
|
var userService = require('../services/userService');
|
|
14
14
|
var departmentService = require('../services/departmentService');
|
|
@@ -41,13 +41,11 @@ describe('DepartmentService()', function () {
|
|
|
41
41
|
userService.signup(email + '3', pwd, "Test Firstname3", "Test lastname3").then(function (savedUser3) {
|
|
42
42
|
projectService.create("createWithAssignedDepartment", savedUser._id).then(function (savedProject) {
|
|
43
43
|
|
|
44
|
-
|
|
45
|
-
|
|
46
44
|
var pu1 = new Project_user({
|
|
47
45
|
// _id: new mongoose.Types.ObjectId(),
|
|
48
46
|
id_project: savedProject._id,
|
|
49
47
|
id_user: savedUser2._id,
|
|
50
|
-
role:
|
|
48
|
+
role: RoleConstants.AGENT,
|
|
51
49
|
roleType : RoleConstants.TYPE_AGENTS,
|
|
52
50
|
user_available: true,
|
|
53
51
|
createdBy: savedUser2._id,
|
|
@@ -57,12 +55,11 @@ describe('DepartmentService()', function () {
|
|
|
57
55
|
winston.debug("err", err);
|
|
58
56
|
winston.debug("savedProject_user2", savedProject_user2.toObject());
|
|
59
57
|
|
|
60
|
-
|
|
61
58
|
var pu2 = new Project_user({
|
|
62
59
|
// _id: new mongoose.Types.ObjectId(),
|
|
63
60
|
id_project: savedProject._id,
|
|
64
61
|
id_user: savedUser3._id,
|
|
65
|
-
role:
|
|
62
|
+
role: RoleConstants.AGENT,
|
|
66
63
|
roleType : RoleConstants.TYPE_AGENTS,
|
|
67
64
|
user_available: true,
|
|
68
65
|
createdBy: savedUser3._id,
|
|
@@ -71,12 +68,11 @@ describe('DepartmentService()', function () {
|
|
|
71
68
|
|
|
72
69
|
pu2.save(function (err, savedProject_user3) {
|
|
73
70
|
winston.debug("savedProject_user3", savedProject_user3.toObject());
|
|
74
|
-
|
|
71
|
+
|
|
75
72
|
departmentService.create("PooledDepartment-for-createWithIdWith-createFirstWithAssignedDepartment", savedProject._id, routingConstants.ASSIGNED, savedUser._id).then(function (createdDepartment) {
|
|
76
73
|
|
|
77
74
|
expect(createdDepartment.hasBot).to.equal(false);
|
|
78
75
|
|
|
79
|
-
|
|
80
76
|
// requestService.createWithId("request_id1", "requester_id1", savedProject._id, "first_text", createdDepartment._id).then(function(savedRequest) {
|
|
81
77
|
|
|
82
78
|
// getOperators(departmentid, projectid, nobot) {
|
|
@@ -127,7 +123,7 @@ describe('DepartmentService()', function () {
|
|
|
127
123
|
// _id: new mongoose.Types.ObjectId(),
|
|
128
124
|
id_project: savedProject._id,
|
|
129
125
|
id_user: savedUser2._id,
|
|
130
|
-
role:
|
|
126
|
+
role: RoleConstants.AGENT,
|
|
131
127
|
roleType : RoleConstants.TYPE_AGENTS,
|
|
132
128
|
user_available: true,
|
|
133
129
|
createdBy: savedUser2._id,
|
|
@@ -142,7 +138,7 @@ describe('DepartmentService()', function () {
|
|
|
142
138
|
// // _id: new mongoose.Types.ObjectId(),
|
|
143
139
|
// id_project: savedProject._id,
|
|
144
140
|
// id_user: savedUser3._id,
|
|
145
|
-
// role:
|
|
141
|
+
// role: RoleConstants.AGENT,
|
|
146
142
|
// user_available: true,
|
|
147
143
|
// createdBy: savedUser3._id,
|
|
148
144
|
// updatedBy: savedUser3._id,
|
|
@@ -249,7 +245,7 @@ describe('DepartmentService()', function () {
|
|
|
249
245
|
var pu1 = new Project_user({
|
|
250
246
|
id_project: savedProject._id,
|
|
251
247
|
id_user: savedUser2._id,
|
|
252
|
-
role:
|
|
248
|
+
role: RoleConstants.AGENT,
|
|
253
249
|
roleType : RoleConstants.TYPE_AGENTS,
|
|
254
250
|
user_available: false,
|
|
255
251
|
createdBy: savedUser2._id,
|
|
@@ -328,7 +324,7 @@ describe('DepartmentService()', function () {
|
|
|
328
324
|
var pu1 = new Project_user({
|
|
329
325
|
id_project: savedProject._id,
|
|
330
326
|
id_user: savedUser2._id,
|
|
331
|
-
role:
|
|
327
|
+
role: RoleConstants.AGENT,
|
|
332
328
|
roleType : RoleConstants.TYPE_AGENTS,
|
|
333
329
|
user_available: false,
|
|
334
330
|
createdBy: savedUser2._id,
|
|
@@ -5,10 +5,10 @@ process.env.LOG_LEVEL = 'critical';
|
|
|
5
5
|
//Require the dev-dependencies
|
|
6
6
|
let chai = require('chai');
|
|
7
7
|
let chaiHttp = require('chai-http');
|
|
8
|
-
let server = require('
|
|
8
|
+
let server = require('../../app');
|
|
9
9
|
let should = chai.should();
|
|
10
10
|
var fs = require('fs');
|
|
11
|
-
var userService = require('
|
|
11
|
+
var userService = require('../../services/userService');
|
|
12
12
|
|
|
13
13
|
let log = false;
|
|
14
14
|
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
//During the test the env variable is set to test
|
|
2
2
|
process.env.NODE_ENV = 'test';
|
|
3
3
|
|
|
4
|
-
var userService = require('
|
|
5
|
-
var projectService = require('
|
|
4
|
+
var userService = require('../../services/userService');
|
|
5
|
+
var projectService = require('../../services/projectService');
|
|
6
6
|
|
|
7
7
|
let log = false;
|
|
8
8
|
|
|
9
9
|
//Require the dev-dependencies
|
|
10
10
|
let chai = require('chai');
|
|
11
11
|
let chaiHttp = require('chai-http');
|
|
12
|
-
let server = require('
|
|
12
|
+
let server = require('../../app');
|
|
13
13
|
let should = chai.should();
|
|
14
14
|
var fs = require('fs');
|
|
15
15
|
const path = require('path');
|
package/test/faqRoute.js
CHANGED
|
@@ -19,6 +19,7 @@ const path = require('path');
|
|
|
19
19
|
const uuidv4 = require('uuid/v4');
|
|
20
20
|
const project_user = require('../models/project_user');
|
|
21
21
|
const roleConstants = require('../models/roleConstants');
|
|
22
|
+
const cachegoose = require('cachegoose');
|
|
22
23
|
|
|
23
24
|
|
|
24
25
|
// chai.config.includeStack = true;
|
|
@@ -301,7 +302,7 @@ describe('FaqKBRoute', () => {
|
|
|
301
302
|
|
|
302
303
|
res.should.have.status(200);
|
|
303
304
|
res.body.should.be.a('array');
|
|
304
|
-
expect(res.body.length).to.equal(
|
|
305
|
+
expect(res.body.length).to.equal(4);
|
|
305
306
|
|
|
306
307
|
let intent = res.body.find(f => f.intent_display_name === 'welcome');
|
|
307
308
|
expect(intent.agents_available).to.equal(false);
|
|
@@ -323,6 +324,9 @@ describe('FaqKBRoute', () => {
|
|
|
323
324
|
|
|
324
325
|
Project_user.findOneAndUpdate({ id_project: savedProject._id, id_user: savedUser._id }, { role: roleConstants.AGENT }, (err, savedProject_user) => {
|
|
325
326
|
|
|
327
|
+
const projectUserCacheKey = savedProject._id + ":project_users:iduser:" + savedUser._id;
|
|
328
|
+
cachegoose.clearCache(projectUserCacheKey, () => {
|
|
329
|
+
|
|
326
330
|
chai.request(server)
|
|
327
331
|
.get('/' + savedProject._id + '/faq?id_faq_kb=' + id_faq_kb)
|
|
328
332
|
.auth(email, pwd)
|
|
@@ -340,6 +344,7 @@ describe('FaqKBRoute', () => {
|
|
|
340
344
|
done();
|
|
341
345
|
|
|
342
346
|
})
|
|
347
|
+
});
|
|
343
348
|
})
|
|
344
349
|
})
|
|
345
350
|
|
package/test/faqkbRoute.js
CHANGED
|
@@ -1129,13 +1129,18 @@ describe('FaqKBRoute', () => {
|
|
|
1129
1129
|
expect(exported.subagents[0]._id).to.equal(source_subagent_id);
|
|
1130
1130
|
expect(exported.subagents[0].id_project).to.be.undefined;
|
|
1131
1131
|
expect(exported.subagents[0].language).to.equal("en");
|
|
1132
|
-
expect(exported.subagents[0].intents.length).to.equal(
|
|
1133
|
-
|
|
1134
|
-
expect(
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1132
|
+
expect(exported.subagents[0].intents.length).to.equal(5);
|
|
1133
|
+
const intentNames = exported.subagents[0].intents.map((intent) => intent.intent_display_name);
|
|
1134
|
+
expect(intentNames).to.have.members([
|
|
1135
|
+
"start",
|
|
1136
|
+
"untitled_block_1",
|
|
1137
|
+
"return",
|
|
1138
|
+
"defaultFallback",
|
|
1139
|
+
"untitled_block_2"
|
|
1140
|
+
]);
|
|
1141
|
+
exported.subagents[0].intents.forEach((intent) => {
|
|
1142
|
+
expect(intent._id).to.be.undefined;
|
|
1143
|
+
});
|
|
1139
1144
|
done();
|
|
1140
1145
|
})
|
|
1141
1146
|
})
|
|
@@ -1675,7 +1680,6 @@ describe('FaqKBRoute', () => {
|
|
|
1675
1680
|
if (err) { console.error("err: ", err); }
|
|
1676
1681
|
if (log) { console.log("res.body", res.body); }
|
|
1677
1682
|
|
|
1678
|
-
console.log("chatbot trashed: ", res.body);
|
|
1679
1683
|
res.should.have.status(200);
|
|
1680
1684
|
res.body.should.be.a('object');
|
|
1681
1685
|
expect(res.body.trashed).to.equal(true);
|
|
@@ -1691,7 +1695,7 @@ describe('FaqKBRoute', () => {
|
|
|
1691
1695
|
|
|
1692
1696
|
res.should.have.status(200);
|
|
1693
1697
|
res.body.should.be.a('array');
|
|
1694
|
-
expect(res.body.length).to.equal(
|
|
1698
|
+
expect(res.body.length).to.equal(4);
|
|
1695
1699
|
expect(res.body[0].trashed).to.equal(true);
|
|
1696
1700
|
expect(res.body[0].trashedAt).to.exist;
|
|
1697
1701
|
|
|
@@ -1922,7 +1926,7 @@ describe('FaqKBRoute', () => {
|
|
|
1922
1926
|
|
|
1923
1927
|
res.should.have.status(200);
|
|
1924
1928
|
res.body.should.be.a('array');
|
|
1925
|
-
res.body.length.should.equal(
|
|
1929
|
+
res.body.length.should.equal(5);
|
|
1926
1930
|
|
|
1927
1931
|
done()
|
|
1928
1932
|
})
|
package/test/faqkbV3Route.js
CHANGED
package/test/filepRoute.js
CHANGED
|
@@ -91,10 +91,11 @@ describe('FileRoute', () => {
|
|
|
91
91
|
if (err) { console.error("err: ", err); }
|
|
92
92
|
if (log) { console.log("res.body", res.body); }
|
|
93
93
|
|
|
94
|
-
res.should.have.status(
|
|
94
|
+
res.should.have.status(201);
|
|
95
95
|
res.body.should.be.a('object');
|
|
96
|
-
expect(res.body.
|
|
97
|
-
expect(res.body.
|
|
96
|
+
expect(res.body.message).to.equal('Image uploaded successfully');
|
|
97
|
+
expect(res.body.filename).to.equal(`uploads%2Fusers%2F${savedUser._id}%2Fimages%2Fphoto.jpg`);
|
|
98
|
+
expect(res.body.thumbnail).to.equal(`uploads%2Fusers%2F${savedUser._id}%2Fimages%2Fthumbnails_200_200-photo.jpg`);
|
|
98
99
|
|
|
99
100
|
done();
|
|
100
101
|
})
|
|
@@ -314,53 +315,6 @@ describe('FileRoute', () => {
|
|
|
314
315
|
})
|
|
315
316
|
});
|
|
316
317
|
|
|
317
|
-
it('post-assets-images-retro-compatibility', (done) => {
|
|
318
|
-
|
|
319
|
-
var email = "test-signup-" + Date.now() + "@email.com";
|
|
320
|
-
var pwd = "pwd";
|
|
321
|
-
|
|
322
|
-
userService.signup(email, pwd, "Test Firstname", "Test lastname").then(function (savedUser) {
|
|
323
|
-
projectService.create("test-assets-create", savedUser._id).then(function (savedProject) {
|
|
324
|
-
|
|
325
|
-
chai.request(server)
|
|
326
|
-
.post('/images/users/')
|
|
327
|
-
.auth(email, pwd)
|
|
328
|
-
.set('Content-Type', 'image/jpeg')
|
|
329
|
-
.attach('file', fs.readFileSync('./test/fixtures/test-image.png'), 'test-image.png')
|
|
330
|
-
// .field('delimiter', ';')
|
|
331
|
-
.end((err, res) => {
|
|
332
|
-
|
|
333
|
-
if (err) { console.error("err: ", err); }
|
|
334
|
-
if (log) { console.log("res.body", res.body); }
|
|
335
|
-
|
|
336
|
-
res.should.have.status(201);
|
|
337
|
-
res.body.should.be.a('object');
|
|
338
|
-
expect(res.body.message).to.equal('Image uploded successfully');
|
|
339
|
-
expect(res.body.filename).to.not.equal(null);
|
|
340
|
-
expect(res.body.filename).to.containIgnoreSpaces('test-image.png');
|
|
341
|
-
expect(res.body.filename).to.containIgnoreSpaces('users', 'images');
|
|
342
|
-
expect(res.body.thumbnail).to.not.equal(null);
|
|
343
|
-
|
|
344
|
-
let filepath = res.body.filename;
|
|
345
|
-
|
|
346
|
-
chai.request(server)
|
|
347
|
-
.get('/' + savedProject._id + '/files?path=' + filepath)
|
|
348
|
-
.auth(email, pwd)
|
|
349
|
-
.end((err, res) => {
|
|
350
|
-
|
|
351
|
-
if (err) { console.error("err: ", err); }
|
|
352
|
-
if (log) { console.log("res.body", res.body); }
|
|
353
|
-
|
|
354
|
-
res.should.have.status(200);
|
|
355
|
-
expect(res.body).to.be.instanceof(Buffer)
|
|
356
|
-
|
|
357
|
-
done();
|
|
358
|
-
});
|
|
359
|
-
});
|
|
360
|
-
})
|
|
361
|
-
})
|
|
362
|
-
});
|
|
363
|
-
|
|
364
318
|
});
|
|
365
319
|
|
|
366
320
|
describe('Security', () => {
|