shuttlepro-shared 1.3.15 → 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.
@@ -13,7 +13,6 @@ 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");
17
16
  exports.module = {
18
17
  workspaceRepository,
19
18
  integrationRepository,
@@ -30,5 +29,4 @@ exports.module = {
30
29
  userPermissionRepository,
31
30
  userRolePermissionRepository,
32
31
  customerProfileRepository,
33
- customerTimelineRepository,
34
32
  };
package/config/redis.js CHANGED
@@ -142,6 +142,21 @@ 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
+ };
145
160
 
146
161
  /**
147
162
  * ✅ Delete Data from Redis (Supports String & Hash)
@@ -185,6 +200,7 @@ module.exports = {
185
200
  publisher,
186
201
  subscriber,
187
202
  setRedisData,
203
+ getRedisDataTime,
188
204
  getRedisData,
189
205
  deleteRedisData,
190
206
  publishToChannel,
@@ -8,9 +8,6 @@ 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 },
14
11
  blackList: { type: Boolean, default: false },
15
12
  workspaceId: {
16
13
  type: Schema.Types.ObjectId,
package/models/Order.js CHANGED
@@ -139,24 +139,6 @@ 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
- },
160
142
  orderName: { type: String, default: "" },
161
143
  totalWeight: { type: String, default: "" },
162
144
  },
package/models/Website.js CHANGED
@@ -29,7 +29,6 @@ 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: {} },
33
32
  },
34
33
  { timestamps: true, toJSON: { virtuals: true }, toObject: { virtuals: true } }
35
34
  );
@@ -280,6 +280,16 @@ 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
+ },
283
293
  },
284
294
  { timestamps: true, toJSON: { virtuals: true }, toObject: { virtuals: true } }
285
295
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shuttlepro-shared",
3
- "version": "1.3.15",
3
+ "version": "1.3.16",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -1,78 +0,0 @@
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
- };
@@ -1,28 +0,0 @@
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);