shuttlepro-shared 1.3.41 → 1.3.43

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 (73) 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/ActivityLogs.js +1 -0
  7. package/models/AgentActivity.js +5 -4
  8. package/models/Attribute.js +130 -0
  9. package/models/Automation.js +231 -0
  10. package/models/BusinessRule.js +16 -0
  11. package/models/BusinessRuleHelper.js +13 -0
  12. package/models/Card.js +50 -1
  13. package/models/Catalogue.js +22 -0
  14. package/models/Category.js +129 -0
  15. package/models/ChatMemberSession.js +21 -0
  16. package/models/ChatMessage.js +43 -0
  17. package/models/Chatbot.js +1 -1
  18. package/models/Color.js +10 -0
  19. package/models/Column.js +6 -0
  20. package/models/Conversation.js +40 -0
  21. package/models/Customer.js +2 -1
  22. package/models/CustomerCheckpoint.js +21 -0
  23. package/models/DeviceInfo.js +13 -0
  24. package/models/Email.js +21 -0
  25. package/models/EmailMessage.js +30 -0
  26. package/models/EmailNotification.js +17 -0
  27. package/models/EscalationConfiguration.js +123 -0
  28. package/models/EscalationManager.js +50 -0
  29. package/models/Faq.js +29 -0
  30. package/models/FeedbackResponse.js +72 -0
  31. package/models/FormTemplate.js +27 -0
  32. package/models/Integration.js +8 -0
  33. package/models/InternalComments.js +27 -0
  34. package/models/InternalThreads.js +20 -0
  35. package/models/JobDesign.js +32 -0
  36. package/models/JobQueue.js +17 -0
  37. package/models/LabelsPdf.js +12 -0
  38. package/models/Layout.js +12 -0
  39. package/models/LoadSheet.js +31 -0
  40. package/models/Location.js +148 -0
  41. package/models/Logo.js +11 -0
  42. package/models/MailGroup.js +21 -0
  43. package/models/Notification.js +32 -0
  44. package/models/Order.js +11 -0
  45. package/models/OrderPdf.js +29 -0
  46. package/models/PostsAutomation.js +66 -0
  47. package/models/Product.js +337 -0
  48. package/models/ProductAttachment.js +158 -0
  49. package/models/ProductAttribute.js +140 -0
  50. package/models/ProductCategory.js +128 -0
  51. package/models/ProductLabels.js +11 -0
  52. package/models/ProductShopify.js +13 -0
  53. package/models/ProductTag.js +124 -0
  54. package/models/ProductVariant.js +157 -0
  55. package/models/Profile.js +3 -1
  56. package/models/ServiceUsage.js +26 -0
  57. package/models/ShipperSetting.js +24 -0
  58. package/models/SocialGroup.js +127 -0
  59. package/models/SocialPost.js +40 -0
  60. package/models/SocialProfile.js +56 -0
  61. package/models/Story.js +86 -0
  62. package/models/Tag.js +77 -0
  63. package/models/Template.js +76 -0
  64. package/models/TemplateFrame.js +55 -0
  65. package/models/TemplateTag.js +10 -0
  66. package/models/UserGuide.js +21 -0
  67. package/models/UserSession.js +47 -0
  68. package/models/VariantLocation.js +145 -0
  69. package/models/WhatsappFlow.js +29 -0
  70. package/models/Workflow.js +34 -0
  71. package/models/Workspace.js +78 -4
  72. package/models.js +168 -49
  73. package/package.json +1 -1
@@ -0,0 +1,55 @@
1
+ const mongoose = require("mongoose");
2
+ const { Schema } = mongoose;
3
+
4
+ const templateFrameSchema = new mongoose.Schema(
5
+ {
6
+ fullImageUrl: { type: String, default: "" },
7
+ frameUrl: { type: String, default: "" },
8
+ name: { type: String, default: "" },
9
+ height: { type: Number },
10
+ width: { type: Number },
11
+ displayImageHeight: { type: Number },
12
+ displayImageWidth: { type: Number },
13
+ type: { type: String, default: "" },
14
+ categoryId: { type: Schema.Types.ObjectId, ref: "Catalogue" },
15
+ subCategoryId: { type: String, default: "" },
16
+ workspaceId: { type: String, default: "" },
17
+ colorIds: [
18
+ {
19
+ colorId: {
20
+ type: Schema.Types.ObjectId,
21
+ ref: "Color",
22
+ },
23
+ },
24
+ ],
25
+ tagIds: [
26
+ {
27
+ tagId: {
28
+ type: Schema.Types.ObjectId,
29
+ ref: "Tag",
30
+ },
31
+ },
32
+ ],
33
+ },
34
+ { timestamps: true, toJSON: { virtuals: true }, toObject: { virtuals: true } }
35
+ );
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
+
55
+ module.exports = mongoose.model("TemplateFrame", templateFrameSchema);
@@ -0,0 +1,10 @@
1
+ const mongoose = require("mongoose");
2
+
3
+ const tagSchema = new mongoose.Schema(
4
+ {
5
+ name: { type: String, default: "" },
6
+ },
7
+ { timestamps: true, toJSON: { virtuals: true }, toObject: { virtuals: true } }
8
+ );
9
+
10
+ module.exports = mongoose.model("TemplateTag", tagSchema);
@@ -0,0 +1,21 @@
1
+ const mongoose = require("mongoose");
2
+ const { Schema } = mongoose;
3
+ const UserGuideSchema = new Schema(
4
+ {
5
+ category: {
6
+ type: String,
7
+ required: true,
8
+ },
9
+ subcategory: {
10
+ type: String,
11
+ required: true,
12
+ },
13
+ pdfUrl: {
14
+ type: String,
15
+ required: true,
16
+ },
17
+ },
18
+ { timestamps: true, toJSON: { virtuals: true }, toObject: { virtuals: true } }
19
+ );
20
+ const UserGuide = mongoose.model("UserGuide", UserGuideSchema);
21
+ module.exports = UserGuide;
@@ -0,0 +1,47 @@
1
+ const mongoose = require("mongoose");
2
+
3
+ const userSessionSchema = new mongoose.Schema(
4
+ {
5
+ userId: {
6
+ type: mongoose.Schema.Types.ObjectId,
7
+ ref: "User",
8
+ default: null,
9
+ },
10
+ browserId: {
11
+ type: String,
12
+ default: "",
13
+ },
14
+ ipAddress: {
15
+ type: String,
16
+ default: "",
17
+ },
18
+ userAgent: {
19
+ type: String,
20
+ default: "",
21
+ },
22
+ createdTime: {
23
+ type: String,
24
+ default: "",
25
+ },
26
+ lastActivity: {
27
+ type: String,
28
+ default: "",
29
+ },
30
+ valid: {
31
+ type: Boolean,
32
+ default: true,
33
+ },
34
+ uuid: {
35
+ type: String,
36
+ default: "",
37
+ },
38
+ type: {
39
+ type: String,
40
+ default: "web",
41
+ },
42
+ },
43
+ { timestamps: true, toJSON: { virtuals: true }, toObject: { virtuals: true } }
44
+ );
45
+
46
+ const UserSession = mongoose.model("UserSession", userSessionSchema);
47
+ module.exports = UserSession;
@@ -0,0 +1,145 @@
1
+ const mongoose = require("mongoose");
2
+ const { Schema } = mongoose;
3
+ const VariantLocationSchema = new Schema(
4
+ {
5
+ variantId: {
6
+ type: Schema.Types.ObjectId,
7
+ ref: "ProductVariant",
8
+ default: null,
9
+ },
10
+ quantity: { type: Number, default: 0 },
11
+ workspaceId: {
12
+ type: Schema.Types.ObjectId,
13
+ ref: "Workspace",
14
+ default: null,
15
+ },
16
+ productId: { type: Schema.Types.ObjectId, ref: "Product", default: null },
17
+ locationId: { type: Schema.Types.ObjectId, ref: "Location", default: null },
18
+ webVariantLocationId: { type: Number, default: null },
19
+ rackNo: { type: String, default: "" },
20
+ boxNo: { type: String, default: "" },
21
+ shelfNo: { type: String, default: "" },
22
+ uuid: { type: String, default: "" },
23
+ createdBy: { type: Schema.Types.ObjectId, ref: "User", default: null },
24
+ updatedBy: { type: Schema.Types.ObjectId, ref: "User", default: null },
25
+ isDeleted: { type: Boolean, default: false },
26
+ },
27
+ { timestamps: true, toJSON: { virtuals: true }, toObject: { virtuals: true } }
28
+ );
29
+
30
+ const VariantLocation = mongoose.model(
31
+ "VariantLocation",
32
+ VariantLocationSchema
33
+ );
34
+
35
+ const createNewVariantLocation = async (variantLocationData) => {
36
+ try {
37
+ return await VariantLocation.create(variantLocationData);
38
+ } catch (error) {
39
+ console.log(error);
40
+ return null;
41
+ }
42
+ };
43
+
44
+ const insertVariantLocations = async (data) => {
45
+ try {
46
+ return await VariantLocation.insertMany(data);
47
+ } catch (error) {
48
+ console.log(error);
49
+ return [null];
50
+ }
51
+ };
52
+
53
+ const updateManyVariantsLocations = async (
54
+ criteria,
55
+ updateData,
56
+ options = {}
57
+ ) => {
58
+ try {
59
+ return await VariantLocation.updateMany(criteria, updateData, options);
60
+ } catch (error) {
61
+ console.log(error);
62
+ return null;
63
+ }
64
+ };
65
+
66
+ const findVariantLocationById = async (variantLocationId) => {
67
+ try {
68
+ return await VariantLocation.findById(variantLocationId);
69
+ } catch (error) {
70
+ console.log(error);
71
+ return null;
72
+ }
73
+ };
74
+
75
+ const updateVariantLocationById = async (criteria, updateData, options) => {
76
+ try {
77
+ return await VariantLocation.findByIdAndUpdate(
78
+ criteria,
79
+ updateData,
80
+ options
81
+ );
82
+ } catch (error) {
83
+ console.log(error);
84
+ return null;
85
+ }
86
+ };
87
+
88
+ const deleteVariantLocationById = async (variantLocationId) => {
89
+ try {
90
+ return await VariantLocation.findByIdAndDelete(variantLocationId);
91
+ } catch (error) {
92
+ console.log(error);
93
+ return null;
94
+ }
95
+ };
96
+
97
+ const findVariantLocation = async (criteria) => {
98
+ try {
99
+ return await VariantLocation.findOne(criteria);
100
+ } catch (error) {
101
+ console.log(error);
102
+ return null;
103
+ }
104
+ };
105
+
106
+ const findVariantLocations = async (criteria) => {
107
+ try {
108
+ return await VariantLocation.find(criteria);
109
+ } catch (error) {
110
+ console.log(error);
111
+ return [];
112
+ }
113
+ };
114
+
115
+ const findSingleVariantLocation = async (obj) => {
116
+ try {
117
+ let variantLocation = await VariantLocation.findOne(obj);
118
+ return variantLocation;
119
+ } catch (err) {
120
+ return null;
121
+ }
122
+ };
123
+
124
+ const findVariantLocationsByPopulate = async (criteria, populate) => {
125
+ try {
126
+ return await VariantLocation.find(criteria).populate(populate);
127
+ } catch (error) {
128
+ console.log(error);
129
+ return [];
130
+ }
131
+ };
132
+
133
+ module.exports = {
134
+ insertVariantLocations,
135
+ createNewVariantLocation,
136
+ updateManyVariantsLocations,
137
+ findVariantLocationById,
138
+ updateVariantLocationById,
139
+ findVariantLocationsByPopulate,
140
+ deleteVariantLocationById,
141
+ findVariantLocation,
142
+ findVariantLocations,
143
+ findSingleVariantLocation,
144
+ VariantLocation,
145
+ };
@@ -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;
@@ -0,0 +1,34 @@
1
+ const mongoose = require("mongoose");
2
+
3
+ const WorkflowSchema = new mongoose.Schema(
4
+ {
5
+ workspaceId: {
6
+ type: mongoose.Schema.Types.ObjectId,
7
+ ref: "Workspace",
8
+ required: true,
9
+ },
10
+ orders: {
11
+ enabled: { type: Boolean, default: false },
12
+ maxOrders: { type: Number, default: 100 },
13
+ currentCount: { type: Number, default: 0 },
14
+ },
15
+ chatbot: { type: Boolean, default: true },
16
+ nlpBot: {
17
+ enabled: { type: Boolean, default: true },
18
+ shared: {
19
+ maxRequests: { type: Number, default: 5000 },
20
+ maxTokens: { type: Number, default: 80000 },
21
+ requestsCount: { type: Number, default: 0 },
22
+ tokensCount: { type: Number, default: 0 },
23
+ },
24
+ custom: {
25
+ requestsCount: { type: Number, default: 0 },
26
+ tokensCount: { type: Number, default: 0 },
27
+ },
28
+ },
29
+ },
30
+ { timestamps: true, toJSON: { virtuals: true }, toObject: { virtuals: true } }
31
+ );
32
+
33
+ const Workflow = mongoose.model("Workflow", WorkflowSchema);
34
+ module.exports = Workflow;
@@ -1,7 +1,24 @@
1
1
  const mongoose = require("mongoose");
2
+ const SettingModel = require("./Setting");
3
+ const SocialMediaSettingModel = require("./SocialMediaSetting");
4
+ const { Schema } = mongoose;
5
+
6
+ const generateSlug = (input) => {
7
+ return input
8
+ .trim()
9
+ .toLowerCase()
10
+ .replace(/[^a-z0-9\s-]/g, "")
11
+ .replace(/\s+/g, "-")
12
+ .replace(/-+/g, "-");
13
+ };
14
+
2
15
  //TODO: task manager and default location creation
3
16
  const shiftSchema = new mongoose.Schema(
4
17
  {
18
+ _id: {
19
+ type: mongoose.Schema.Types.ObjectId,
20
+ default: () => new mongoose.Types.ObjectId(),
21
+ },
5
22
  shiftName: {
6
23
  type: String,
7
24
  required: true,
@@ -161,6 +178,13 @@ const workspaceSchema = new mongoose.Schema(
161
178
  required: true,
162
179
  trim: true,
163
180
  },
181
+ slug: {
182
+ type: String,
183
+ required: true,
184
+ trim: true,
185
+ default: "",
186
+ unique: true,
187
+ },
164
188
  iconUrl: { type: String, default: "" },
165
189
  thumbUrl: { type: String, default: "" },
166
190
  createdBy: {
@@ -273,6 +297,9 @@ const workspaceSchema = new mongoose.Schema(
273
297
  "url",
274
298
  "colour",
275
299
  "file",
300
+ "starRating",
301
+ "paragraph",
302
+ "heading",
276
303
  ],
277
304
  },
278
305
  option: {
@@ -292,9 +319,44 @@ const workspaceSchema = new mongoose.Schema(
292
319
  default: "everyone",
293
320
  },
294
321
  defaultShift: { type: String, default: "" },
322
+ automationManager: {
323
+ delayThreshold: {
324
+ type: Number,
325
+ default: 5,
326
+ },
327
+ messageCount: {
328
+ type: Number,
329
+ default: 3,
330
+ },
331
+ },
295
332
  },
296
333
  { timestamps: true, toJSON: { virtuals: true }, toObject: { virtuals: true } }
297
334
  );
335
+
336
+ workspaceSchema.virtual("products", {
337
+ ref: "Product",
338
+ localField: "_id",
339
+ foreignField: "workspaceId",
340
+ });
341
+
342
+ workspaceSchema.virtual("orders", {
343
+ ref: "Order",
344
+ localField: "_id",
345
+ foreignField: "workspaceId",
346
+ });
347
+
348
+ workspaceSchema.virtual("socialProfilesArr", {
349
+ ref: "socialProfile",
350
+ localField: "_id",
351
+ foreignField: "workspaceId",
352
+ });
353
+
354
+ workspaceSchema.virtual("integrations", {
355
+ ref: "Integration",
356
+ localField: "_id",
357
+ foreignField: "workspaceId",
358
+ });
359
+
298
360
  const commonOptions = {
299
361
  type: String,
300
362
  trim: true,
@@ -311,10 +373,22 @@ workspaceSchema.add({
311
373
  chatGptApiKey: commonOptions,
312
374
  });
313
375
 
314
- workspaceSchema.virtual("integrations", {
315
- ref: "Integration",
316
- localField: "_id",
317
- foreignField: "workspaceId",
376
+ workspaceSchema.pre("save", async function (next) {
377
+ if (this.isModified("name")) {
378
+ let slug = generateSlug(this.name);
379
+ let slugExists = await mongoose.models.Workspace.findOne({ slug });
380
+
381
+ let counter = 1;
382
+ while (slugExists) {
383
+ slug = `${slug}-${counter}`;
384
+ slugExists = await mongoose.models.Workspace.findOne({ slug });
385
+ counter++;
386
+ }
387
+
388
+ this.slug = slug;
389
+ }
390
+ next();
318
391
  });
392
+
319
393
  const Workspace = mongoose.model("Workspace", workspaceSchema);
320
394
  module.exports = Workspace;