shuttlepro-shared 1.3.13 → 1.3.14
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/constants/index.js +0 -15
- package/index.js +0 -8
- package/models/UserRole.js +119 -1
- package/models/Website.js +1 -0
- package/models.js +1 -62
- package/package.json +2 -13
- package/common/repositories/chatMember.repository.js +0 -9
- package/common/repositories/customerProfile.repository.js +0 -147
- package/common/repositories/descriptionTemplates.repository.js +0 -229
- package/common/repositories/index.js +0 -32
- package/common/repositories/integration.repository.js +0 -210
- package/common/repositories/label.repository.js +0 -95
- package/common/repositories/notificationSettings.repository.js +0 -95
- package/common/repositories/role.repository.js +0 -333
- package/common/repositories/settings.repository.js +0 -32
- package/common/repositories/shipper.repository.js +0 -77
- package/common/repositories/socialMediaSetting.repository.js +0 -33
- package/common/repositories/user.repository.js +0 -150
- package/common/repositories/userPermission.repository.js +0 -228
- package/common/repositories/userRepository.js +0 -31
- package/common/repositories/userRole.repository.js +0 -235
- package/common/repositories/userRolePermission.repository.js +0 -59
- package/common/repositories/workspace.repository.js +0 -147
- package/config/bull.js +0 -78
- package/config/config.js +0 -14
- package/config/database.js +0 -4
- package/config/index.js +0 -13
- package/config/redis.js +0 -196
- package/config/socket.js +0 -172
- package/models/AgentActivity.js +0 -192
- package/models/Assignment.js +0 -23
- package/models/BusinessDistribution.js +0 -23
- package/models/Card.js +0 -144
- package/models/CardComments.js +0 -33
- package/models/ChatMember.js +0 -17
- package/models/Chatbot.js +0 -20
- package/models/Checkpoint.js +0 -50
- package/models/City.js +0 -17
- package/models/Column.js +0 -28
- package/models/Conversation.js +0 -87
- package/models/Customer.js +0 -36
- package/models/CustomerProfile.js +0 -27
- package/models/DefaultRolePermission.js +0 -34
- package/models/DescriptionTemplate.js +0 -22
- package/models/Integration.js +0 -51
- package/models/Label.js +0 -42
- package/models/Message.js +0 -47
- package/models/NewProduct.js +0 -71
- package/models/NotificationSettings.js +0 -130
- package/models/Order.js +0 -236
- package/models/OrderProduct.js +0 -37
- package/models/Profile.js +0 -127
- package/models/Report.js +0 -27
- package/models/Setting.js +0 -18
- package/models/Shipper.js +0 -62
- package/models/SocialMediaSetting.js +0 -28
- package/models/Status.js +0 -58
- package/models/StatusType.js +0 -10
- package/models/Step.js +0 -50
- package/models/Type.js +0 -25
- package/models/UserWorkflow.js +0 -46
- package/models/Workspace.js +0 -308
- package/utils/decorator-factory.js +0 -264
- package/utils/logger.js +0 -41
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
const mongoose = require("mongoose");
|
|
2
|
-
const { Schema } = mongoose;
|
|
3
|
-
|
|
4
|
-
const businessDistributionSchema = new mongoose.Schema(
|
|
5
|
-
{
|
|
6
|
-
name: { type: String, default: "" },
|
|
7
|
-
deliveryCharges: { type: String, default: "" },
|
|
8
|
-
shippers: [],
|
|
9
|
-
type: {
|
|
10
|
-
type: String,
|
|
11
|
-
enum: ["default", "cities"],
|
|
12
|
-
required: true,
|
|
13
|
-
},
|
|
14
|
-
index: { type: String, default: "" },
|
|
15
|
-
workspaceId: { type: String, default: "" },
|
|
16
|
-
},
|
|
17
|
-
{ timestamps: true, toJSON: { virtuals: true }, toObject: { virtuals: true } }
|
|
18
|
-
);
|
|
19
|
-
|
|
20
|
-
module.exports = mongoose.model(
|
|
21
|
-
"BusinessDistribution",
|
|
22
|
-
businessDistributionSchema
|
|
23
|
-
);
|
package/models/Card.js
DELETED
|
@@ -1,144 +0,0 @@
|
|
|
1
|
-
const mongoose = require("mongoose");
|
|
2
|
-
const { DYNAMIC_FIELD_TYPES } = require("../constants");
|
|
3
|
-
|
|
4
|
-
const cardSchema = new mongoose.Schema(
|
|
5
|
-
{
|
|
6
|
-
cardId: { type: String, required: true },
|
|
7
|
-
columnId: {
|
|
8
|
-
type: mongoose.Schema.Types.ObjectId,
|
|
9
|
-
ref: "Column",
|
|
10
|
-
required: false,
|
|
11
|
-
default: null,
|
|
12
|
-
set: (v) => (v === "" ? null : v),
|
|
13
|
-
},
|
|
14
|
-
title: {
|
|
15
|
-
type: String,
|
|
16
|
-
default: "",
|
|
17
|
-
// required: true,
|
|
18
|
-
},
|
|
19
|
-
description: {
|
|
20
|
-
type: String,
|
|
21
|
-
},
|
|
22
|
-
priority: {
|
|
23
|
-
type: String,
|
|
24
|
-
enum: ["high", "medium", "low"],
|
|
25
|
-
},
|
|
26
|
-
typeId: [
|
|
27
|
-
{
|
|
28
|
-
type: mongoose.Schema.Types.ObjectId,
|
|
29
|
-
ref: "Label",
|
|
30
|
-
},
|
|
31
|
-
],
|
|
32
|
-
type: {
|
|
33
|
-
type: String,
|
|
34
|
-
required: true,
|
|
35
|
-
},
|
|
36
|
-
assignedBy: {
|
|
37
|
-
type: Object,
|
|
38
|
-
},
|
|
39
|
-
attachmentId: {
|
|
40
|
-
type: mongoose.Schema.Types.ObjectId,
|
|
41
|
-
ref: "Attachment",
|
|
42
|
-
},
|
|
43
|
-
attachments: {
|
|
44
|
-
type: [String],
|
|
45
|
-
default: [],
|
|
46
|
-
},
|
|
47
|
-
product: {
|
|
48
|
-
type: Object,
|
|
49
|
-
},
|
|
50
|
-
courierId: {
|
|
51
|
-
type: String,
|
|
52
|
-
},
|
|
53
|
-
orderId: {
|
|
54
|
-
type: Object,
|
|
55
|
-
},
|
|
56
|
-
conversation: {
|
|
57
|
-
type: Object,
|
|
58
|
-
},
|
|
59
|
-
deleted: {
|
|
60
|
-
type: Boolean,
|
|
61
|
-
default: false,
|
|
62
|
-
},
|
|
63
|
-
isExpired: {
|
|
64
|
-
type: Boolean,
|
|
65
|
-
default: false,
|
|
66
|
-
},
|
|
67
|
-
isUpdated: {
|
|
68
|
-
type: Boolean,
|
|
69
|
-
default: false,
|
|
70
|
-
},
|
|
71
|
-
completionDate: {
|
|
72
|
-
type: String,
|
|
73
|
-
},
|
|
74
|
-
updatedDate: {
|
|
75
|
-
type: Date,
|
|
76
|
-
default: Date.now,
|
|
77
|
-
},
|
|
78
|
-
ticketId: {
|
|
79
|
-
type: String,
|
|
80
|
-
},
|
|
81
|
-
category: {
|
|
82
|
-
type: String,
|
|
83
|
-
default: "ticket",
|
|
84
|
-
enum: ["ticket", "conversation"],
|
|
85
|
-
},
|
|
86
|
-
dynamicFieldValue: [
|
|
87
|
-
{
|
|
88
|
-
dynamicFieldId: {
|
|
89
|
-
type: String,
|
|
90
|
-
default: "",
|
|
91
|
-
},
|
|
92
|
-
fieldType: {
|
|
93
|
-
type: String,
|
|
94
|
-
enum: DYNAMIC_FIELD_TYPES,
|
|
95
|
-
},
|
|
96
|
-
fieldValueId: {
|
|
97
|
-
type: mongoose.Schema.Types.Mixed,
|
|
98
|
-
},
|
|
99
|
-
},
|
|
100
|
-
],
|
|
101
|
-
workspaceId: { type: String, default: "" },
|
|
102
|
-
activities: [
|
|
103
|
-
{
|
|
104
|
-
data: {
|
|
105
|
-
type: mongoose.Schema.Types.Mixed,
|
|
106
|
-
default: {},
|
|
107
|
-
},
|
|
108
|
-
},
|
|
109
|
-
],
|
|
110
|
-
},
|
|
111
|
-
{ timestamps: true, toJSON: { virtuals: true }, toObject: { virtuals: true } }
|
|
112
|
-
);
|
|
113
|
-
|
|
114
|
-
cardSchema.index({ workspaceId: 1, createdAt: 1 }); // Common filter
|
|
115
|
-
|
|
116
|
-
// Virtual for the assignedTo user
|
|
117
|
-
cardSchema.virtual("assignedToUser", {
|
|
118
|
-
ref: "User",
|
|
119
|
-
localField: "assignedTo",
|
|
120
|
-
foreignField: "_id",
|
|
121
|
-
});
|
|
122
|
-
|
|
123
|
-
// Virtual for the attachment
|
|
124
|
-
cardSchema.virtual("attachment", {
|
|
125
|
-
ref: "Attachment",
|
|
126
|
-
localField: "attachmentId",
|
|
127
|
-
foreignField: "_id",
|
|
128
|
-
});
|
|
129
|
-
|
|
130
|
-
// Virtual for the comment
|
|
131
|
-
cardSchema.virtual("comments", {
|
|
132
|
-
ref: "CardComment",
|
|
133
|
-
localField: "_id",
|
|
134
|
-
foreignField: "cardId",
|
|
135
|
-
});
|
|
136
|
-
|
|
137
|
-
// Virtual for the assignmentList
|
|
138
|
-
cardSchema.virtual("assignedTo", {
|
|
139
|
-
ref: "Assignment",
|
|
140
|
-
localField: "_id", // Change to 'cardId' to match the 'cardId' field in the Assignment model
|
|
141
|
-
foreignField: "cardId",
|
|
142
|
-
});
|
|
143
|
-
|
|
144
|
-
module.exports = mongoose.model("Card", cardSchema);
|
package/models/CardComments.js
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
const mongoose = require("mongoose");
|
|
2
|
-
|
|
3
|
-
const cardCommentSchema = new mongoose.Schema(
|
|
4
|
-
{
|
|
5
|
-
cardId: {
|
|
6
|
-
type: mongoose.Schema.Types.ObjectId,
|
|
7
|
-
ref: "Card",
|
|
8
|
-
required: true,
|
|
9
|
-
},
|
|
10
|
-
commentText: {
|
|
11
|
-
type: String,
|
|
12
|
-
required: true,
|
|
13
|
-
},
|
|
14
|
-
createdBy: {
|
|
15
|
-
type: Object,
|
|
16
|
-
required: true,
|
|
17
|
-
},
|
|
18
|
-
readers: {
|
|
19
|
-
type: [],
|
|
20
|
-
default: [],
|
|
21
|
-
},
|
|
22
|
-
deleted: {
|
|
23
|
-
type: Boolean,
|
|
24
|
-
default: false,
|
|
25
|
-
},
|
|
26
|
-
updatedDate: {
|
|
27
|
-
type: Date,
|
|
28
|
-
},
|
|
29
|
-
},
|
|
30
|
-
{ timestamps: true }
|
|
31
|
-
);
|
|
32
|
-
|
|
33
|
-
module.exports = mongoose.model("CardComment", cardCommentSchema);
|
package/models/ChatMember.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
const { Schema, model } = require("mongoose");
|
|
2
|
-
|
|
3
|
-
const ChatMemberSchema = new Schema(
|
|
4
|
-
{
|
|
5
|
-
userName: { type: String, default: "" },
|
|
6
|
-
phoneNo: { type: String, default: "" },
|
|
7
|
-
email: { type: String, default: "" },
|
|
8
|
-
workspaceId: {
|
|
9
|
-
type: Schema.Types.ObjectId,
|
|
10
|
-
ref: "Workspace",
|
|
11
|
-
default: null,
|
|
12
|
-
},
|
|
13
|
-
},
|
|
14
|
-
{ timestamps: true, toJSON: { virtuals: true }, toObject: { virtuals: true } }
|
|
15
|
-
);
|
|
16
|
-
|
|
17
|
-
module.exports = model("ChatMember", ChatMemberSchema);
|
package/models/Chatbot.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
const { Schema, model } = require("mongoose");
|
|
2
|
-
const ChatbotSchema = new Schema(
|
|
3
|
-
{
|
|
4
|
-
name: { type: String, default: "" },
|
|
5
|
-
workspaceId: {
|
|
6
|
-
type: String,
|
|
7
|
-
default: "",
|
|
8
|
-
},
|
|
9
|
-
initialMessage: {
|
|
10
|
-
type: String,
|
|
11
|
-
default: "",
|
|
12
|
-
},
|
|
13
|
-
expiryTime: {
|
|
14
|
-
type: Number,
|
|
15
|
-
default: 300,
|
|
16
|
-
},
|
|
17
|
-
},
|
|
18
|
-
{ timestamps: true, toJSON: { virtuals: true }, toObject: { virtuals: true } }
|
|
19
|
-
);
|
|
20
|
-
module.exports = model("Chatbot", ChatbotSchema);
|
package/models/Checkpoint.js
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
const { Schema, model } = require("mongoose");
|
|
2
|
-
const Order = require("./Order");
|
|
3
|
-
const CheckpointSchema = new Schema(
|
|
4
|
-
{
|
|
5
|
-
bookingDate: { type: String, default: "" },
|
|
6
|
-
shipperType: { type: String, default: "" },
|
|
7
|
-
statusTime: { type: String, default: "" },
|
|
8
|
-
orderId: { type: Schema.Types.ObjectId, default: null, ref: "Order" },
|
|
9
|
-
statusId: { type: Schema.Types.ObjectId, default: null, ref: "Status" },
|
|
10
|
-
statusValue: { type: String, default: "" },
|
|
11
|
-
description: { type: String, default: "" },
|
|
12
|
-
workspaceId: {
|
|
13
|
-
type: Schema.Types.ObjectId,
|
|
14
|
-
ref: "Workspace",
|
|
15
|
-
default: null,
|
|
16
|
-
},
|
|
17
|
-
},
|
|
18
|
-
{ timestamps: true, toJSON: { virtuals: true }, toObject: { virtuals: true } }
|
|
19
|
-
);
|
|
20
|
-
|
|
21
|
-
const initialStatuses = {
|
|
22
|
-
POSTEX: "departed to postex. warehouse",
|
|
23
|
-
DAEWOO: "booking",
|
|
24
|
-
TRAX: "shipment - arrived at origin",
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
CheckpointSchema.post("save", async function (doc) {
|
|
28
|
-
try {
|
|
29
|
-
if (
|
|
30
|
-
doc?.shipperType &&
|
|
31
|
-
doc?.statusValue.toLowerCase() === initialStatuses[doc?.shipperType]
|
|
32
|
-
) {
|
|
33
|
-
let order = await Order.findOneAndUpdate(
|
|
34
|
-
{
|
|
35
|
-
_id: doc.orderId,
|
|
36
|
-
workspaceId: doc.workspaceId,
|
|
37
|
-
},
|
|
38
|
-
{ $set: { statusUpdatedAt: doc.bookingDate } },
|
|
39
|
-
{ new: true }
|
|
40
|
-
);
|
|
41
|
-
console.log(order, "initial status from shipper");
|
|
42
|
-
}
|
|
43
|
-
return { code: 200 };
|
|
44
|
-
} catch (err) {
|
|
45
|
-
console.log("err", err);
|
|
46
|
-
return { code: 400 };
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
module.exports = model("Checkpoint", CheckpointSchema);
|
package/models/City.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
const { Schema, model } = require("mongoose");
|
|
2
|
-
|
|
3
|
-
const CitySchema = new Schema(
|
|
4
|
-
{
|
|
5
|
-
cityName: { type: String, default: "" },
|
|
6
|
-
correctedCityName: { type: String, default: "" },
|
|
7
|
-
cityCode: { type: String, default: "" },
|
|
8
|
-
area: { type: String, default: "" },
|
|
9
|
-
shipperType: { type: String, default: "" },
|
|
10
|
-
webCityId: { type: String, default: "" },
|
|
11
|
-
hubId: { type: String, default: "" },
|
|
12
|
-
body: {},
|
|
13
|
-
},
|
|
14
|
-
{ timestamps: true, toJSON: { virtuals: true }, toObject: { virtuals: true } }
|
|
15
|
-
);
|
|
16
|
-
|
|
17
|
-
module.exports = model("City", CitySchema);
|
package/models/Column.js
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
const mongoose = require("mongoose");
|
|
2
|
-
|
|
3
|
-
const columnSchema = new mongoose.Schema(
|
|
4
|
-
{
|
|
5
|
-
title: {
|
|
6
|
-
type: String,
|
|
7
|
-
required: true,
|
|
8
|
-
},
|
|
9
|
-
position: {
|
|
10
|
-
type: Number,
|
|
11
|
-
required: true,
|
|
12
|
-
},
|
|
13
|
-
deleted: {
|
|
14
|
-
type: Boolean,
|
|
15
|
-
default: false,
|
|
16
|
-
},
|
|
17
|
-
workspaceId: { type: String, default: "" },
|
|
18
|
-
},
|
|
19
|
-
{ timestamps: true, toJSON: { virtuals: true }, toObject: { virtuals: true } }
|
|
20
|
-
);
|
|
21
|
-
|
|
22
|
-
columnSchema.virtual("cardList", {
|
|
23
|
-
ref: "Card",
|
|
24
|
-
localField: "_id", // Change to '_id' to match the column's '_id'
|
|
25
|
-
foreignField: "columnId",
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
module.exports = mongoose.model("Column", columnSchema);
|
package/models/Conversation.js
DELETED
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
const mongoose = require("mongoose");
|
|
2
|
-
const { Schema } = mongoose;
|
|
3
|
-
|
|
4
|
-
const draftSchema = new mongoose.Schema({
|
|
5
|
-
_id: {
|
|
6
|
-
type: Schema.Types.ObjectId,
|
|
7
|
-
default: () => new mongoose.Types.ObjectId(),
|
|
8
|
-
},
|
|
9
|
-
messageBody: {},
|
|
10
|
-
createdBy: { type: Schema.Types.ObjectId, ref: "User" },
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
const conversationSchema = new mongoose.Schema(
|
|
14
|
-
{
|
|
15
|
-
platformType: {
|
|
16
|
-
type: String,
|
|
17
|
-
enum: [
|
|
18
|
-
"gmail",
|
|
19
|
-
"instagram",
|
|
20
|
-
"whatsapp",
|
|
21
|
-
"linkedin",
|
|
22
|
-
"facebook",
|
|
23
|
-
"tiktok",
|
|
24
|
-
"outlook",
|
|
25
|
-
"webChat",
|
|
26
|
-
"smtp_gmail",
|
|
27
|
-
],
|
|
28
|
-
required: true,
|
|
29
|
-
},
|
|
30
|
-
members: [{ type: Schema.Types.ObjectId, ref: "User" }],
|
|
31
|
-
conversationType: {
|
|
32
|
-
type: String,
|
|
33
|
-
enum: ["comment", "message", "email"],
|
|
34
|
-
required: true,
|
|
35
|
-
},
|
|
36
|
-
messageCount: { type: Number, default: 0 },
|
|
37
|
-
conversationStatus: {
|
|
38
|
-
type: String,
|
|
39
|
-
enum: ["assigned", "unassigned", "archived"],
|
|
40
|
-
required: true,
|
|
41
|
-
default: "unassigned",
|
|
42
|
-
},
|
|
43
|
-
assignId: { type: Schema.Types.ObjectId, ref: "User", default: null },
|
|
44
|
-
platformId: {
|
|
45
|
-
type: Schema.Types.ObjectId,
|
|
46
|
-
ref: "Integration",
|
|
47
|
-
default: null,
|
|
48
|
-
},
|
|
49
|
-
labels: [{ type: Schema.Types.ObjectId, ref: "Label" }],
|
|
50
|
-
title: { type: String },
|
|
51
|
-
platformTimestamp: { type: String, default: "" },
|
|
52
|
-
status: {
|
|
53
|
-
type: String,
|
|
54
|
-
enum: ["open", "processing", "hold", "closed"],
|
|
55
|
-
required: true,
|
|
56
|
-
default: "open",
|
|
57
|
-
},
|
|
58
|
-
isSpam: { type: Boolean, default: false },
|
|
59
|
-
threadId: { type: String, default: "" },
|
|
60
|
-
messageId: { type: String, default: "" },
|
|
61
|
-
profileId: { type: Schema.Types.ObjectId, ref: "Profile" },
|
|
62
|
-
conversationCloseTime: { type: String },
|
|
63
|
-
workspaceId: { type: Schema.Types.ObjectId, ref: "Workspace" },
|
|
64
|
-
postId: { type: String, default: "" },
|
|
65
|
-
postUrl: { type: String, default: "" },
|
|
66
|
-
sender: { type: String, default: "" },
|
|
67
|
-
reasonForClosing: {
|
|
68
|
-
reason: { type: String, default: "" },
|
|
69
|
-
category: { type: String, default: "" },
|
|
70
|
-
color: { type: String, default: "" },
|
|
71
|
-
closedBy: { type: Schema.Types.ObjectId, ref: "User", default: null },
|
|
72
|
-
},
|
|
73
|
-
integratedAccount: { type: String, default: "" },
|
|
74
|
-
isRead: { type: Boolean, default: false },
|
|
75
|
-
ticketId: { type: String, default: "" },
|
|
76
|
-
draft: [draftSchema],
|
|
77
|
-
isWebchatTicket: { type: Boolean, default: false },
|
|
78
|
-
webchatComplaintType: { type: String, default: null },
|
|
79
|
-
isComposed: { type: Boolean, default: false },
|
|
80
|
-
utilityMessage: [],
|
|
81
|
-
orderId: [],
|
|
82
|
-
isFetch: { type: Boolean, default: true },
|
|
83
|
-
},
|
|
84
|
-
{ timestamps: true, toJSON: { virtuals: true }, toObject: { virtuals: true } }
|
|
85
|
-
);
|
|
86
|
-
|
|
87
|
-
module.exports = mongoose.model("Conversation", conversationSchema);
|
package/models/Customer.js
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
const mongoose = require("mongoose");
|
|
2
|
-
const { Schema } = mongoose;
|
|
3
|
-
|
|
4
|
-
const CustomerSchema = new Schema(
|
|
5
|
-
{
|
|
6
|
-
name: { type: String, default: "" },
|
|
7
|
-
email: { type: String, default: "" },
|
|
8
|
-
phone: { type: String, default: "" },
|
|
9
|
-
city: { type: String, default: "" },
|
|
10
|
-
country: { type: String, default: "pk" },
|
|
11
|
-
defaultAddress: { type: String, default: "" },
|
|
12
|
-
currentShippingAddress: {},
|
|
13
|
-
addresses: [],
|
|
14
|
-
workspaceId: {
|
|
15
|
-
type: Schema.Types.ObjectId,
|
|
16
|
-
ref: "Workspace",
|
|
17
|
-
default: null,
|
|
18
|
-
},
|
|
19
|
-
phone1: { type: String, default: "" },
|
|
20
|
-
isBlackListed: { type: Boolean, default: false },
|
|
21
|
-
createdBy: {
|
|
22
|
-
type: Schema.Types.ObjectId,
|
|
23
|
-
ref: "User",
|
|
24
|
-
},
|
|
25
|
-
updatedBy: {
|
|
26
|
-
type: Schema.Types.ObjectId,
|
|
27
|
-
ref: "User",
|
|
28
|
-
},
|
|
29
|
-
isDeleted: { type: Boolean, default: false },
|
|
30
|
-
},
|
|
31
|
-
{ timestamps: true, toJSON: { virtuals: true }, toObject: { virtuals: true } }
|
|
32
|
-
);
|
|
33
|
-
|
|
34
|
-
const Customer = mongoose.model("Customer", CustomerSchema);
|
|
35
|
-
|
|
36
|
-
module.exports = Customer;
|
|
@@ -1,27 +0,0 @@
|
|
|
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
|
-
blackList: { type: Boolean, default: false },
|
|
12
|
-
workspaceId: {
|
|
13
|
-
type: Schema.Types.ObjectId,
|
|
14
|
-
ref: "Workspace",
|
|
15
|
-
default: null,
|
|
16
|
-
},
|
|
17
|
-
mergedId: {
|
|
18
|
-
type: Schema.Types.ObjectId,
|
|
19
|
-
ref: "CustomerProfile",
|
|
20
|
-
default: null,
|
|
21
|
-
},
|
|
22
|
-
body: {},
|
|
23
|
-
},
|
|
24
|
-
{ timestamps: true, toJSON: { virtuals: true }, toObject: { virtuals: true } }
|
|
25
|
-
);
|
|
26
|
-
|
|
27
|
-
module.exports = mongoose.model("CustomerProfile", CustomerProfileSchema);
|
|
@@ -1,34 +0,0 @@
|
|
|
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
|
-
);
|
|
@@ -1,22 +0,0 @@
|
|
|
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;
|
package/models/Integration.js
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
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
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
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;
|
package/models/Message.js
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
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);
|