shuttlepro-shared 1.3.16 → 1.3.17

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(filter).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
  };
package/config/redis.js CHANGED
@@ -142,21 +142,6 @@ const getRedisData = async (key, field = null) => {
142
142
  return null;
143
143
  }
144
144
  };
145
- /**
146
- * ✅ Get Expiry Time from Redis
147
- * @param {string} key - The Redis key
148
- * @param {string|null} field - Optional field for Hash retrieval
149
- */
150
- const getRedisDataTime = async (key) => {
151
- try {
152
- await connectRedis();
153
- let result = await client.ttl(key);
154
- return result ? JSON.parse(result) : null;
155
- } catch (err) {
156
- console.error("❌ Error getting Redis data:", err);
157
- return null;
158
- }
159
- };
160
145
 
161
146
  /**
162
147
  * ✅ Delete Data from Redis (Supports String & Hash)
@@ -200,7 +185,6 @@ module.exports = {
200
185
  publisher,
201
186
  subscriber,
202
187
  setRedisData,
203
- getRedisDataTime,
204
188
  getRedisData,
205
189
  deleteRedisData,
206
190
  publishToChannel,
@@ -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
  );
@@ -280,16 +280,6 @@ const workspaceSchema = new mongoose.Schema(
280
280
  default: "everyone",
281
281
  },
282
282
  defaultShift: { type: String, default: "" },
283
- automationManager: {
284
- delayThreshold: {
285
- type: Number,
286
- default: 5,
287
- },
288
- messageCount: {
289
- type: Number,
290
- default: 3,
291
- },
292
- },
293
283
  },
294
284
  { timestamps: true, toJSON: { virtuals: true }, toObject: { virtuals: true } }
295
285
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shuttlepro-shared",
3
- "version": "1.3.16",
3
+ "version": "1.3.17",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {