shuttlepro-shared 1.3.19 → 1.3.20
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/chatMember.repository.js +9 -0
- package/common/repositories/customerProfile.repository.js +147 -0
- package/common/repositories/customerTimeline.repository.js +78 -0
- package/common/repositories/descriptionTemplates.repository.js +229 -0
- package/common/repositories/index.js +34 -0
- package/common/repositories/integration.repository.js +210 -0
- package/common/repositories/label.repository.js +95 -0
- package/common/repositories/notificationSettings.repository.js +95 -0
- package/common/repositories/role.repository.js +333 -0
- package/common/repositories/settings.repository.js +32 -0
- package/common/repositories/shipper.repository.js +77 -0
- package/common/repositories/socialMediaSetting.repository.js +33 -0
- package/common/repositories/user.repository.js +150 -0
- package/common/repositories/userPermission.repository.js +228 -0
- package/common/repositories/userRepository.js +31 -0
- package/common/repositories/userRole.repository.js +235 -0
- package/common/repositories/userRolePermission.repository.js +59 -0
- package/common/repositories/workspace.repository.js +147 -0
- package/config/bull.js +78 -0
- package/config/config.js +14 -0
- package/config/database.js +4 -0
- package/config/index.js +13 -0
- package/config/redis.js +196 -0
- package/config/socket.js +172 -0
- package/constants/index.js +15 -0
- package/index.js +8 -0
- package/models/AgentActivity.js +192 -0
- package/models/Assignment.js +23 -0
- package/models/BusinessDistribution.js +23 -0
- package/models/Card.js +144 -0
- package/models/CardComments.js +33 -0
- package/models/ChatMember.js +17 -0
- package/models/Chatbot.js +20 -0
- package/models/Checkpoint.js +50 -0
- package/models/City.js +17 -0
- package/models/Column.js +28 -0
- package/models/Conversation.js +87 -0
- package/models/Customer.js +36 -0
- package/models/CustomerProfile.js +30 -0
- package/models/CustomerTimeline.js +28 -0
- package/models/DefaultRolePermission.js +34 -0
- package/models/DescriptionTemplate.js +22 -0
- package/models/Integration.js +51 -0
- package/models/Label.js +42 -0
- package/models/Message.js +47 -0
- package/models/NewProduct.js +71 -0
- package/models/NotificationSettings.js +130 -0
- package/models/Order.js +254 -0
- package/models/OrderProduct.js +37 -0
- package/models/Profile.js +127 -0
- package/models/Report.js +27 -0
- package/models/Setting.js +18 -0
- package/models/Shipper.js +62 -0
- package/models/SocialMediaSetting.js +28 -0
- package/models/Status.js +58 -0
- package/models/StatusType.js +10 -0
- package/models/Step.js +50 -0
- package/models/Type.js +25 -0
- package/models/UserRole.js +1 -119
- package/models/UserWorkflow.js +46 -0
- package/models/Workspace.js +308 -0
- package/models.js +62 -1
- package/package.json +13 -2
- package/utils/decorator-factory.js +264 -0
- package/utils/logger.js +41 -0
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
const mongoose = require("mongoose");
|
|
2
|
+
const { Schema } = mongoose;
|
|
3
|
+
const CustomerProfileSchema = new Schema(
|
|
4
|
+
{
|
|
5
|
+
name: { type: String, default: "" },
|
|
6
|
+
email: { type: String, default: "" },
|
|
7
|
+
contact: { type: String, default: "" },
|
|
8
|
+
picture: { type: String, default: "" },
|
|
9
|
+
fbId: { type: String, default: "" },
|
|
10
|
+
igId: { type: String, default: "" },
|
|
11
|
+
totalOrders: { type: Number, default: 0 },
|
|
12
|
+
totalConversations: { type: Number, default: 0 },
|
|
13
|
+
totalTickets: { type: Number, default: 0 },
|
|
14
|
+
blackList: { type: Boolean, default: false },
|
|
15
|
+
workspaceId: {
|
|
16
|
+
type: Schema.Types.ObjectId,
|
|
17
|
+
ref: "Workspace",
|
|
18
|
+
default: null,
|
|
19
|
+
},
|
|
20
|
+
mergedId: {
|
|
21
|
+
type: Schema.Types.ObjectId,
|
|
22
|
+
ref: "CustomerProfile",
|
|
23
|
+
default: null,
|
|
24
|
+
},
|
|
25
|
+
body: {},
|
|
26
|
+
},
|
|
27
|
+
{ timestamps: true, toJSON: { virtuals: true }, toObject: { virtuals: true } }
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
module.exports = mongoose.model("CustomerProfile", CustomerProfileSchema);
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
const mongoose = require("mongoose");
|
|
2
|
+
const { Schema } = mongoose;
|
|
3
|
+
const CustomerTimelineSchema = new Schema(
|
|
4
|
+
{
|
|
5
|
+
type: { type: String, default: "" },
|
|
6
|
+
referenceId: { type: String, default: "" },
|
|
7
|
+
timestamp: { type: String, default: "" },
|
|
8
|
+
platformId: {
|
|
9
|
+
type: Schema.Types.ObjectId,
|
|
10
|
+
ref: "Integration",
|
|
11
|
+
default: null,
|
|
12
|
+
},
|
|
13
|
+
workspaceId: {
|
|
14
|
+
type: Schema.Types.ObjectId,
|
|
15
|
+
ref: "Workspace",
|
|
16
|
+
default: null,
|
|
17
|
+
},
|
|
18
|
+
profileId: {
|
|
19
|
+
type: Schema.Types.ObjectId,
|
|
20
|
+
ref: "CustomerProfile",
|
|
21
|
+
default: null,
|
|
22
|
+
},
|
|
23
|
+
body: {},
|
|
24
|
+
},
|
|
25
|
+
{ timestamps: true, toJSON: { virtuals: true }, toObject: { virtuals: true } }
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
module.exports = mongoose.model("CustomerTimeline", CustomerTimelineSchema);
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
const mongoose = require("mongoose");
|
|
2
|
+
const { Schema } = mongoose;
|
|
3
|
+
|
|
4
|
+
const DefaultRolePermissionSchema = new Schema(
|
|
5
|
+
{
|
|
6
|
+
type: {
|
|
7
|
+
type: String,
|
|
8
|
+
default: "",
|
|
9
|
+
},
|
|
10
|
+
roleId: {
|
|
11
|
+
type: Schema.Types.ObjectId,
|
|
12
|
+
ref: "Role",
|
|
13
|
+
default: null,
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
{ timestamps: true, toJSON: { virtuals: true }, toObject: { virtuals: true } }
|
|
17
|
+
);
|
|
18
|
+
|
|
19
|
+
const fields = ["role", "module", "action", "value"];
|
|
20
|
+
|
|
21
|
+
fields.forEach((field) => {
|
|
22
|
+
DefaultRolePermissionSchema.add({
|
|
23
|
+
[field]: {
|
|
24
|
+
type: String,
|
|
25
|
+
required: true,
|
|
26
|
+
default: "",
|
|
27
|
+
},
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
module.exports = mongoose.model(
|
|
32
|
+
"DefaultRolePermission",
|
|
33
|
+
DefaultRolePermissionSchema
|
|
34
|
+
);
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
const mongoose = require("mongoose");
|
|
2
|
+
const { Schema } = mongoose;
|
|
3
|
+
const DescriptionTemplateSchema = new Schema(
|
|
4
|
+
{
|
|
5
|
+
name: { type: String, default: "" },
|
|
6
|
+
subject: { type: String, default: "" },
|
|
7
|
+
format: { type: String, default: "" },
|
|
8
|
+
workspaceId: { type: String, default: "" },
|
|
9
|
+
businessId: { type: String, default: "" },
|
|
10
|
+
integrationId: { type: String, default: "" },
|
|
11
|
+
type: { type: String, default: "" },
|
|
12
|
+
body: {},
|
|
13
|
+
arbitraryValues: {},
|
|
14
|
+
moduleType: { type: String, default: "" },
|
|
15
|
+
},
|
|
16
|
+
{ timestamps: true, toJSON: { virtuals: true }, toObject: { virtuals: true } }
|
|
17
|
+
);
|
|
18
|
+
const DescriptionTemplate =
|
|
19
|
+
mongoose.models.DescriptionTemplate ||
|
|
20
|
+
mongoose.model("DescriptionTemplate", DescriptionTemplateSchema);
|
|
21
|
+
|
|
22
|
+
module.exports = DescriptionTemplate;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
const mongoose = require("mongoose");
|
|
2
|
+
const IntegrationSchema = new mongoose.Schema(
|
|
3
|
+
{
|
|
4
|
+
workspaceId: {
|
|
5
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
6
|
+
ref: "Workspace",
|
|
7
|
+
default: null,
|
|
8
|
+
},
|
|
9
|
+
type: {
|
|
10
|
+
type: String,
|
|
11
|
+
enum: [
|
|
12
|
+
"socialPlatforms",
|
|
13
|
+
"whatsapp",
|
|
14
|
+
"gmail",
|
|
15
|
+
"sms",
|
|
16
|
+
"map",
|
|
17
|
+
"facebook",
|
|
18
|
+
"instagram",
|
|
19
|
+
"webChat",
|
|
20
|
+
"smtp_gmail",
|
|
21
|
+
"outlook",
|
|
22
|
+
"business_central",
|
|
23
|
+
],
|
|
24
|
+
},
|
|
25
|
+
chatbot: { type: Boolean, default: false },
|
|
26
|
+
isNlp: { type: Boolean, default: false },
|
|
27
|
+
autoTicket: {
|
|
28
|
+
enabled: { type: Boolean, default: false },
|
|
29
|
+
},
|
|
30
|
+
signature: {
|
|
31
|
+
type: Map,
|
|
32
|
+
of: mongoose.Schema.Types.Mixed,
|
|
33
|
+
default: {},
|
|
34
|
+
},
|
|
35
|
+
chatbotId: {
|
|
36
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
37
|
+
ref: "Chatbot",
|
|
38
|
+
default: null,
|
|
39
|
+
},
|
|
40
|
+
members: [
|
|
41
|
+
{
|
|
42
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
43
|
+
ref: "User",
|
|
44
|
+
},
|
|
45
|
+
],
|
|
46
|
+
body: {},
|
|
47
|
+
},
|
|
48
|
+
{ timestamps: true, toJSON: { virtuals: true }, toObject: { virtuals: true } }
|
|
49
|
+
);
|
|
50
|
+
|
|
51
|
+
module.exports = mongoose.model("Integration", IntegrationSchema);
|
package/models/Label.js
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
const mongoose = require("mongoose");
|
|
2
|
+
const { Schema } = mongoose;
|
|
3
|
+
|
|
4
|
+
const LabelSchema = new Schema(
|
|
5
|
+
{
|
|
6
|
+
color: { type: String },
|
|
7
|
+
title: {
|
|
8
|
+
type: String,
|
|
9
|
+
required: true,
|
|
10
|
+
},
|
|
11
|
+
type: {
|
|
12
|
+
type: String,
|
|
13
|
+
required: true,
|
|
14
|
+
default: "system",
|
|
15
|
+
enum: ["system", "custom", "escalation"],
|
|
16
|
+
},
|
|
17
|
+
workspaceId: {
|
|
18
|
+
type: Schema.Types.ObjectId,
|
|
19
|
+
ref: "Workspace",
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
{ timestamps: true, toJSON: { virtuals: true }, toObject: { virtuals: true } }
|
|
23
|
+
);
|
|
24
|
+
LabelSchema.virtual("conversationCount", {
|
|
25
|
+
ref: "Conversation",
|
|
26
|
+
localField: "_id",
|
|
27
|
+
foreignField: "labels",
|
|
28
|
+
count: true,
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
LabelSchema.virtual("conversations", {
|
|
32
|
+
ref: "Conversation",
|
|
33
|
+
localField: "_id",
|
|
34
|
+
foreignField: "labels",
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
LabelSchema.set("toObject", { virtuals: true });
|
|
38
|
+
LabelSchema.set("toJSON", { virtuals: true });
|
|
39
|
+
|
|
40
|
+
const Label = mongoose.model("Label", LabelSchema);
|
|
41
|
+
|
|
42
|
+
module.exports = Label;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
const mongoose = require("mongoose");
|
|
2
|
+
const { Schema } = mongoose;
|
|
3
|
+
|
|
4
|
+
const readBySchema = new Schema({
|
|
5
|
+
receiptTrigger: { type: Boolean, default: false },
|
|
6
|
+
readerId: { type: Schema.Types.ObjectId, ref: "User", default: null },
|
|
7
|
+
readTime: { type: String, default: "" },
|
|
8
|
+
responseTime: { type: String, default: "" },
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
const newMessageSchema = new mongoose.Schema(
|
|
12
|
+
{
|
|
13
|
+
workspaceId: {
|
|
14
|
+
type: Schema.Types.ObjectId,
|
|
15
|
+
ref: "Workspace",
|
|
16
|
+
default: null,
|
|
17
|
+
},
|
|
18
|
+
readBy: [readBySchema],
|
|
19
|
+
messageType: {
|
|
20
|
+
type: String,
|
|
21
|
+
enum: [
|
|
22
|
+
"system",
|
|
23
|
+
"user",
|
|
24
|
+
"internal",
|
|
25
|
+
"chatbot",
|
|
26
|
+
"auto-generated",
|
|
27
|
+
"facebook",
|
|
28
|
+
"instagram",
|
|
29
|
+
"webChat",
|
|
30
|
+
"chat-status",
|
|
31
|
+
],
|
|
32
|
+
required: true,
|
|
33
|
+
},
|
|
34
|
+
conversationId: {
|
|
35
|
+
type: Schema.Types.ObjectId,
|
|
36
|
+
ref: "Conversation",
|
|
37
|
+
default: null,
|
|
38
|
+
},
|
|
39
|
+
conversationType: { type: String },
|
|
40
|
+
activityId: { type: String, default: "" },
|
|
41
|
+
|
|
42
|
+
body: {},
|
|
43
|
+
},
|
|
44
|
+
{ timestamps: true, toJSON: { virtuals: true }, toObject: { virtuals: true } }
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
module.exports = mongoose.model("Message", newMessageSchema);
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
const mongoose = require("mongoose");
|
|
2
|
+
const { Schema } = mongoose;
|
|
3
|
+
|
|
4
|
+
const NewProductSchema = new Schema(
|
|
5
|
+
{
|
|
6
|
+
id: {
|
|
7
|
+
type: Schema.Types.ObjectId,
|
|
8
|
+
ref: "Product",
|
|
9
|
+
default: null,
|
|
10
|
+
},
|
|
11
|
+
name: { type: String, default: "" },
|
|
12
|
+
description: { type: String, default: "" },
|
|
13
|
+
sku: { type: String, default: "" },
|
|
14
|
+
price: { type: String, default: 0 },
|
|
15
|
+
quantity: { type: Number, default: 0 },
|
|
16
|
+
imageUrl: { type: String, default: "" },
|
|
17
|
+
costPrice: { type: String, default: 0 },
|
|
18
|
+
salePrice: { type: String, default: 0 },
|
|
19
|
+
webProductId: { type: Number, default: null },
|
|
20
|
+
variants: [],
|
|
21
|
+
attachments: [],
|
|
22
|
+
workspaceId: {
|
|
23
|
+
type: Schema.Types.ObjectId,
|
|
24
|
+
ref: "Workspace",
|
|
25
|
+
default: null,
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
timestamps: true,
|
|
30
|
+
toJSON: { virtuals: true },
|
|
31
|
+
toObject: { virtuals: true },
|
|
32
|
+
}
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
// Adding compound text index for name, sku, and variants
|
|
36
|
+
NewProductSchema.index({
|
|
37
|
+
name: "text",
|
|
38
|
+
sku: "text",
|
|
39
|
+
"variants.name": "text",
|
|
40
|
+
"variants.sku": "text",
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
// Adding separate indexes for frequent query conditions
|
|
44
|
+
NewProductSchema.index({
|
|
45
|
+
workspaceId: 1,
|
|
46
|
+
name: 1,
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
NewProductSchema.index({
|
|
50
|
+
workspaceId: 1,
|
|
51
|
+
sku: 1,
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
NewProductSchema.index({
|
|
55
|
+
workspaceId: 1,
|
|
56
|
+
"variants.name": 1,
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
NewProductSchema.index({
|
|
60
|
+
workspaceId: 1,
|
|
61
|
+
"variants.sku": 1,
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
// Index for attachments existence check
|
|
65
|
+
NewProductSchema.index({
|
|
66
|
+
attachments: 1,
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
const NewProduct = mongoose.model("NewProduct", NewProductSchema);
|
|
70
|
+
|
|
71
|
+
module.exports = NewProduct;
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
const { model, Schema } = require("mongoose");
|
|
2
|
+
|
|
3
|
+
const NotificationSettingsSchema = new Schema(
|
|
4
|
+
{
|
|
5
|
+
workspaceId: {
|
|
6
|
+
type: Schema.Types.ObjectId,
|
|
7
|
+
ref: "Workspace",
|
|
8
|
+
default: null,
|
|
9
|
+
},
|
|
10
|
+
|
|
11
|
+
orders: {
|
|
12
|
+
type: {
|
|
13
|
+
createOrder: {
|
|
14
|
+
type: Boolean,
|
|
15
|
+
default: false,
|
|
16
|
+
},
|
|
17
|
+
orderAssign: {
|
|
18
|
+
type: Boolean,
|
|
19
|
+
default: false,
|
|
20
|
+
},
|
|
21
|
+
orderComment: {
|
|
22
|
+
type: Boolean,
|
|
23
|
+
default: false,
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
default: {
|
|
27
|
+
createOrder: false,
|
|
28
|
+
orderAssign: false,
|
|
29
|
+
orderComment: false,
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
|
|
33
|
+
products: {
|
|
34
|
+
type: Boolean,
|
|
35
|
+
default: false,
|
|
36
|
+
},
|
|
37
|
+
|
|
38
|
+
socialProfiles: {
|
|
39
|
+
type: {
|
|
40
|
+
socialProfileComment: {
|
|
41
|
+
type: Boolean,
|
|
42
|
+
default: false,
|
|
43
|
+
},
|
|
44
|
+
story: {
|
|
45
|
+
type: Boolean,
|
|
46
|
+
default: false,
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
default: {
|
|
50
|
+
socialProfileComment: false,
|
|
51
|
+
story: false,
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
|
|
55
|
+
conversation: {
|
|
56
|
+
type: {
|
|
57
|
+
instaMessage: {
|
|
58
|
+
type: Boolean,
|
|
59
|
+
default: false,
|
|
60
|
+
},
|
|
61
|
+
fbMessage: {
|
|
62
|
+
type: Boolean,
|
|
63
|
+
default: false,
|
|
64
|
+
},
|
|
65
|
+
whatsapp: {
|
|
66
|
+
type: Boolean,
|
|
67
|
+
default: false,
|
|
68
|
+
},
|
|
69
|
+
instaComment: {
|
|
70
|
+
type: Boolean,
|
|
71
|
+
default: false,
|
|
72
|
+
},
|
|
73
|
+
fbComment: {
|
|
74
|
+
type: Boolean,
|
|
75
|
+
default: false,
|
|
76
|
+
},
|
|
77
|
+
email: {
|
|
78
|
+
type: Boolean,
|
|
79
|
+
default: false,
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
default: {
|
|
83
|
+
instaMessage: false,
|
|
84
|
+
fbMessage: false,
|
|
85
|
+
instaComment: false,
|
|
86
|
+
fbComment: false,
|
|
87
|
+
email: false,
|
|
88
|
+
whatsapp: false,
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
|
|
92
|
+
taskManager: {
|
|
93
|
+
type: {
|
|
94
|
+
cardAssign: {
|
|
95
|
+
type: Boolean,
|
|
96
|
+
default: false,
|
|
97
|
+
},
|
|
98
|
+
cardMove: {
|
|
99
|
+
type: Boolean,
|
|
100
|
+
default: false,
|
|
101
|
+
},
|
|
102
|
+
},
|
|
103
|
+
default: {
|
|
104
|
+
cardAssign: false,
|
|
105
|
+
cardMove: false,
|
|
106
|
+
},
|
|
107
|
+
},
|
|
108
|
+
|
|
109
|
+
sound: {
|
|
110
|
+
type: {
|
|
111
|
+
play: {
|
|
112
|
+
type: Boolean,
|
|
113
|
+
default: true,
|
|
114
|
+
},
|
|
115
|
+
},
|
|
116
|
+
default: {
|
|
117
|
+
play: true,
|
|
118
|
+
},
|
|
119
|
+
},
|
|
120
|
+
|
|
121
|
+
default: {
|
|
122
|
+
type: Boolean,
|
|
123
|
+
default: true,
|
|
124
|
+
},
|
|
125
|
+
createdBy: { type: Schema.Types.ObjectId, ref: "User", default: null },
|
|
126
|
+
},
|
|
127
|
+
{ timestamps: true, toJSON: { virtuals: true }, toObject: { virtuals: true } }
|
|
128
|
+
);
|
|
129
|
+
|
|
130
|
+
module.exports = model("NotificationSettings", NotificationSettingsSchema);
|