shuttlepro-shared 1.3.29 → 1.3.31

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.
Files changed (60) hide show
  1. package/common/repositories/customerProfile.repository.js +83 -14
  2. package/common/repositories/userRole.repository.js +5 -2
  3. package/config/redis.js +72 -73
  4. package/middlewares/checkPermission/index.js +36 -23
  5. package/models/Activity.js +28 -0
  6. package/models/AgentActivity.js +5 -2
  7. package/models/Attribute.js +130 -0
  8. package/models/Automation.js +238 -0
  9. package/models/Card.js +50 -1
  10. package/models/Catalogue.js +22 -0
  11. package/models/Category.js +129 -0
  12. package/models/ChatMemberSession.js +21 -0
  13. package/models/ChatMessage.js +43 -0
  14. package/models/Color.js +10 -0
  15. package/models/Column.js +6 -0
  16. package/models/Conversation.js +1 -0
  17. package/models/Customer.js +3 -2
  18. package/models/DeviceInfo.js +13 -0
  19. package/models/EscalationConfiguration.js +123 -0
  20. package/models/EscalationManager.js +50 -0
  21. package/models/Faq.js +29 -0
  22. package/models/FeedbackResponse.js +72 -0
  23. package/models/FormTemplate.js +27 -0
  24. package/models/Integration.js +6 -0
  25. package/models/InternalComments.js +27 -0
  26. package/models/InternalThreads.js +20 -0
  27. package/models/JobDesign.js +32 -0
  28. package/models/JobQueue.js +17 -0
  29. package/models/LabelsPdf.js +12 -0
  30. package/models/Layout.js +12 -0
  31. package/models/Location.js +147 -0
  32. package/models/Logo.js +11 -0
  33. package/models/Notification.js +32 -0
  34. package/models/Order.js +11 -0
  35. package/models/OrderPdf.js +29 -0
  36. package/models/PostsAutomation.js +66 -0
  37. package/models/Product.js +336 -0
  38. package/models/ProductAttachment.js +158 -0
  39. package/models/ProductAttribute.js +140 -0
  40. package/models/ProductCategory.js +128 -0
  41. package/models/ProductLabels.js +11 -0
  42. package/models/ProductShopify.js +13 -0
  43. package/models/ProductTag.js +124 -0
  44. package/models/ProductVariant.js +156 -0
  45. package/models/ServiceUsage.js +26 -0
  46. package/models/ShipperSetting.js +24 -0
  47. package/models/SocialGroup.js +127 -0
  48. package/models/SocialPost.js +40 -0
  49. package/models/SocialProfile.js +57 -0
  50. package/models/Tag.js +77 -0
  51. package/models/Template.js +76 -0
  52. package/models/TemplateFrame.js +37 -0
  53. package/models/TemplateTag.js +10 -0
  54. package/models/UserSession.js +47 -0
  55. package/models/VariantLocation.js +145 -0
  56. package/models/WhatsappFlow.js +0 -0
  57. package/models/Workflow.js +34 -0
  58. package/models/Workspace.js +13 -0
  59. package/models.js +148 -49
  60. package/package.json +1 -1
@@ -0,0 +1,50 @@
1
+ const mongoose = require("mongoose");
2
+ const { Schema } = mongoose;
3
+
4
+ const EscalationManagerSchema = new Schema(
5
+ {
6
+ type: {
7
+ type: String,
8
+ required: true,
9
+ enum: ["conversation", "ticket"],
10
+ },
11
+ refId: {
12
+ type: String,
13
+ required: true,
14
+ },
15
+ escalationId: {
16
+ type: Schema.Types.ObjectId,
17
+ ref: "Escalation",
18
+ },
19
+ groupId: {
20
+ type: String,
21
+ },
22
+ status: {
23
+ type: String,
24
+ enum: ["pending", "processing", "close"],
25
+ },
26
+ managerStatus: [
27
+ {
28
+ escalationLevel: {
29
+ type: Number,
30
+ },
31
+ status: {
32
+ type: String,
33
+ enum: ["pending", "done", "failed"],
34
+ },
35
+ },
36
+ ],
37
+ workspaceId: {
38
+ type: Schema.Types.ObjectId,
39
+ ref: "Workspace",
40
+ },
41
+ },
42
+ { timestamps: true, toJSON: { virtuals: true }, toObject: { virtuals: true } }
43
+ );
44
+
45
+ const EscalationManager = mongoose.model(
46
+ "EscalationManager",
47
+ EscalationManagerSchema
48
+ );
49
+
50
+ module.exports = EscalationManager;
package/models/Faq.js ADDED
@@ -0,0 +1,29 @@
1
+ const mongoose = require("mongoose");
2
+ const { Schema } = mongoose;
3
+
4
+ const FaqItemSchema = new Schema({
5
+ question: { type: String, required: true },
6
+ answer: { type: String, required: true },
7
+ });
8
+
9
+ const FaqSchema = new Schema(
10
+ {
11
+ name: {
12
+ type: String,
13
+ required: true,
14
+ },
15
+ list: {
16
+ type: [FaqItemSchema],
17
+ required: true,
18
+ },
19
+ workspaceId: {
20
+ type: Schema.Types.ObjectId,
21
+ ref: "Workspace",
22
+ },
23
+ },
24
+ { timestamps: true, toJSON: { virtuals: true }, toObject: { virtuals: true } }
25
+ );
26
+
27
+ const Faq = mongoose.model("Faq", FaqSchema);
28
+
29
+ module.exports = Faq;
@@ -0,0 +1,72 @@
1
+ const mongoose = require("mongoose");
2
+ const { Schema } = mongoose;
3
+ const { v4: uuidv4 } = require("uuid");
4
+
5
+ const FeedbackResponseSchema = new Schema(
6
+ {
7
+ paramId: {
8
+ type: String,
9
+ default: uuidv4(),
10
+ },
11
+ type: {
12
+ type: String,
13
+ enum: ["conversation", "order"],
14
+ default: "conversation",
15
+ },
16
+ refId: {
17
+ type: String,
18
+ default: "",
19
+ },
20
+ workspaceId: {
21
+ type: String,
22
+ default: "",
23
+ },
24
+ agentId: {
25
+ type: String,
26
+ default: "",
27
+ },
28
+ feedbackFormId: {
29
+ type: String,
30
+ default: "",
31
+ },
32
+ data: {
33
+ type: Schema.Types.Mixed,
34
+ default: {},
35
+ },
36
+ responseAdded: {
37
+ type: Boolean,
38
+ default: false,
39
+ },
40
+ customerInfo: {
41
+ type: Schema.Types.Mixed,
42
+ default: {},
43
+ },
44
+ platformInfo: {
45
+ type: Schema.Types.Mixed,
46
+ default: {},
47
+ },
48
+ timeStamp: {
49
+ type: Date,
50
+ default: Date.now,
51
+ },
52
+
53
+ workspaceId: {
54
+ type: String,
55
+ default: "",
56
+ },
57
+ feedbackFormId: {
58
+ type: String,
59
+ default: "",
60
+ },
61
+ qr: {
62
+ link: {
63
+ type: String,
64
+ default: "",
65
+ trim: true,
66
+ },
67
+ },
68
+ },
69
+ { timestamps: true, toJSON: { virtuals: true }, toObject: { virtuals: true } }
70
+ );
71
+
72
+ module.exports = mongoose.model("FeedbackResponse", FeedbackResponseSchema);
@@ -0,0 +1,27 @@
1
+ const mongoose = require("mongoose");
2
+
3
+ const FormTemplateSchema = new mongoose.Schema(
4
+ {
5
+ type: {
6
+ type: String,
7
+ required: true,
8
+ enum: ["feedback", "ticket"],
9
+ },
10
+ subType: {
11
+ type: String,
12
+ enum: ["formBuilder","complaint", "order", "ticket", "product"],
13
+ },
14
+ workspaceId: {
15
+ type: String,
16
+ default: "",
17
+ },
18
+ body: {
19
+ type: mongoose.Schema.Types.Mixed,
20
+ default: {},
21
+ },
22
+ },
23
+ { timestamps: true, toJSON: { virtuals: true }, toObject: { virtuals: true } }
24
+ );
25
+
26
+ const FormTemplate = mongoose.model("FormTemplate", FormTemplateSchema);
27
+ module.exports = FormTemplate;
@@ -48,4 +48,10 @@ const IntegrationSchema = new mongoose.Schema(
48
48
  { timestamps: true, toJSON: { virtuals: true }, toObject: { virtuals: true } }
49
49
  );
50
50
 
51
+ IntegrationSchema.virtual("conversations", {
52
+ ref: "Conversation",
53
+ localField: "_id",
54
+ foreignField: "platformId",
55
+ });
56
+
51
57
  module.exports = mongoose.model("Integration", IntegrationSchema);
@@ -0,0 +1,27 @@
1
+ const mongoose = require("mongoose");
2
+ const { Schema } = mongoose;
3
+ const InternalCommentSchema = new Schema(
4
+ {
5
+ comment: { type: String, default: "" },
6
+ item_id: { type: String, default: "" },
7
+ sender_profile_url: { type: String, default: "" },
8
+ workspace_id: { type: String, default: "" },
9
+ sender_name: { type: String, default: "" },
10
+ senderId: { type: String, default: "" },
11
+ commentType: { type: String, default: "" },
12
+ mention_id: [{ id: String, name: String }],
13
+ pageId: { type: String, default: "" },
14
+ attachments: [],
15
+ },
16
+ { timestamps: true, toJSON: { virtuals: true }, toObject: { virtuals: true } }
17
+ );
18
+ InternalCommentSchema.virtual("internalThreads", {
19
+ ref: "InternalThreads",
20
+ localField: "_id",
21
+ foreignField: "internalCommentId",
22
+ });
23
+ const InternalComment = mongoose.model(
24
+ "InternalComment",
25
+ InternalCommentSchema
26
+ );
27
+ module.exports = InternalComment;
@@ -0,0 +1,20 @@
1
+ const mongoose = require("mongoose");
2
+ const { Schema } = mongoose;
3
+ const InternalThreadsSchema = new Schema(
4
+ {
5
+ internalCommentId: { type: Schema.Types.ObjectId, ref: "InternalComment" },
6
+ comment: { type: String, default: "" },
7
+ sender_name: { type: String, default: "" },
8
+ senderId: { type: String, default: "" },
9
+ sender_profile_url: { type: String, default: "" },
10
+ mention_id: [{ id: String, name: String }],
11
+ pageId: { type: String, default: "" },
12
+ attachments: [],
13
+ },
14
+ { timestamps: true, toJSON: { virtuals: true }, toObject: { virtuals: true } }
15
+ );
16
+ const InternalThreads = mongoose.model(
17
+ "InternalThreads",
18
+ InternalThreadsSchema
19
+ );
20
+ module.exports = InternalThreads;
@@ -0,0 +1,32 @@
1
+ const mongoose = require("mongoose");
2
+ const { Schema } = mongoose;
3
+
4
+ const jobDesignSchema = new mongoose.Schema(
5
+ {
6
+ name: { type: String, default: "" },
7
+ products: { type: Number, default: 0 },
8
+ productIds: [],
9
+ status: { type: String, default: "processing" },
10
+ data: [
11
+ {
12
+ url: { type: String, default: "" },
13
+ bucket: { type: String, default: "" },
14
+ key: { type: String, default: "" },
15
+ },
16
+ ],
17
+ downloads: [],
18
+ tagName: { type: String, default: "" },
19
+ tagId: { type: String, default: "" },
20
+ userId: { type: Schema.Types.ObjectId, ref: "User" },
21
+ userName: { type: String, default: "" },
22
+ organizationId: { type: Number, default: 0 },
23
+ workspaceId: { type: Schema.Types.ObjectId, ref: "Workspace" },
24
+ templateId: {
25
+ type: Schema.Types.ObjectId,
26
+ ref: "Template",
27
+ },
28
+ },
29
+ { timestamps: true, toJSON: { virtuals: true }, toObject: { virtuals: true } }
30
+ );
31
+
32
+ module.exports = mongoose.model("JobDesign", jobDesignSchema);
@@ -0,0 +1,17 @@
1
+ const mongoose = require("mongoose");
2
+ const { Schema } = mongoose;
3
+ const jobQueueSchema = new mongoose.Schema(
4
+ {
5
+ jobId: { type: String },
6
+ templateData: { type: Object },
7
+ imageUrl: { type: String },
8
+ imageId: { type: String, default: "" },
9
+ workspaceId: { type: Schema.Types.ObjectId, ref: "Product" },
10
+ status: { type: String, default: "Processing" },
11
+ message: { type: String, default: "" },
12
+ attempt: { type: Number, default: 0 },
13
+ },
14
+ { timestamps: true, toJSON: { virtuals: true }, toObject: { virtuals: true } }
15
+ );
16
+
17
+ module.exports = mongoose.model("JobQueue", jobQueueSchema);
@@ -0,0 +1,12 @@
1
+ const mongoose = require("mongoose");
2
+
3
+ const LabelsPdfSchema = new mongoose.Schema(
4
+ {
5
+ url: { type: String, default: "" },
6
+ organizationId: { type: Number, default: 0 },
7
+ storeId: { type: Number, default: 0 }
8
+ },
9
+ { timestamps: true, toJSON: { virtuals: true }, toObject: { virtuals: true } }
10
+ );
11
+
12
+ module.exports = mongoose.model("LabelsPdf", LabelsPdfSchema);
@@ -0,0 +1,12 @@
1
+ const mongoose = require("mongoose");
2
+
3
+ const layoutSchema = new mongoose.Schema(
4
+ {
5
+ name: { type: String, default: "" },
6
+ height: { type: Number, default: 0 },
7
+ width: { type: Number, default: 0 }
8
+ },
9
+ { timestamps: true, toJSON: { virtuals: true }, toObject: { virtuals: true } }
10
+ );
11
+
12
+ module.exports = mongoose.model("Layout", layoutSchema);
@@ -0,0 +1,147 @@
1
+ const mongoose = require("mongoose");
2
+ const { Schema } = mongoose;
3
+ const LocationSchema = new Schema(
4
+ {
5
+ isDefault: { type: Boolean, default: false },
6
+ address1: { type: String, default: "" },
7
+ address2: { type: String, default: "" },
8
+ city: { type: String, default: "" },
9
+ zip: { type: String, default: "" },
10
+ province: { type: String, default: "" },
11
+ country: { type: String, default: "" },
12
+ phone: { type: String, default: "" },
13
+ active: { type: Boolean, default: true },
14
+ oldId: { type: String, default: "" },
15
+ webLocationId: { type: Number, default: null },
16
+ bcLocationId: { type: String, default: "" },
17
+ workspaceId: {
18
+ type: Schema.Types.ObjectId,
19
+ ref: "Workspace",
20
+ default: null,
21
+ },
22
+ legacy: { type: Boolean, default: false },
23
+ name: { type: String, default: "" },
24
+ isDeleted: { type: Boolean, default: false },
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
+ LocationSchema.virtual("variantLocations", {
32
+ ref: "VariantLocation",
33
+ localField: "_id",
34
+ foreignField: "locationId",
35
+ });
36
+
37
+ const Location = mongoose.model("Location", LocationSchema);
38
+
39
+ const createNewLocation = async (locationData) => {
40
+ try {
41
+ return await Location.create(locationData);
42
+ } catch (error) {
43
+ console.log(error);
44
+ return null;
45
+ }
46
+ };
47
+
48
+ const findLocationById = async (locationId) => {
49
+ try {
50
+ return await Location.findById(locationId);
51
+ } catch (error) {
52
+ console.log(error);
53
+ return null;
54
+ }
55
+ };
56
+
57
+ const updateLocationById = async (criteria, updateData, options) => {
58
+ try {
59
+ return await Location.findByIdAndUpdate(criteria, updateData, options);
60
+ } catch (error) {
61
+ console.log(error);
62
+ return null;
63
+ }
64
+ };
65
+ const updateLocation = async (criteria, updateData, options) => {
66
+ try {
67
+ return await Location.findOneAndUpdate(criteria, updateData, options);
68
+ } catch (error) {
69
+ console.log(error);
70
+ return null;
71
+ }
72
+ };
73
+
74
+ const findAndUpdateLocation = async (criteria, data, options) => {
75
+ try {
76
+ return await Location.findOneAndUpdate(criteria, data, options);
77
+ } catch (error) {
78
+ console.log(error);
79
+ return null;
80
+ }
81
+ };
82
+ const deleteLocationById = async (locationId) => {
83
+ try {
84
+ return await Location.findByIdAndDelete(locationId);
85
+ } catch (error) {
86
+ console.log(error);
87
+ return null;
88
+ }
89
+ };
90
+
91
+ const findLocation = async (criteria) => {
92
+ try {
93
+ return await Location.findOne(criteria);
94
+ } catch (error) {
95
+ console.log(error);
96
+ return null;
97
+ }
98
+ };
99
+
100
+ const findLocations = async (criteria) => {
101
+ try {
102
+ return await Location.find(criteria);
103
+ } catch (error) {
104
+ console.log(error);
105
+ return [];
106
+ }
107
+ };
108
+
109
+ const locationsByAggregation = async (aggregate = []) => {
110
+ try {
111
+ let locations = await Location.aggregate(aggregate);
112
+ return locations;
113
+ } catch (err) {
114
+ return [];
115
+ }
116
+ };
117
+
118
+ const locationsUpdateMany = async (criteria, updateData, options = {}) => {
119
+ try {
120
+ return await Location.updateMany(criteria, updateData, options);
121
+ } catch (error) {
122
+ return null;
123
+ }
124
+ };
125
+
126
+ const insertLocations = async (locations) => {
127
+ try {
128
+ return await Location.insertMany(locations);
129
+ } catch (err) {
130
+ return [];
131
+ }
132
+ };
133
+
134
+ module.exports = {
135
+ Location,
136
+ createNewLocation,
137
+ findLocationById,
138
+ updateLocationById,
139
+ updateLocation,
140
+ deleteLocationById,
141
+ findLocation,
142
+ findLocations,
143
+ locationsByAggregation,
144
+ locationsUpdateMany,
145
+ insertLocations,
146
+ findAndUpdateLocation,
147
+ };
package/models/Logo.js ADDED
@@ -0,0 +1,11 @@
1
+ const mongoose = require("mongoose");
2
+
3
+ const logoSchema = new mongoose.Schema(
4
+ {
5
+ url: { type: String, default: "" },
6
+ workspaceId: { type: String, default: "" },
7
+ },
8
+ { timestamps: true, toJSON: { virtuals: true }, toObject: { virtuals: true } }
9
+ );
10
+
11
+ module.exports = mongoose.model("Logo", logoSchema);
@@ -0,0 +1,32 @@
1
+ const mongoose = require("mongoose");
2
+ const { Schema } = mongoose;
3
+
4
+ const NotificationSchema = new Schema(
5
+ {
6
+ type: { type: String, default: "" },
7
+ isRead: { type: Boolean, default: false },
8
+ operation: { type: String, default: "" },
9
+ actionId: { type: String, default: "" },
10
+ workspaceId: { type: String, default: "" },
11
+ workspaceName: { type: String, default: "" },
12
+ message: { type: String, default: "" },
13
+ email: { type: String, default: "" },
14
+ userId: { type: String, default: "" },
15
+ data: { type: mongoose.Schema.Types.Mixed },
16
+ isDeleted: { type: Boolean, default: false },
17
+ alertShow: { type: Boolean, default: false },
18
+ routes: {
19
+ routeType: { type: String, default: "" },
20
+ id: { type: String, default: "" },
21
+ query: { type: Boolean, default: false },
22
+ queryData: { type: String, default: "" },
23
+ },
24
+ permissions: [],
25
+ role: [String],
26
+ },
27
+ { timestamps: true, toJSON: { virtuals: true }, toObject: { virtuals: true } }
28
+ );
29
+
30
+ const Notification = mongoose.model("Notification", NotificationSchema);
31
+
32
+ module.exports = Notification;
package/models/Order.js CHANGED
@@ -136,6 +136,14 @@ const OrderSchema = new Schema(
136
136
  paymentDate: { type: String, default: "" },
137
137
  paymentDetails: {},
138
138
  },
139
+ merged: {
140
+ status: { type: String, default: "open" },
141
+ webOrderNumbers: [],
142
+ orderNumbers: [],
143
+ localOrderIds: [],
144
+ webOrderIds: [],
145
+ details: [],
146
+ },
139
147
  credentials: {},
140
148
  ticketId: { type: String, default: "" },
141
149
  sender: { type: String, default: "" },
@@ -159,6 +167,9 @@ const OrderSchema = new Schema(
159
167
  },
160
168
  orderName: { type: String, default: "" },
161
169
  totalWeight: { type: String, default: "" },
170
+ currency: {},
171
+ presentedCurrency: {},
172
+ exchangeRate: { type: Number, default: 0 },
162
173
  },
163
174
  { timestamps: true, toJSON: { virtuals: true }, toObject: { virtuals: true } }
164
175
  );
@@ -0,0 +1,29 @@
1
+ const mongoose = require("mongoose");
2
+ const { Schema } = mongoose;
3
+
4
+ const OrderPdfScehma = new mongoose.Schema(
5
+ {
6
+ orderNumber: {
7
+ type: {
8
+ localMin: { type: String, default: "" },
9
+ localMax: { type: String, default: "" },
10
+ storeMin: { type: String, default: "" },
11
+ storeMax: { type: String, default: "" },
12
+ },
13
+ },
14
+ ordersCount: { type: String, default: "" },
15
+ url: { type: String, default: "" },
16
+ key: { type: String, default: "" },
17
+ status: { type: String, default: "" },
18
+ workspaceId: {
19
+ type: Schema.Types.ObjectId,
20
+ ref: "Workspace",
21
+ default: null,
22
+ },
23
+ createdBy: { type: Schema.Types.ObjectId, ref: "User", default: null },
24
+ updatedBy: { type: Schema.Types.ObjectId, ref: "User", default: null },
25
+ },
26
+ { timestamps: true, toJSON: { virtuals: true }, toObject: { virtuals: true } }
27
+ );
28
+
29
+ module.exports = mongoose.model("OrderPdf", OrderPdfScehma);
@@ -0,0 +1,66 @@
1
+ const mongoose = require("mongoose");
2
+ const { Schema } = mongoose;
3
+
4
+ const PostsAutomation = new mongoose.Schema(
5
+ {
6
+ workspaceId: {
7
+ type: Schema.Types.ObjectId,
8
+ ref: "Workspace",
9
+ default: null,
10
+ },
11
+ platformType: {
12
+ type: String,
13
+ required: true,
14
+ enum: ["facebook", "instagram"],
15
+ },
16
+ attachments: [
17
+ {
18
+ type: String,
19
+ default: "",
20
+ },
21
+ ],
22
+ attachmentType: {
23
+ type: String,
24
+ default: "",
25
+ },
26
+ postId: {
27
+ type: String,
28
+ default: "",
29
+ },
30
+ verb: {
31
+ type: String,
32
+ default: "",
33
+ },
34
+ published: {
35
+ type: String,
36
+ default: "",
37
+ },
38
+ message: {
39
+ type: String,
40
+ default: "",
41
+ },
42
+ pageId: {
43
+ type: String,
44
+ default: "",
45
+ },
46
+ field: {
47
+ type: String,
48
+ default: "",
49
+ },
50
+ integratedAccount: {
51
+ type: Schema.Types.ObjectId,
52
+ ref: "Integration",
53
+ default: null,
54
+ },
55
+ status: {
56
+ type: String,
57
+ default: "",
58
+ emum: ["active", "pending", "removed"],
59
+ },
60
+ platformTimestamp: { type: String, default: "" },
61
+ body: [{}],
62
+ },
63
+ { timestamps: true, toJSON: { virtuals: true }, toObject: { virtuals: true } }
64
+ );
65
+
66
+ module.exports = mongoose.model("PostsAutomation", PostsAutomation);