shuttlepro-shared 1.3.14 → 1.3.16

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.
Files changed (64) hide show
  1. package/common/repositories/chatMember.repository.js +9 -0
  2. package/common/repositories/customerProfile.repository.js +147 -0
  3. package/common/repositories/descriptionTemplates.repository.js +229 -0
  4. package/common/repositories/index.js +32 -0
  5. package/common/repositories/integration.repository.js +210 -0
  6. package/common/repositories/label.repository.js +95 -0
  7. package/common/repositories/notificationSettings.repository.js +95 -0
  8. package/common/repositories/role.repository.js +333 -0
  9. package/common/repositories/settings.repository.js +32 -0
  10. package/common/repositories/shipper.repository.js +77 -0
  11. package/common/repositories/socialMediaSetting.repository.js +33 -0
  12. package/common/repositories/user.repository.js +150 -0
  13. package/common/repositories/userPermission.repository.js +228 -0
  14. package/common/repositories/userRepository.js +31 -0
  15. package/common/repositories/userRole.repository.js +235 -0
  16. package/common/repositories/userRolePermission.repository.js +59 -0
  17. package/common/repositories/workspace.repository.js +147 -0
  18. package/config/bull.js +78 -0
  19. package/config/config.js +14 -0
  20. package/config/database.js +4 -0
  21. package/config/index.js +13 -0
  22. package/config/redis.js +212 -0
  23. package/config/socket.js +172 -0
  24. package/constants/index.js +15 -0
  25. package/index.js +8 -0
  26. package/models/AgentActivity.js +192 -0
  27. package/models/Assignment.js +23 -0
  28. package/models/BusinessDistribution.js +23 -0
  29. package/models/Card.js +144 -0
  30. package/models/CardComments.js +33 -0
  31. package/models/ChatMember.js +17 -0
  32. package/models/Chatbot.js +20 -0
  33. package/models/Checkpoint.js +50 -0
  34. package/models/City.js +17 -0
  35. package/models/Column.js +28 -0
  36. package/models/Conversation.js +87 -0
  37. package/models/Customer.js +36 -0
  38. package/models/CustomerProfile.js +27 -0
  39. package/models/DefaultRolePermission.js +34 -0
  40. package/models/DescriptionTemplate.js +22 -0
  41. package/models/Integration.js +51 -0
  42. package/models/Label.js +42 -0
  43. package/models/Message.js +47 -0
  44. package/models/NewProduct.js +71 -0
  45. package/models/NotificationSettings.js +130 -0
  46. package/models/Order.js +236 -0
  47. package/models/OrderProduct.js +37 -0
  48. package/models/Profile.js +127 -0
  49. package/models/Report.js +27 -0
  50. package/models/Setting.js +18 -0
  51. package/models/Shipper.js +62 -0
  52. package/models/SocialMediaSetting.js +28 -0
  53. package/models/Status.js +58 -0
  54. package/models/StatusType.js +10 -0
  55. package/models/Step.js +50 -0
  56. package/models/Type.js +25 -0
  57. package/models/UserRole.js +1 -119
  58. package/models/UserWorkflow.js +46 -0
  59. package/models/Website.js +0 -1
  60. package/models/Workspace.js +318 -0
  61. package/models.js +62 -1
  62. package/package.json +13 -2
  63. package/utils/decorator-factory.js +264 -0
  64. package/utils/logger.js +41 -0
@@ -0,0 +1,192 @@
1
+ const mongoose = require("mongoose");
2
+ const { Schema } = mongoose;
3
+
4
+ const breakSchema = new mongoose.Schema({
5
+ refId: { type: String, required: true },
6
+ breakId: { type: String, required: false },
7
+ startTime: { type: Date, required: true },
8
+ endTime: { type: Date, required: false },
9
+ });
10
+
11
+ const responseSchema = new mongoose.Schema({
12
+ queryMessageId: { type: [String], default: [] },
13
+ responseMessageId: { type: [String], default: [] },
14
+ responseTime: { type: Number, required: false },
15
+ accuracy: { type: Number, required: false, default: 10 },
16
+ });
17
+
18
+ const activitySchema = new mongoose.Schema({
19
+ refId: { type: String, required: true },
20
+ type: {
21
+ type: String,
22
+ required: true,
23
+ default: "other",
24
+ enum: ["conversation", "ticket", "order", "other"],
25
+ },
26
+ platformName: { type: String, required: false },
27
+ platformType: { type: String, required: false },
28
+ customerName: { type: String, default: "", required: false },
29
+ conversationId: { type: String, default: "", required: false },
30
+ profileId: { type: String, required: false },
31
+ conversationType: {
32
+ type: String,
33
+ enum: ["email", "comment", "message", ""],
34
+ default: "",
35
+ required: false,
36
+ },
37
+ status: { type: String, required: false, default: "unassigned" },
38
+ sourceType: { type: String, required: false, default: "normal" },
39
+ labels: [{ type: Schema.Types.ObjectId, ref: "Label" }],
40
+ platformId: { type: String, required: false },
41
+ assignTime: { type: Date, required: false },
42
+ qaScore: { type: Number, required: false, default: 10 },
43
+ startTime: { type: String, required: false },
44
+ endTime: { type: String, required: false },
45
+ resolutionTime: { type: String, required: false },
46
+ responses: { type: [responseSchema], default: [] },
47
+ remarks: { type: String, required: false },
48
+ avgAccuracy: { type: Number, required: false, default: 10 },
49
+ sender: { type: String, required: "" },
50
+ });
51
+
52
+ const totalActivitySchema = new mongoose.Schema({
53
+ type: { type: String, required: true },
54
+ platformType: { type: String, required: false },
55
+ count: { type: Number, required: true },
56
+ });
57
+
58
+ const agentActivitySchema = new mongoose.Schema(
59
+ {
60
+ _id: {
61
+ type: mongoose.Schema.Types.ObjectId,
62
+ default: () => new mongoose.Types.ObjectId(),
63
+ },
64
+ agentId: { type: String, required: true },
65
+ agentRole: { type: String, default: "" },
66
+ agentName: { type: String, required: false },
67
+ agentShift: { type: Object, default: {}, required: false },
68
+ workspaceId: {
69
+ type: mongoose.Schema.Types.ObjectId,
70
+ required: true,
71
+ ref: "Workspace",
72
+ },
73
+ date: { type: String, required: true },
74
+ lateMinutes: {
75
+ type: Number,
76
+ default: 0,
77
+ },
78
+ earlyLeaveMinutes: {
79
+ type: Number,
80
+ default: 0,
81
+ },
82
+ shiftStartTime: { type: [Date], default: [] },
83
+ shiftEndTime: { type: [Date], default: [] },
84
+ shifts: [
85
+ {
86
+ shiftStartTime: { type: Date, required: true, default: null },
87
+ shiftEndTime: { type: Date, required: false, default: null },
88
+ },
89
+ ],
90
+ isLate: { type: Boolean, required: true, default: false },
91
+ isEarlyLeave: { type: Boolean, required: true, default: false },
92
+ breaks: { type: [breakSchema], default: [] },
93
+ activities: { type: [activitySchema], default: [] },
94
+ totalPsc: { type: Number, required: false, default: 0 },
95
+ totalQa: { type: Number, required: false, default: 0 },
96
+ weightedQa: { type: Number, required: false, default: 0 },
97
+ weightedPsc: { type: Number, required: false, default: 0 },
98
+ kpiScore: { type: Number, required: false, default: 0 },
99
+ totalActivities: { type: [totalActivitySchema], default: [] },
100
+ totalWorkTime: { type: Number, required: false, default: 0 },
101
+ totalBreakTime: { type: Number, required: false, default: 0 },
102
+ totalIdleTime: { type: Number, required: false, default: 0 },
103
+ },
104
+ { timestamps: true, toJSON: { virtuals: true }, toObject: { virtuals: true } }
105
+ );
106
+
107
+ agentActivitySchema.index({ workspaceId: 1 });
108
+ agentActivitySchema.index({ date: 1 });
109
+ agentActivitySchema.index({ agentId: 1 });
110
+ agentActivitySchema.index({ "activities.platformId": 1 });
111
+ agentActivitySchema.index({ "activities.labels": 1 });
112
+ agentActivitySchema.index({ workspaceId: 1, date: 1, agentId: 1 });
113
+ agentActivitySchema.index({
114
+ workspaceId: 1,
115
+ date: 1,
116
+ agentId: 1,
117
+ "activities.platformId": 1,
118
+ "activities.labels": 1,
119
+ });
120
+ agentActivitySchema.index({
121
+ workspaceId: 1,
122
+ date: 1,
123
+ agentId: 1,
124
+ "activities.platformId": 1,
125
+ });
126
+ agentActivitySchema.index({
127
+ workspaceId: 1,
128
+ date: 1,
129
+ agentId: 1,
130
+ "activities.labels": 1,
131
+ });
132
+ agentActivitySchema.index(
133
+ { "activities.platformId": 1, "activities.labels": 1 },
134
+ {
135
+ partialFilterExpression: {
136
+ "activities.platformId": { $exists: true },
137
+ "activities.labels": { $exists: true },
138
+ },
139
+ }
140
+ );
141
+ const AgentActivity = mongoose.model("AgentActivity", agentActivitySchema);
142
+
143
+ const findOneAndUpdateAgentActivity = async (
144
+ findQuery = {},
145
+ updateQuery = null
146
+ ) => {
147
+ try {
148
+ if (!findQuery || Object.values(findQuery).length === 0) {
149
+ console.log("Find Query is required.");
150
+ return null;
151
+ }
152
+
153
+ const agentActivityForActivitiesUpdated = await AgentActivity.findOne(
154
+ findQuery
155
+ ).sort({ createdAt: -1 });
156
+
157
+ if (!agentActivityForActivitiesUpdated) {
158
+ console.log("No matching record found.");
159
+ return null;
160
+ }
161
+
162
+ const bsonSize = require("bson").calculateObjectSize(
163
+ agentActivityForActivitiesUpdated
164
+ );
165
+
166
+ if (bsonSize <= 1000000) {
167
+ return await AgentActivity.findOneAndUpdate(findQuery, updateQuery);
168
+ } else {
169
+ const { breaks, activities, totalActivities, ...restData } =
170
+ agentActivityForActivitiesUpdated.toObject();
171
+
172
+ const newAgentActivity = await AgentActivity.create({
173
+ ...restData,
174
+ });
175
+
176
+ const agentActivityRecord = await AgentActivity.findOneAndUpdate(
177
+ { ...findQuery, _id: newAgentActivity._id },
178
+ updateQuery
179
+ );
180
+
181
+ return agentActivityRecord;
182
+ }
183
+ } catch (err) {
184
+ console.error("Error:", err);
185
+ return null;
186
+ }
187
+ };
188
+
189
+ module.exports = {
190
+ AgentActivity,
191
+ findOneAndUpdateAgentActivity,
192
+ };
@@ -0,0 +1,23 @@
1
+ const mongoose = require("mongoose");
2
+
3
+ const assignmentSchema = new mongoose.Schema({
4
+ cardId: {
5
+ type: mongoose.Schema.Types.ObjectId,
6
+ ref: "Card",
7
+ required: true,
8
+ },
9
+ id: {
10
+ type: String,
11
+ required: true,
12
+ },
13
+ name: {
14
+ type: String,
15
+ },
16
+ email: {
17
+ type: String,
18
+ },
19
+ });
20
+
21
+ const Assignment = mongoose.model("Assignment", assignmentSchema);
22
+
23
+ module.exports = Assignment;
@@ -0,0 +1,23 @@
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 ADDED
@@ -0,0 +1,144 @@
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);
@@ -0,0 +1,33 @@
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);
@@ -0,0 +1,17 @@
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);
@@ -0,0 +1,20 @@
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);
@@ -0,0 +1,50 @@
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 ADDED
@@ -0,0 +1,17 @@
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);
@@ -0,0 +1,28 @@
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);
@@ -0,0 +1,87 @@
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);
@@ -0,0 +1,36 @@
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;