shuttlepro-shared 1.4.67 → 1.4.69
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/common/repositories/userRole.repository.js +4 -8
- package/models/Chatbot.js +13 -1
- package/models/FeedbackBot.js +92 -0
- package/models/UserRole.js +1 -2
- package/models.js +2 -0
- package/package.json +2 -2
|
@@ -15,7 +15,7 @@ const updateCachedMembers = async (workspaceId) => {
|
|
|
15
15
|
.populate({
|
|
16
16
|
path: "roleId",
|
|
17
17
|
select:
|
|
18
|
-
"id name userId userShift permissionId modulePermissions workspaceId
|
|
18
|
+
"id name userId userShift permissionId modulePermissions workspaceId",
|
|
19
19
|
populate: [{ path: "permissionId", select: "id name" }],
|
|
20
20
|
})
|
|
21
21
|
.populate({
|
|
@@ -35,14 +35,14 @@ const updateCachedMembers = async (workspaceId) => {
|
|
|
35
35
|
|
|
36
36
|
const getMembers = async (workspaceId) => {
|
|
37
37
|
let members = await getRedisData(workspaceId, MEMBERS);
|
|
38
|
-
|
|
38
|
+
|
|
39
39
|
if (!members || members?.length === 0) {
|
|
40
40
|
members = await UserRole.find({ workspaceId })
|
|
41
41
|
.select("userId role userShift roleId isOwner workspaceId")
|
|
42
42
|
.populate({
|
|
43
43
|
path: "roleId",
|
|
44
44
|
select:
|
|
45
|
-
"id name userId userShift permissionId modulePermissions workspaceId
|
|
45
|
+
"id name userId userShift permissionId modulePermissions workspaceId",
|
|
46
46
|
populate: [{ path: "permissionId", select: "id name" }],
|
|
47
47
|
})
|
|
48
48
|
.populate({
|
|
@@ -165,8 +165,6 @@ const getUserRoleWithPermissions = async (workspaceId, userId) => {
|
|
|
165
165
|
parentRole: data?.roleId?.permissionId?.name || "",
|
|
166
166
|
parentRoleId: data?.roleId?.permissionId?._id?.toString() || "",
|
|
167
167
|
defaultModule: data?.roleId?.defaultModule || "",
|
|
168
|
-
extraCapabilities: data?.roleId?.extraCapabilities || [],
|
|
169
|
-
scope: data?.roleId?.scope || "workspace",
|
|
170
168
|
};
|
|
171
169
|
return roleWithPermissions || null;
|
|
172
170
|
}
|
|
@@ -199,7 +197,7 @@ const findUserWorkspaces = async (userId) => {
|
|
|
199
197
|
.select("userId roleId workspaceId")
|
|
200
198
|
.populate({
|
|
201
199
|
path: "roleId",
|
|
202
|
-
select: "id name userId userShift permissionId modulePermissions
|
|
200
|
+
select: "id name userId userShift permissionId modulePermissions",
|
|
203
201
|
populate: [{ path: "permissionId", select: "id name" }],
|
|
204
202
|
})
|
|
205
203
|
.populate({
|
|
@@ -219,8 +217,6 @@ const findUserWorkspaces = async (userId) => {
|
|
|
219
217
|
_id: ur?.workspaceId?._id?.toString(),
|
|
220
218
|
role: ur?.roleId?.name || "",
|
|
221
219
|
permissions: ur?.roleId?.modulePermissions?.modules || [],
|
|
222
|
-
extraCapabilities: ur?.roleId?.extraCapabilities || [],
|
|
223
|
-
scope: ur?.roleId?.scope || "workspace",
|
|
224
220
|
};
|
|
225
221
|
});
|
|
226
222
|
return userRoleWithWorkspaces || [];
|
package/models/Chatbot.js
CHANGED
|
@@ -20,7 +20,7 @@ const ChatbotSchema = new Schema(
|
|
|
20
20
|
},
|
|
21
21
|
type: {
|
|
22
22
|
type: String,
|
|
23
|
-
enum: ["chatbot", "agent", "interactive"],
|
|
23
|
+
enum: ["chatbot", "agent", "interactive", "feedback-bot"],
|
|
24
24
|
default: "chatbot",
|
|
25
25
|
},
|
|
26
26
|
interactiveId: {
|
|
@@ -62,6 +62,18 @@ const ChatbotSchema = new Schema(
|
|
|
62
62
|
],
|
|
63
63
|
},
|
|
64
64
|
],
|
|
65
|
+
feedbackConfig: {
|
|
66
|
+
templateId: {
|
|
67
|
+
type: Schema.Types.Mixed,
|
|
68
|
+
default: null,
|
|
69
|
+
},
|
|
70
|
+
questions: [
|
|
71
|
+
{
|
|
72
|
+
question: { type: String, default: "" },
|
|
73
|
+
options: [{ type: String, default: "" }],
|
|
74
|
+
},
|
|
75
|
+
],
|
|
76
|
+
},
|
|
65
77
|
},
|
|
66
78
|
{ timestamps: true, toJSON: { virtuals: true }, toObject: { virtuals: true } }
|
|
67
79
|
);
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
const { Schema } = require("mongoose");
|
|
2
|
+
|
|
3
|
+
const FeedbackBotSchema = new Schema(
|
|
4
|
+
{
|
|
5
|
+
workspaceId: {
|
|
6
|
+
type: Schema.Types.ObjectId,
|
|
7
|
+
ref: "Workspace",
|
|
8
|
+
required: true,
|
|
9
|
+
},
|
|
10
|
+
chatbotId: {
|
|
11
|
+
type: Schema.Types.ObjectId,
|
|
12
|
+
ref: "Chatbot",
|
|
13
|
+
required: true,
|
|
14
|
+
},
|
|
15
|
+
conversationId: {
|
|
16
|
+
type: Schema.Types.ObjectId,
|
|
17
|
+
ref: "Conversation",
|
|
18
|
+
required: true,
|
|
19
|
+
},
|
|
20
|
+
phoneNumber: {
|
|
21
|
+
type: String,
|
|
22
|
+
required: true,
|
|
23
|
+
},
|
|
24
|
+
status: {
|
|
25
|
+
type: String,
|
|
26
|
+
enum: ["active", "completed", "abandoned"],
|
|
27
|
+
default: "active",
|
|
28
|
+
},
|
|
29
|
+
answers: [
|
|
30
|
+
{
|
|
31
|
+
question: {
|
|
32
|
+
type: String,
|
|
33
|
+
required: true,
|
|
34
|
+
},
|
|
35
|
+
answer: {
|
|
36
|
+
type: String,
|
|
37
|
+
required: true,
|
|
38
|
+
},
|
|
39
|
+
optionIndex: {
|
|
40
|
+
type: Number,
|
|
41
|
+
default: 0,
|
|
42
|
+
},
|
|
43
|
+
options: {
|
|
44
|
+
type: [String],
|
|
45
|
+
default: [],
|
|
46
|
+
},
|
|
47
|
+
answeredAt: {
|
|
48
|
+
type: Date,
|
|
49
|
+
default: Date.now,
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
],
|
|
53
|
+
totalQuestions: {
|
|
54
|
+
type: Number,
|
|
55
|
+
default: 0,
|
|
56
|
+
},
|
|
57
|
+
completedQuestions: {
|
|
58
|
+
type: Number,
|
|
59
|
+
default: 0,
|
|
60
|
+
},
|
|
61
|
+
startedAt: {
|
|
62
|
+
type: Date,
|
|
63
|
+
default: Date.now,
|
|
64
|
+
},
|
|
65
|
+
completedAt: {
|
|
66
|
+
type: Date,
|
|
67
|
+
default: null,
|
|
68
|
+
},
|
|
69
|
+
// Store reference to order/workflow if applicable
|
|
70
|
+
orderId: {
|
|
71
|
+
type: String,
|
|
72
|
+
default: null,
|
|
73
|
+
},
|
|
74
|
+
workflowId: {
|
|
75
|
+
type: Schema.Types.ObjectId,
|
|
76
|
+
ref: "SocialWorkflow",
|
|
77
|
+
default: null,
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
{ timestamps: true, toJSON: { virtuals: true }, toObject: { virtuals: true } }
|
|
81
|
+
);
|
|
82
|
+
|
|
83
|
+
// Index for faster queries
|
|
84
|
+
FeedbackBotSchema.index({ workspaceId: 1, phoneNumber: 1, createdAt: -1 });
|
|
85
|
+
FeedbackBotSchema.index({ conversationId: 1 });
|
|
86
|
+
FeedbackBotSchema.index({ chatbotId: 1 });
|
|
87
|
+
FeedbackBotSchema.index({ status: 1 });
|
|
88
|
+
// Index for order_id based queries (allows multiple feedback per conversation)
|
|
89
|
+
FeedbackBotSchema.index({ workspaceId: 1, phoneNumber: 1, orderId: 1 });
|
|
90
|
+
|
|
91
|
+
module.exports = FeedbackBotSchema;
|
|
92
|
+
|
package/models/UserRole.js
CHANGED
package/models.js
CHANGED
|
@@ -39,6 +39,7 @@ const EmailNotification = require("./models/EmailNotification");
|
|
|
39
39
|
const EscalationConfiguration = require("./models/EscalationConfiguration");
|
|
40
40
|
const EscalationManager = require("./models/EscalationManager");
|
|
41
41
|
const Faq = require("./models/Faq");
|
|
42
|
+
const FeedbackBot = require("./models/FeedbackBot");
|
|
42
43
|
const FeedbackResponse = require("./models/FeedbackResponse");
|
|
43
44
|
const FormTemplate = require("./models/FormTemplate");
|
|
44
45
|
const GoogleClientInfo = require("./models/GoogleClientInfo");
|
|
@@ -151,6 +152,7 @@ module.exports = {
|
|
|
151
152
|
EscalationConfiguration,
|
|
152
153
|
EscalationManager,
|
|
153
154
|
Faq,
|
|
155
|
+
FeedbackBot,
|
|
154
156
|
FeedbackResponse,
|
|
155
157
|
FormTemplate,
|
|
156
158
|
GoogleClientInfo,
|