shuttlepro-shared 1.4.23 → 1.4.25

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.
@@ -239,6 +239,15 @@ class CallRepository {
239
239
  ) {
240
240
  const { from: fromDate, to: toDate } = this._utcDayBounds(from, to);
241
241
 
242
+ console.log(
243
+ {
244
+ workspaceId,
245
+ createdAt: { $gte: fromDate, $lte: toDate },
246
+ ...filters,
247
+ },
248
+ "query"
249
+ );
250
+
242
251
  let query = Call.find({
243
252
  workspaceId,
244
253
  createdAt: { $gte: fromDate, $lte: toDate },
@@ -280,12 +289,28 @@ class CallRepository {
280
289
  .exec();
281
290
  }
282
291
 
283
- getActiveCalls(workspaceId) {
284
- return Call.find({ workspaceId, status: { $in: ["active", "hold"] } });
292
+ getActiveCalls(workspaceId, filters = {}) {
293
+ return Call.find({
294
+ workspaceId,
295
+ status: { $in: ["active"] },
296
+ ...filters,
297
+ })
298
+ .lean()
299
+ .exec();
285
300
  }
286
301
 
287
302
  getPendingCalls(workspaceId) {
288
- return Call.find({ workspaceId, status: "pending" });
303
+ return Call.find({
304
+ workspaceId,
305
+ status: { $in: ["pending", "hold"] },
306
+ ...filters,
307
+ })
308
+ .lean()
309
+ .exec();
310
+ }
311
+
312
+ getCallByFilter(filters = {}) {
313
+ return Call.findOne(filters).lean().exec();
289
314
  }
290
315
 
291
316
  getStaleCalls(timeoutMinutes = 5) {
@@ -293,7 +318,9 @@ class CallRepository {
293
318
  return Call.find({
294
319
  status: { $in: ["active", "hold", "pending"] },
295
320
  "connectionMetadata.lastHeartbeat": { $lt: timeout },
296
- });
321
+ })
322
+ .lean()
323
+ .exec();
297
324
  }
298
325
 
299
326
  /* ----------------- Reporting ----------------- */
@@ -313,19 +340,42 @@ class CallRepository {
313
340
  $group: {
314
341
  _id: filters.agentId ? "$agentId" : null,
315
342
  totalCalls: { $sum: 1 },
316
- pending: { $sum: { $cond: [{ $eq: ["$status", "pending"] }, 1, 0] } },
343
+
344
+ pending: {
345
+ $sum: {
346
+ $cond: [{ $in: ["$status", ["pending", "hold"]] }, 1, 0],
347
+ },
348
+ },
349
+
350
+ active: {
351
+ $sum: {
352
+ $cond: [{ $eq: ["$status", "active"] }, 1, 0],
353
+ },
354
+ },
355
+
317
356
  abandoned: {
318
357
  $sum: { $cond: [{ $eq: ["$status", "abandoned"] }, 1, 0] },
319
358
  },
320
- ended: { $sum: { $cond: [{ $eq: ["$status", "ended"] }, 1, 0] } },
359
+ ended: {
360
+ $sum: { $cond: [{ $eq: ["$status", "ended"] }, 1, 0] },
361
+ },
321
362
  },
322
363
  },
323
364
  {
324
- $project: { _id: 0, totalCalls: 1, pending: 1, abandoned: 1, ended: 1 },
365
+ $project: {
366
+ _id: 0,
367
+ totalCalls: 1,
368
+ pending: 1,
369
+ active: 1,
370
+ abandoned: 1,
371
+ ended: 1,
372
+ },
325
373
  },
326
374
  ]);
327
375
 
328
- return stats || { totalCalls: 0, pending: 0, abandoned: 0, ended: 0 };
376
+ return (
377
+ stats || { totalCalls: 0, pending: 0, active: 0, abandoned: 0, ended: 0 }
378
+ );
329
379
  }
330
380
 
331
381
  getDailySummary(workspaceId, from, to, filters = {}, groupBy = null) {
@@ -39,7 +39,12 @@ const updateCustomerProfile = async (id, data) => {
39
39
  }).exec();
40
40
  return updated;
41
41
  };
42
-
42
+ const updateManyCustomerProfiles = async (filter, data) => {
43
+ const result = await CustomerProfile.updateMany(filter, {
44
+ $set: data,
45
+ }).exec();
46
+ return result;
47
+ };
43
48
  const updateCustomerProfileByFilter = async (
44
49
  filter,
45
50
  data,
@@ -112,4 +117,5 @@ module.exports = {
112
117
  findAllCustomerProfilesByFilter,
113
118
  findAllCustomerProfilesByFilterFromDb,
114
119
  searchCustomerProfilesByName,
120
+ updateManyCustomerProfiles,
115
121
  };
@@ -55,6 +55,32 @@ const AutomationAction = new Schema({
55
55
  templateId: descriptionJoin,
56
56
  delay: defaultStringType,
57
57
  },
58
+ ticketList: {
59
+ enabled: { type: Boolean, default: false },
60
+ templateId: descriptionJoin,
61
+ delay: defaultStringType,
62
+ ticketList: [
63
+ {
64
+ id: {
65
+ type: mongoose.Schema.Types.ObjectId,
66
+ ref: "Column",
67
+ required: true,
68
+ },
69
+ title: {
70
+ type: String,
71
+ required: true,
72
+ },
73
+ name: {
74
+ type: String,
75
+ required: true,
76
+ },
77
+ type: {
78
+ type: String,
79
+ required: true,
80
+ },
81
+ },
82
+ ],
83
+ },
58
84
  markAsSpam: {
59
85
  enabled: { type: Boolean, default: false },
60
86
  },
@@ -64,6 +90,10 @@ const AutomationAction = new Schema({
64
90
  hideComment: {
65
91
  enabled: { type: Boolean, default: false },
66
92
  },
93
+ futureRestriction: {
94
+ enabled: { type: Boolean, default: false },
95
+ action: { type: String, default: "" },
96
+ },
67
97
  closeChat: {
68
98
  enabled: { type: Boolean, default: false },
69
99
  },
@@ -169,6 +199,7 @@ const AutomationCondition = new Schema({
169
199
  "shift",
170
200
  "newCommentPost",
171
201
  "profile",
202
+ "moveTicket",
172
203
  ],
173
204
  },
174
205
  keyValue: {
@@ -193,6 +224,7 @@ const AutomationCondition = new Schema({
193
224
  "orderPublish",
194
225
  "newCommentPost",
195
226
  "profile",
227
+ "moveTicket",
196
228
  ],
197
229
  },
198
230
  subKeyValue: {
@@ -24,6 +24,9 @@ const CustomerProfileSchema = new Schema(
24
24
  default: null,
25
25
  },
26
26
  body: {},
27
+ blocked: { type: Boolean, default: false }, // To Block User (Current Automation case)
28
+ hideComments: { type: Boolean, default: false }, // For Hide Comment Check
29
+ deleteComments: { type: Boolean, default: false }, // For Delete Comment Check
27
30
  },
28
31
  { timestamps: true, toJSON: { virtuals: true }, toObject: { virtuals: true } }
29
32
  );
@@ -10,7 +10,7 @@ const ActionSchema = new Schema({
10
10
  });
11
11
  const InteractiveSchema = new Schema({
12
12
  name: { type: String, default: "" },
13
- workspace: { type: Types.ObjectId, ref: "Workspace", default: null },
13
+ workspaceId: { type: Types.ObjectId, ref: "Workspace", default: null },
14
14
  type: {
15
15
  type: String,
16
16
  enum: ["button", "list"],
package/models/Step.js CHANGED
@@ -45,6 +45,23 @@ const StepSchema = new Schema(
45
45
  default: null,
46
46
  },
47
47
  chatbotId: { type: Schema.Types.ObjectId, ref: "Chatbot", default: null },
48
+ complaintCreation: {
49
+ successTemplate: {
50
+ type: Schema.Types.ObjectId,
51
+ ref: "DescriptionTemplate",
52
+ default: null,
53
+ },
54
+ alreadyExistTemplate: {
55
+ type: Schema.Types.ObjectId,
56
+ ref: "DescriptionTemplate",
57
+ default: null,
58
+ },
59
+ columnId: {
60
+ type: Schema.Types.ObjectId,
61
+ ref: "Column",
62
+ default: null,
63
+ },
64
+ },
48
65
  },
49
66
  { timestamps: true, toJSON: { virtuals: true }, toObject: { virtuals: true } }
50
67
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shuttlepro-shared",
3
- "version": "1.4.23",
3
+ "version": "1.4.25",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {