shuttlepro-shared 1.3.13 → 1.3.15
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.
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
const CustomerTimeline = require("../../models/CustomerTimeline");
|
|
2
|
+
|
|
3
|
+
const createCustomerTimeline = async (data) => {
|
|
4
|
+
const newTimeline = new CustomerTimeline(data);
|
|
5
|
+
return await newTimeline.save();
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
const findCustomerTimelinesByWorkspaceId = async (workspaceId) => {
|
|
9
|
+
return await CustomerTimeline.find({ workspaceId }).lean().exec();
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
const findCustomerTimelinesByWorkspace = async (workspaceId, filter = {}) => {
|
|
13
|
+
return await CustomerTimeline.find({ workspaceId, ...filter })
|
|
14
|
+
.lean()
|
|
15
|
+
.exec();
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const findCustomerTimelineByFilter = async (filter = {}, bodyFilter = {}) => {
|
|
19
|
+
const all = await CustomerTimeline.find(filter).lean().exec();
|
|
20
|
+
|
|
21
|
+
return (
|
|
22
|
+
all.find((item) =>
|
|
23
|
+
Object.entries(bodyFilter).every(
|
|
24
|
+
([key, value]) => item.body?.[key] === value
|
|
25
|
+
)
|
|
26
|
+
) || null
|
|
27
|
+
);
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const findAllCustomerTimelinesByFilter = async (
|
|
31
|
+
filter = {},
|
|
32
|
+
bodyFilter = {}
|
|
33
|
+
) => {
|
|
34
|
+
const all = await CustomerTimeline.find(filter).lean().exec();
|
|
35
|
+
return all.filter((item) =>
|
|
36
|
+
Object.entries(bodyFilter).every(
|
|
37
|
+
([key, value]) => item.body?.[key] === value
|
|
38
|
+
)
|
|
39
|
+
);
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const updateCustomerTimeline = async (id, data) => {
|
|
43
|
+
return await CustomerTimeline.findByIdAndUpdate(id, data, {
|
|
44
|
+
new: true,
|
|
45
|
+
}).exec();
|
|
46
|
+
};
|
|
47
|
+
const updateManyCustomerTimelinesByFilter = async (filter = {}, data = {}) => {
|
|
48
|
+
await CustomerTimeline.updateMany(filter, data).exec();
|
|
49
|
+
const updatedDocs = await CustomerTimeline.find(query).lean().exec();
|
|
50
|
+
return updatedDocs;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
const updateCustomerTimelineByFilter = async (filter, data) => {
|
|
54
|
+
return await CustomerTimeline.findOneAndUpdate(filter, data, {
|
|
55
|
+
new: true,
|
|
56
|
+
}).exec();
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
const deleteCustomerTimeline = async (id) => {
|
|
60
|
+
return await CustomerTimeline.findByIdAndDelete(id).exec();
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
const deleteAllCustomerTimelinesByWorkspace = async (workspaceId) => {
|
|
64
|
+
return await CustomerTimeline.deleteMany({ workspaceId }).exec();
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
module.exports = {
|
|
68
|
+
createCustomerTimeline,
|
|
69
|
+
findCustomerTimelinesByWorkspaceId,
|
|
70
|
+
findCustomerTimelinesByWorkspace,
|
|
71
|
+
findCustomerTimelineByFilter,
|
|
72
|
+
updateCustomerTimeline,
|
|
73
|
+
updateCustomerTimelineByFilter,
|
|
74
|
+
deleteCustomerTimeline,
|
|
75
|
+
deleteAllCustomerTimelinesByWorkspace,
|
|
76
|
+
findAllCustomerTimelinesByFilter,
|
|
77
|
+
updateManyCustomerTimelinesByFilter,
|
|
78
|
+
};
|
|
@@ -13,6 +13,7 @@ const userPermissionRepository = require("./userPermission.repository");
|
|
|
13
13
|
const userRolePermissionRepository = require("./userRolePermission.repository");
|
|
14
14
|
const notificationSettingsRepository = require("./notificationSettings.repository");
|
|
15
15
|
const customerProfileRepository = require("./customerProfile.repository");
|
|
16
|
+
const customerTimelineRepository = require("./customerTimeline.repository");
|
|
16
17
|
exports.module = {
|
|
17
18
|
workspaceRepository,
|
|
18
19
|
integrationRepository,
|
|
@@ -29,4 +30,5 @@ exports.module = {
|
|
|
29
30
|
userPermissionRepository,
|
|
30
31
|
userRolePermissionRepository,
|
|
31
32
|
customerProfileRepository,
|
|
33
|
+
customerTimelineRepository,
|
|
32
34
|
};
|
|
@@ -8,6 +8,9 @@ const CustomerProfileSchema = new Schema(
|
|
|
8
8
|
picture: { type: String, default: "" },
|
|
9
9
|
fbId: { type: String, default: "" },
|
|
10
10
|
igId: { type: String, default: "" },
|
|
11
|
+
totalOrders: { type: Number, default: 0 },
|
|
12
|
+
totalConversations: { type: Number, default: 0 },
|
|
13
|
+
totalTickets: { type: Number, default: 0 },
|
|
11
14
|
blackList: { type: Boolean, default: false },
|
|
12
15
|
workspaceId: {
|
|
13
16
|
type: Schema.Types.ObjectId,
|
|
@@ -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);
|
package/models/Order.js
CHANGED
|
@@ -139,6 +139,24 @@ const OrderSchema = new Schema(
|
|
|
139
139
|
credentials: {},
|
|
140
140
|
ticketId: { type: String, default: "" },
|
|
141
141
|
sender: { type: String, default: "" },
|
|
142
|
+
shipperAdvice: {
|
|
143
|
+
reAttempt: {
|
|
144
|
+
made: { type: Boolean, default: false },
|
|
145
|
+
details: {
|
|
146
|
+
attempt: { type: String, default: "0" },
|
|
147
|
+
remarks: { type: String, default: "" },
|
|
148
|
+
date: { type: String, default: "" },
|
|
149
|
+
},
|
|
150
|
+
},
|
|
151
|
+
return: {
|
|
152
|
+
made: { type: Boolean, default: false },
|
|
153
|
+
details: {
|
|
154
|
+
attempt: { type: String, default: "0" },
|
|
155
|
+
remarks: { type: String, default: "" },
|
|
156
|
+
date: { type: String, default: "" },
|
|
157
|
+
},
|
|
158
|
+
},
|
|
159
|
+
},
|
|
142
160
|
orderName: { type: String, default: "" },
|
|
143
161
|
totalWeight: { type: String, default: "" },
|
|
144
162
|
},
|
package/models/Website.js
CHANGED
|
@@ -29,6 +29,7 @@ const websiteSchema = new mongoose.Schema(
|
|
|
29
29
|
},
|
|
30
30
|
importStatus: { type: Boolean, default: false },
|
|
31
31
|
mode: { type: String, default: "read" },
|
|
32
|
+
details: { type: mongoose.Schema.Types.Mixed, default: {} },
|
|
32
33
|
},
|
|
33
34
|
{ timestamps: true, toJSON: { virtuals: true }, toObject: { virtuals: true } }
|
|
34
35
|
);
|