shuttlepro-shared 1.3.32 → 1.3.34

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.
@@ -28,6 +28,7 @@ const ActivityLogsSchema = new Schema(
28
28
  type: String,
29
29
  default: "",
30
30
  },
31
+ body: {},
31
32
  },
32
33
  { timestamps: true, toJSON: { virtuals: true }, toObject: { virtuals: true } }
33
34
  );
@@ -0,0 +1,16 @@
1
+ const mongoose = require("mongoose");
2
+
3
+ const businessRuleSchema = new mongoose.Schema(
4
+ {
5
+ allocation: { type: Number, default: "" },
6
+ threshold: { type: Number, default: "" },
7
+ cities: { type: String, default: "" },
8
+ shiftedShipper: { type: String, default: "" },
9
+ businessShifted: { type: Number, default: "" },
10
+ shipper: { type: String, default: "" },
11
+ workspaceId: { type: mongoose.Types.ObjectId, default: "" },
12
+ },
13
+ { timestamps: true, toJSON: { virtuals: true }, toObject: { virtuals: true } }
14
+ );
15
+
16
+ module.exports = mongoose.model("BusinessRule", businessRuleSchema);
@@ -0,0 +1,13 @@
1
+ const mongoose = require("mongoose");
2
+
3
+ const businessRuleHelperSchema = new mongoose.Schema(
4
+ {
5
+ ruleId: { type: mongoose.Types.ObjectId, default: "" },
6
+ next: { type: String, default: "" },
7
+ active: { type: Boolean, default: "" },
8
+ frequency: { type: Number, default: "" },
9
+ },
10
+ { timestamps: true, toJSON: { virtuals: true }, toObject: { virtuals: true } }
11
+ );
12
+
13
+ module.exports = mongoose.model("BusinessRuleHelper", businessRuleHelperSchema);
package/models/Chatbot.js CHANGED
@@ -17,4 +17,4 @@ const ChatbotSchema = new Schema(
17
17
  },
18
18
  { timestamps: true, toJSON: { virtuals: true }, toObject: { virtuals: true } }
19
19
  );
20
- module.exports = model("Chatbot", ChatbotSchema);
20
+ module.exports = ChatbotSchema;
@@ -10,6 +10,14 @@ const draftSchema = new mongoose.Schema({
10
10
  createdBy: { type: Schema.Types.ObjectId, ref: "User" },
11
11
  });
12
12
 
13
+ const activitySchema = new mongoose.Schema({
14
+ action: { type: String, default: null },
15
+ previousAssignee: { type: Schema.Types.ObjectId, ref: "User", default: null },
16
+ newAssignee: { type: Schema.Types.ObjectId, ref: "User", default: null },
17
+ timestamp: { type: Date, default: Date.now },
18
+ performedBy: { type: Schema.Types.ObjectId, ref: "User", default: null },
19
+ });
20
+
13
21
  const conversationSchema = new mongoose.Schema(
14
22
  {
15
23
  platformType: {
@@ -76,13 +84,44 @@ const conversationSchema = new mongoose.Schema(
76
84
  draft: [draftSchema],
77
85
  isWebchatTicket: { type: Boolean, default: false },
78
86
  webchatComplaintType: { type: String, default: null },
87
+ isWebchatAutoReply: { type: Boolean, default: false },
88
+
79
89
  isComposed: { type: Boolean, default: false },
90
+ userMessageTime: { type: String, default: "" },
80
91
  utilityMessage: [],
81
92
  orderId: [],
82
93
  isFetch: { type: Boolean, default: true },
83
94
  isAwaitingFeedback: { type: Boolean, default: true },
95
+ activities: [activitySchema],
84
96
  },
85
97
  { timestamps: true, toJSON: { virtuals: true }, toObject: { virtuals: true } }
86
98
  );
87
99
 
100
+ conversationSchema.index({ workspaceId: 1, isSpam: 1 });
101
+ conversationSchema.index({ workspaceId: 1, isSpam: 1, conversationStatus: 1 });
102
+ conversationSchema.index({
103
+ workspaceId: 1,
104
+ isSpam: 1,
105
+ platformId: 1,
106
+ });
107
+ conversationSchema.index({
108
+ workspaceId: 1,
109
+ isSpam: 1,
110
+ platformId: 1,
111
+ conversationStatus: 1,
112
+ });
113
+ conversationSchema.index({
114
+ workspaceId: 1,
115
+ isSpam: 1,
116
+ platformId: 1,
117
+ conversationType: 1,
118
+ });
119
+ conversationSchema.index({
120
+ workspaceId: 1,
121
+ isSpam: 1,
122
+ platformId: 1,
123
+ conversationType: 1,
124
+ conversationStatus: 1,
125
+ });
126
+
88
127
  module.exports = mongoose.model("Conversation", conversationSchema);
@@ -17,7 +17,7 @@ const CustomerSchema = new Schema(
17
17
  type: Schema.Types.ObjectId,
18
18
  ref: "Workspace",
19
19
  default: null,
20
- },
20
+ },
21
21
  isBlackListed: { type: Boolean, default: false },
22
22
  createdBy: {
23
23
  type: Schema.Types.ObjectId,
@@ -0,0 +1,21 @@
1
+ const { Schema, model } = require("mongoose");
2
+
3
+ const CustomerCheckpointSchema = new Schema(
4
+ {
5
+ message: { type: String, default: "" },
6
+ type: { type: String, default: "" },
7
+ conversationPlatform: { type: String, default: null },
8
+ customerId: { type: Schema.Types.ObjectId, default: null, ref: "Customer" },
9
+ orderId: { type: Schema.Types.ObjectId, default: null, ref: "Order" },
10
+ conversationId: { type: String, default: "" },
11
+ workspaceId: {
12
+ type: Schema.Types.ObjectId,
13
+ ref: "Workspace",
14
+ default: null,
15
+ },
16
+ latestTimeStamp: { type: String, default: "" },
17
+ },
18
+ { timestamps: true, toJSON: { virtuals: true }, toObject: { virtuals: true } }
19
+ );
20
+
21
+ module.exports = model("CustomerCheckpoint", CustomerCheckpointSchema);
@@ -0,0 +1,21 @@
1
+ const mongoose = require("mongoose");
2
+ const { Schema } = mongoose;
3
+
4
+ const EmailSchema = new Schema(
5
+ {
6
+ name: { type: String, default: "" },
7
+ address: { type: String, default: "" },
8
+ contact: { type: String, default: "" },
9
+ email: { type: String, default: "" },
10
+ reference: { type: String, default: "" },
11
+ city: { type: String, default: "" },
12
+ isBlackListed: { type: Boolean, default: false },
13
+ customerId: { type: String, default: "" },
14
+ workspaceId: { type: String, default: "" },
15
+ designation: { type: String, default: "" },
16
+ },
17
+ { timestamps: true, toJSON: { virtuals: true }, toObject: { virtuals: true } }
18
+ );
19
+
20
+ const Email = mongoose.model("Email", EmailSchema);
21
+ module.exports = Email;
@@ -0,0 +1,31 @@
1
+ const mongoose = require("mongoose");
2
+ const { Schema } = mongoose;
3
+
4
+ const EmailMessageSchema = new Schema(
5
+ {
6
+ workspaceId: { type: String, default: "" },
7
+ threadId: { type: String, default: "" },
8
+ messageId: { type: String, default: "" },
9
+ message: { type: String, default: "" },
10
+ subject: { type: String, default: "" },
11
+ trackingId: { type: String, default: "" },
12
+ integratedEmail: { type: String, default: "" },
13
+ receiverEmail: { type: String, default: "" },
14
+ senderEmail: { type: String, default: "" },
15
+ agentId: { type: String, default: "" },
16
+ isRead: { type: Boolean, default: false },
17
+ type: { type: String, default: "email" },
18
+ attachmentArr: [
19
+ {
20
+ attachmentId: { type: String, default: "" },
21
+ attachemntName: { type: String, default: "" },
22
+ attachmentSize: { type: String, default: "" },
23
+ },
24
+ ],
25
+ right: { type: Boolean, default: true },
26
+ },
27
+ { timestamps: true, toJSON: { virtuals: true }, toObject: { virtuals: true } }
28
+ );
29
+
30
+ const EmailMessage = mongoose.model("EmailMessage", EmailMessageSchema);
31
+ module.exports = EmailMessage;
@@ -0,0 +1,17 @@
1
+ const mongoose = require("mongoose");
2
+
3
+ const emailNotificationSchema = new mongoose.Schema(
4
+ {
5
+ threadId: { type: String, default: "" },
6
+ messageId: { type: String, default: "" },
7
+ message: { type: String, default: "" },
8
+ subject: { type: String, default: "" },
9
+ trackingId: { type: String, default: "" },
10
+ integratedEmail: { type: String, default: "" },
11
+ receiverEmail: { type: String, default: "" },
12
+ senderEmail: { type: String, default: "" },
13
+ },
14
+ { timestamps: true, toJSON: { virtuals: true }, toObject: { virtuals: true } }
15
+ );
16
+
17
+ module.exports = mongoose.model("EmailNotification", emailNotificationSchema);
@@ -65,7 +65,7 @@ const EscalationGroupSchema = new Schema({
65
65
  type: {
66
66
  type: String,
67
67
  required: true,
68
- enum: ["status", "label"],
68
+ enum: ["status", "label", "formBuilder"],
69
69
  },
70
70
  values: [
71
71
  {
@@ -0,0 +1,31 @@
1
+ const mongoose = require("mongoose");
2
+ const { Schema } = mongoose;
3
+
4
+ const loadSheetSchema = new mongoose.Schema(
5
+ {
6
+ uuid: { type: String, default: "" },
7
+ courierName: { type: String, default: "" },
8
+ courierId: { type: String, default: "" },
9
+ orders: [
10
+ {
11
+ orderId: {
12
+ type: Schema.Types.ObjectId,
13
+ ref: "Order",
14
+ default: null,
15
+ },
16
+ },
17
+ ],
18
+ workspaceId: {
19
+ type: Schema.Types.ObjectId,
20
+ ref: "Workspace",
21
+ default: null,
22
+ },
23
+ isDeleted: { type: Boolean, default: false },
24
+ generatedBy: { type: Schema.Types.ObjectId, ref: "User", default: null },
25
+ createdBy: { type: Schema.Types.ObjectId, ref: "User", default: null },
26
+ updatedBy: { type: Schema.Types.ObjectId, ref: "User", default: null },
27
+ },
28
+ { timestamps: true, toJSON: { virtuals: true }, toObject: { virtuals: true } }
29
+ );
30
+
31
+ module.exports = mongoose.model("LoadSheet", loadSheetSchema);
@@ -0,0 +1,21 @@
1
+ const mongoose = require("mongoose");
2
+ const { Schema } = mongoose;
3
+
4
+ const MailGroupSchema = new Schema(
5
+ {
6
+ name: { type: String, default: "" },
7
+ emailIds: [
8
+ {
9
+ emailId: {
10
+ type: Schema.Types.ObjectId,
11
+ ref: "Email",
12
+ },
13
+ },
14
+ ],
15
+ workspaceId: { type: String, default: "" },
16
+ },
17
+ { timestamps: true, toJSON: { virtuals: true }, toObject: { virtuals: true } }
18
+ );
19
+
20
+ const MailGroup = mongoose.model("MailGroup", MailGroupSchema);
21
+ module.exports = MailGroup;
package/models/Profile.js CHANGED
@@ -68,7 +68,9 @@ const fetchProfileByEmailAndWorkspaceId = async (
68
68
  try {
69
69
  let profiles = await fetchProfiles(workspaceId);
70
70
  let profile = profiles.find(
71
- (p) => p?.userName === userName && p?.workspaceId === workspaceId
71
+ (p) =>
72
+ p?.userName === userName &&
73
+ p?.workspaceId?.toString() === workspaceId?.toString()
72
74
  );
73
75
  return profile || null;
74
76
  } catch (err) {
@@ -1,6 +1,5 @@
1
1
  const mongoose = require("mongoose");
2
2
  const { Schema } = mongoose;
3
- // const { Workspace } = require("./Workspace");
4
3
 
5
4
  const socialProfileSchema = new mongoose.Schema(
6
5
  {
@@ -0,0 +1,86 @@
1
+ const mongoose = require("mongoose");
2
+
3
+ const StorySchema = new mongoose.Schema(
4
+ {
5
+ option: { type: String, default: "" },
6
+ images: [String],
7
+ shareAt: { type: String, default: "" },
8
+ userId: { type: String, default: "" },
9
+ delay: { type: String, default: "" },
10
+ status: { type: String, default: "pending" },
11
+ workspaceId: { type: String, default: "" },
12
+ timeZone: { type: String, default: "" },
13
+ pageId: { type: String, default: "" },
14
+ pageName: { type: String, default: "" },
15
+ pageLogo: { type: String, default: "" },
16
+ accessToken: { type: String, default: "" },
17
+ type: { type: String, default: "" },
18
+ productIds: [{ productId: { type: String, default: "" } }],
19
+ isDeleted: { type: Boolean, default: false },
20
+ isNotified: { type: Boolean, default: false },
21
+ },
22
+ { timestamps: true, toJSON: { virtuals: true }, toObject: { virtuals: true } }
23
+ );
24
+
25
+ const Story = mongoose.model("Story", StorySchema);
26
+
27
+ const storiesByAggregation = async (pipeline) => {
28
+ try {
29
+ return await Story.aggregate(pipeline);
30
+ } catch (err) {
31
+ return [];
32
+ }
33
+ };
34
+ const findStory = async (obj) => {
35
+ try {
36
+ return await Story.find(obj);
37
+ } catch (err) {
38
+ return err;
39
+ }
40
+ };
41
+ const findSingleStory = async (obj) => {
42
+ try {
43
+ return await Story.findOne(obj);
44
+ } catch (err) {
45
+ return err;
46
+ }
47
+ };
48
+ const deleteSingleStory = async (obj) => {
49
+ try {
50
+ return await Story.deleteOne(obj);
51
+ } catch (err) {
52
+ return err;
53
+ }
54
+ };
55
+ const saveStory = async (obj) => {
56
+ try {
57
+ let story = new Story(obj);
58
+ return await story.save();
59
+ } catch (err) {
60
+ return err;
61
+ }
62
+ };
63
+ const saveScheduledStory = async (obj) => {
64
+ try {
65
+ return await Story.insertMany(obj);
66
+ } catch (err) {
67
+ return [];
68
+ }
69
+ };
70
+ const findPendingStories = async (obj) => {
71
+ try {
72
+ return await Story.find(obj).exec();
73
+ } catch (err) {
74
+ return [];
75
+ }
76
+ };
77
+ module.exports = {
78
+ storiesByAggregation,
79
+ findStory,
80
+ findSingleStory,
81
+ deleteSingleStory,
82
+ saveStory,
83
+ saveScheduledStory,
84
+ findPendingStories,
85
+ Story,
86
+ };
@@ -26,7 +26,7 @@ const templateFrameSchema = new mongoose.Schema(
26
26
  {
27
27
  tagId: {
28
28
  type: Schema.Types.ObjectId,
29
- ref: "TemplateTag",
29
+ ref: "Tag",
30
30
  },
31
31
  },
32
32
  ],
@@ -34,4 +34,22 @@ const templateFrameSchema = new mongoose.Schema(
34
34
  { timestamps: true, toJSON: { virtuals: true }, toObject: { virtuals: true } }
35
35
  );
36
36
 
37
+ templateFrameSchema.virtual("templateTag", {
38
+ ref: "TemplateTag",
39
+ localField: "_id",
40
+ foreignField: "frameId",
41
+ });
42
+
43
+ templateFrameSchema.virtual("templateColors", {
44
+ ref: "TemplateColor",
45
+ localField: "_id",
46
+ foreignField: "frameId",
47
+ });
48
+
49
+ templateFrameSchema.virtual("templateCategories", {
50
+ ref: "TemplateCategory",
51
+ localField: "_id",
52
+ foreignField: "frameId",
53
+ });
54
+
37
55
  module.exports = mongoose.model("TemplateFrame", templateFrameSchema);
@@ -0,0 +1,29 @@
1
+ const mongoose = require("mongoose");
2
+
3
+ const whatsappFlowSchema = new mongoose.Schema(
4
+ {
5
+ referenceId: {
6
+ type: String,
7
+ default: "",
8
+ },
9
+ flowName: {
10
+ type: String,
11
+ default: "",
12
+ },
13
+ workspaceId: {
14
+ type: mongoose.Schema.Types.ObjectId,
15
+ ref: "Workspace",
16
+ },
17
+ response: {
18
+ type: Object,
19
+ default: {},
20
+ },
21
+ },
22
+ {
23
+ timestamps: true,
24
+ }
25
+ );
26
+
27
+ const WhatsappFlow = mongoose.model("WhatsappFlow", whatsappFlowSchema);
28
+
29
+ module.exports = WhatsappFlow;
@@ -1,7 +1,15 @@
1
1
  const mongoose = require("mongoose");
2
+ const SettingModel = require("./Setting");
3
+ const SocialMediaSettingModel = require("./SocialMediaSetting");
4
+ const { Schema } = mongoose;
5
+
2
6
  //TODO: task manager and default location creation
3
7
  const shiftSchema = new mongoose.Schema(
4
8
  {
9
+ _id: {
10
+ type: mongoose.Schema.Types.ObjectId,
11
+ default: () => new mongoose.Types.ObjectId(),
12
+ },
5
13
  shiftName: {
6
14
  type: String,
7
15
  required: true,
@@ -161,6 +169,13 @@ const workspaceSchema = new mongoose.Schema(
161
169
  required: true,
162
170
  trim: true,
163
171
  },
172
+ slug: {
173
+ type: String,
174
+ required: true,
175
+ trim: true,
176
+ default: "",
177
+ unique: true,
178
+ },
164
179
  iconUrl: { type: String, default: "" },
165
180
  thumbUrl: { type: String, default: "" },
166
181
  createdBy: {
@@ -308,6 +323,31 @@ const workspaceSchema = new mongoose.Schema(
308
323
  },
309
324
  { timestamps: true, toJSON: { virtuals: true }, toObject: { virtuals: true } }
310
325
  );
326
+
327
+ workspaceSchema.virtual("products", {
328
+ ref: "Product",
329
+ localField: "_id",
330
+ foreignField: "workspaceId",
331
+ });
332
+
333
+ workspaceSchema.virtual("orders", {
334
+ ref: "Order",
335
+ localField: "_id",
336
+ foreignField: "workspaceId",
337
+ });
338
+
339
+ workspaceSchema.virtual("socialProfilesArr", {
340
+ ref: "socialProfile",
341
+ localField: "_id",
342
+ foreignField: "workspaceId",
343
+ });
344
+
345
+ workspaceSchema.virtual("integrations", {
346
+ ref: "Integration",
347
+ localField: "_id",
348
+ foreignField: "workspaceId",
349
+ });
350
+
311
351
  const commonOptions = {
312
352
  type: String,
313
353
  trim: true,
@@ -324,10 +364,5 @@ workspaceSchema.add({
324
364
  chatGptApiKey: commonOptions,
325
365
  });
326
366
 
327
- workspaceSchema.virtual("integrations", {
328
- ref: "Integration",
329
- localField: "_id",
330
- foreignField: "workspaceId",
331
- });
332
367
  const Workspace = mongoose.model("Workspace", workspaceSchema);
333
368
  module.exports = Workspace;
package/models.js CHANGED
@@ -9,6 +9,8 @@ const Attribute = require("./models/Attribute");
9
9
  const Automation = require("./models/Automation");
10
10
  const AutoSchedulerSchema = require("./models/AutoScheduler");
11
11
  const BusinessDistribution = require("./models/BusinessDistribution");
12
+ const BusinessRule = require("./models/BusinessRule");
13
+ const BusinessRuleHelper = require("./models/BusinessRuleHelper");
12
14
  const Card = require("./models/Card");
13
15
  const CardComments = require("./models/CardComments");
14
16
  const Catalogue = require("./models/Catalogue");
@@ -24,11 +26,15 @@ const Column = require("./models/Column");
24
26
  const ColumnPreference = require("./models/ColumnPreference");
25
27
  const Conversation = require("./models/Conversation");
26
28
  const Customer = require("./models/Customer");
29
+ const CustomerCheckpoint = require("./models/CustomerCheckpoint");
27
30
  const CustomerProfile = require("./models/CustomerProfile");
28
31
  const CustomerTimeline = require("./models/CustomerTimeline");
29
32
  const DefaultRolePermission = require("./models/DefaultRolePermission");
30
33
  const DescriptionTemplate = require("./models/DescriptionTemplate");
31
34
  const DeviceInfo = require("./models/DeviceInfo");
35
+ const Email = require("./models/Email");
36
+ const EmailMessage = require("./models/EmailMessage");
37
+ const EmailNotification = require("./models/EmailNotification");
32
38
  const EscalationConfiguration = require("./models/EscalationConfiguration");
33
39
  const EscalationManager = require("./models/EscalationManager");
34
40
  const Faq = require("./models/Faq");
@@ -44,8 +50,10 @@ const JobQueue = require("./models/JobQueue");
44
50
  const Label = require("./models/Label");
45
51
  const LabelPdf = require("./models/LabelsPdf");
46
52
  const Layout = require("./models/Layout");
53
+ const LoadSheet = require("./models/LoadSheet");
47
54
  const Location = require("./models/Location");
48
55
  const Logo = require("./models/Logo");
56
+ const MailGroup = require("./models/MailGroup");
49
57
  const Message = require("./models/Message");
50
58
  const NewProduct = require("./models/NewProduct");
51
59
  const Notification = require("./models/Notification");
@@ -78,6 +86,7 @@ const SocialProfile = require("./models/SocialProfile");
78
86
  const Status = require("./models/Status");
79
87
  const StatusType = require("./models/StatusType");
80
88
  const Step = require("./models/Step");
89
+ const Story = require("./models/Story");
81
90
  const Tag = require("./models/Tag");
82
91
  const Template = require("./models/Template");
83
92
  const TemplateFrame = require("./models/TemplateFrame");
@@ -106,6 +115,8 @@ module.exports = {
106
115
  Automation,
107
116
  AutoSchedulerSchema,
108
117
  BusinessDistribution,
118
+ BusinessRule,
119
+ BusinessRuleHelper,
109
120
  Card,
110
121
  CardComments,
111
122
  Catalogue,
@@ -121,11 +132,15 @@ module.exports = {
121
132
  ColumnPreference,
122
133
  Conversation,
123
134
  Customer,
135
+ CustomerCheckpoint,
124
136
  CustomerProfile,
125
137
  CustomerTimeline,
126
138
  DefaultRolePermission,
127
139
  DescriptionTemplate,
128
140
  DeviceInfo,
141
+ Email,
142
+ EmailMessage,
143
+ EmailNotification,
129
144
  EscalationConfiguration,
130
145
  EscalationManager,
131
146
  Faq,
@@ -140,9 +155,11 @@ module.exports = {
140
155
  JobQueue,
141
156
  Label,
142
157
  LabelPdf,
158
+ LoadSheet,
143
159
  Layout,
144
160
  Location,
145
161
  Logo,
162
+ MailGroup,
146
163
  Message,
147
164
  NewProduct,
148
165
  Notification,
@@ -175,6 +192,7 @@ module.exports = {
175
192
  Status,
176
193
  StatusType,
177
194
  Step,
195
+ Story,
178
196
  Tag,
179
197
  Template,
180
198
  TemplateFrame,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shuttlepro-shared",
3
- "version": "1.3.32",
3
+ "version": "1.3.34",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {