shuttlepro-shared 1.3.39 → 1.3.41

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 +14 -83
  2. package/common/repositories/userRole.repository.js +2 -5
  3. package/config/redis.js +73 -72
  4. package/middlewares/checkPermission/index.js +23 -36
  5. package/models/ActivityLogs.js +0 -1
  6. package/models/AgentActivity.js +4 -5
  7. package/models/Card.js +1 -50
  8. package/models/Chatbot.js +1 -1
  9. package/models/Column.js +0 -6
  10. package/models/Conversation.js +0 -40
  11. package/models/Customer.js +1 -2
  12. package/models/Integration.js +0 -6
  13. package/models/Order.js +0 -11
  14. package/models/Profile.js +1 -3
  15. package/models/Workspace.js +4 -78
  16. package/models.js +49 -168
  17. package/package.json +1 -1
  18. package/models/Activity.js +0 -28
  19. package/models/Attribute.js +0 -130
  20. package/models/Automation.js +0 -242
  21. package/models/BusinessRule.js +0 -16
  22. package/models/BusinessRuleHelper.js +0 -13
  23. package/models/Catalogue.js +0 -22
  24. package/models/Category.js +0 -129
  25. package/models/ChatMemberSession.js +0 -21
  26. package/models/ChatMessage.js +0 -43
  27. package/models/Color.js +0 -10
  28. package/models/CustomerCheckpoint.js +0 -21
  29. package/models/DeviceInfo.js +0 -13
  30. package/models/Email.js +0 -21
  31. package/models/EmailMessage.js +0 -30
  32. package/models/EmailNotification.js +0 -17
  33. package/models/EscalationConfiguration.js +0 -123
  34. package/models/EscalationManager.js +0 -50
  35. package/models/Faq.js +0 -29
  36. package/models/FeedbackResponse.js +0 -72
  37. package/models/FormTemplate.js +0 -27
  38. package/models/InternalComments.js +0 -27
  39. package/models/InternalThreads.js +0 -20
  40. package/models/JobDesign.js +0 -32
  41. package/models/JobQueue.js +0 -17
  42. package/models/LabelsPdf.js +0 -12
  43. package/models/Layout.js +0 -12
  44. package/models/LoadSheet.js +0 -31
  45. package/models/Location.js +0 -147
  46. package/models/Logo.js +0 -11
  47. package/models/MailGroup.js +0 -21
  48. package/models/Notification.js +0 -32
  49. package/models/OrderPdf.js +0 -29
  50. package/models/PostsAutomation.js +0 -66
  51. package/models/Product.js +0 -336
  52. package/models/ProductAttachment.js +0 -158
  53. package/models/ProductAttribute.js +0 -140
  54. package/models/ProductCategory.js +0 -128
  55. package/models/ProductLabels.js +0 -11
  56. package/models/ProductShopify.js +0 -13
  57. package/models/ProductTag.js +0 -124
  58. package/models/ProductVariant.js +0 -156
  59. package/models/ServiceUsage.js +0 -26
  60. package/models/ShipperSetting.js +0 -24
  61. package/models/SocialGroup.js +0 -127
  62. package/models/SocialPost.js +0 -40
  63. package/models/SocialProfile.js +0 -56
  64. package/models/Story.js +0 -86
  65. package/models/Tag.js +0 -77
  66. package/models/Template.js +0 -76
  67. package/models/TemplateFrame.js +0 -55
  68. package/models/TemplateTag.js +0 -10
  69. package/models/UserGuide.js +0 -21
  70. package/models/UserSession.js +0 -47
  71. package/models/VariantLocation.js +0 -145
  72. package/models/WhatsappFlow.js +0 -29
  73. package/models/Workflow.js +0 -34
@@ -1,29 +0,0 @@
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);
@@ -1,66 +0,0 @@
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);
package/models/Product.js DELETED
@@ -1,336 +0,0 @@
1
- const mongoose = require("mongoose");
2
- const { Schema } = mongoose;
3
- const axios = require("axios");
4
- const NewProduct = require("./NewProduct"); // Make sure to import NewProduct model
5
-
6
- const categorySchema = new Schema({
7
- _id: false,
8
- categoryId: { type: String, default: "" },
9
- name: { type: String, default: "" },
10
- });
11
-
12
- const ProductSchema = new Schema(
13
- {
14
- name: { type: String, default: "" },
15
- description: { type: String, default: "" },
16
- sku: { type: String, default: "" },
17
- price: { type: String, default: 0 },
18
- quantity: { type: Number, default: 0 },
19
- imageUrl: { type: String, default: "" },
20
- costPrice: { type: String, default: 0 },
21
- salePrice: { type: String, default: 0 },
22
- preference: { type: Number, default: 10 },
23
- oldId: { type: String, default: "" },
24
- webProductId: { type: Number, default: null },
25
- publishedAt: { type: String, default: "" },
26
- workspaceId: {
27
- type: Schema.Types.ObjectId,
28
- ref: "Workspace",
29
- default: null,
30
- },
31
- storeType: { type: String, default: "LOCAL" },
32
- isDeleted: { type: Boolean, default: false },
33
- inventoryPolicy: { type: String, default: "deny" }, //deny,continue
34
- inventoryManagement: { type: String, default: "shopify" }, //shopify, null, fulfillment_service
35
- createdBy: { type: Schema.Types.ObjectId, ref: "User", default: null },
36
- updatedBy: { type: Schema.Types.ObjectId, ref: "User", default: null },
37
- storeUrl: { type: String, default: "" },
38
- status: { type: String, default: "active" }, //active, archived, draft
39
- categories: [],
40
- variantCount: { type: Number, default: 0 },
41
- productType: { type: String, default: "" },
42
- vendor: { type: String, default: "" },
43
- handle: { type: String, default: "" },
44
- isWebhookCase: { type: Boolean, default: false },
45
- updating: { type: Boolean, default: false },
46
- attributes: [],
47
- },
48
- { timestamps: true, toJSON: { virtuals: true }, toObject: { virtuals: true } }
49
- );
50
-
51
- ProductSchema.virtual("productCategories", {
52
- ref: "ProductCategory",
53
- localField: "_id",
54
- foreignField: "productId",
55
- });
56
- ProductSchema.virtual("productTags", {
57
- ref: "ProductTag",
58
- localField: "_id",
59
- foreignField: "productId",
60
- });
61
- ProductSchema.virtual("productAttributes", {
62
- ref: "ProductAttribute",
63
- localField: "_id",
64
- foreignField: "productId",
65
- });
66
- ProductSchema.virtual("productAttachments", {
67
- ref: "ProductAttachment",
68
- localField: "_id",
69
- foreignField: "productId",
70
- });
71
- ProductSchema.virtual("productVariants", {
72
- ref: "ProductVariant",
73
- localField: "_id",
74
- foreignField: "productId",
75
- });
76
- ProductSchema.virtual("variantLocations", {
77
- ref: "VariantLocation",
78
- localField: "_id",
79
- foreignField: "productId",
80
- });
81
-
82
- const transformProductData = async (product) => {
83
- if (!product) return null;
84
-
85
- const populatedProduct = await mongoose.models.Product.findById(product._id)
86
- .populate({
87
- path: "productVariants",
88
- match: { isDeleted: false },
89
- })
90
- .populate({
91
- path: "productAttachments",
92
- match: { isDeleted: false },
93
- populate: {
94
- path: "variantIds",
95
- model: "ProductVariant",
96
- match: { isDeleted: false },
97
- },
98
- })
99
- .lean()
100
- .exec();
101
-
102
- if (!populatedProduct) return null;
103
-
104
- return {
105
- name: populatedProduct.name || "",
106
- id: populatedProduct._id || "",
107
- description: populatedProduct.description || "",
108
- sku: populatedProduct.sku || "",
109
- price: populatedProduct.price || "",
110
- quantity: populatedProduct.quantity || 0,
111
- imageUrl: populatedProduct.imageUrl || "",
112
- costPrice: populatedProduct.costPrice || 0,
113
- salePrice: populatedProduct.salePrice || 0,
114
- webProductId: populatedProduct.webProductId || "",
115
- variants:
116
- populatedProduct.productVariants?.map((p) => ({
117
- id: p?._id,
118
- name: p?.name || "",
119
- sku: p?.sku || "",
120
- subSku: p?.subSku || "",
121
- productId: p?.productId || "",
122
- price: p?.price || "",
123
- costPrice: p?.costPrice || 0,
124
- salePrice: p?.salePrice || 0,
125
- quantity: p?.quantity || 0,
126
- })) || [],
127
- attachments:
128
- populatedProduct.productAttachments?.map((x) => ({
129
- id: x?._id,
130
- thumbUrl: x?.thumbUrl,
131
- remoteUrl: x?.remoteUrl,
132
- url: x?.url,
133
- type: x?.type,
134
- variants:
135
- x?.variantIds?.length > 0
136
- ? x.variantIds.map((p) => ({
137
- id: p?._id,
138
- name: p?.name || "",
139
- sku: p?.sku || "",
140
- subSku: p?.subSku || "",
141
- productId: p?.productId || "",
142
- price: p?.price || "",
143
- costPrice: p?.costPrice || 0,
144
- salePrice: p?.salePrice || 0,
145
- quantity: p?.quantity || 0,
146
- }))
147
- : [],
148
- })) || [],
149
- workspaceId: populatedProduct.workspaceId,
150
- };
151
- };
152
-
153
- // Middleware for various operations
154
- const updateNewProduct = async (doc, next) => {
155
- try {
156
- // Skip if document is marked as deleted
157
- if (doc.isDeleted) return;
158
-
159
- // Transform and upsert product data
160
- const newProductData = await transformProductData(doc);
161
- if (newProductData) {
162
- await NewProduct.findOneAndUpdate(
163
- { id: newProductData.id },
164
- newProductData,
165
- { upsert: true, new: true }
166
- );
167
- }
168
- } catch (error) {
169
- console.error("Error updating NewProduct:", error);
170
- // Call next with error if needed
171
- next(error);
172
- }
173
- };
174
-
175
- const deleteNewProduct = async (doc, next) => {
176
- try {
177
- if (doc) {
178
- await NewProduct.deleteOne({ id: doc._id });
179
- }
180
- } catch (error) {
181
- console.error("Error deleting from NewProduct:", error);
182
- next(error);
183
- }
184
- };
185
-
186
- // Post middleware for various Mongoose operations
187
- ProductSchema.post("save", async function (doc, next) {
188
- console.log(doc, "doc");
189
- await updateNewProduct(doc, next);
190
- });
191
-
192
- ProductSchema.post("findOneAndUpdate", async function (doc, next) {
193
- await updateNewProduct(doc, next);
194
- });
195
-
196
- ProductSchema.post("updateOne", async function (doc, next) {
197
- console.log(doc, "doc called");
198
- await updateNewProduct(doc, next);
199
- });
200
-
201
- ProductSchema.post("create", async function (doc, next) {
202
- await updateNewProduct(doc, next);
203
- });
204
-
205
- ProductSchema.post("findOneAndDelete", async function (doc, next) {
206
- await deleteNewProduct(doc, next);
207
- });
208
-
209
- ProductSchema.post("deleteOne", async function (doc, next) {
210
- await deleteNewProduct(doc, next);
211
- });
212
-
213
- const Product = mongoose.model("Product", ProductSchema);
214
-
215
- const newProductInstance = async (productData) => {
216
- try {
217
- return new Product(productData);
218
- } catch (error) {
219
- return null;
220
- }
221
- };
222
-
223
- const createNewProduct = async (productData) => {
224
- try {
225
- return await Product.create(productData);
226
- } catch (error) {
227
- console.log(error);
228
- return null;
229
- }
230
- };
231
-
232
- const findProductById = async (productId) => {
233
- try {
234
- return await Product.findById(productId);
235
- } catch (error) {
236
- console.log(error);
237
- return null;
238
- }
239
- };
240
-
241
- const updateProductById = async (criteria, updateData, options) => {
242
- try {
243
- return await Product.findByIdAndUpdate(criteria, updateData, options);
244
- } catch (error) {
245
- console.log(error);
246
- return null;
247
- }
248
- };
249
-
250
- const updateProducts = async (criteria, updateData, options = {}) => {
251
- try {
252
- return await Product.updateMany(criteria, updateData, options);
253
- } catch (error) {
254
- console.log(error);
255
- return [];
256
- }
257
- };
258
-
259
- const deleteProductById = async (productId) => {
260
- try {
261
- return await Product.findByIdAndDelete(productId);
262
- } catch (error) {
263
- console.log(error);
264
- return null;
265
- }
266
- };
267
-
268
- const findProduct = async (criteria) => {
269
- try {
270
- return await Product.findOne(criteria);
271
- } catch (error) {
272
- console.log(error);
273
- return null;
274
- }
275
- };
276
-
277
- const findProducts = async (criteria) => {
278
- try {
279
- return await Product.find(criteria);
280
- } catch (error) {
281
- console.log(error);
282
- return [];
283
- }
284
- };
285
-
286
- const findSingleProduct = async (obj) => {
287
- try {
288
- let product = await Product.findOne(obj);
289
- return product;
290
- } catch (err) {
291
- return null;
292
- }
293
- };
294
-
295
- const countProductDocument = async (obj) => {
296
- try {
297
- let product = await Product.countDocuments(obj);
298
- return product;
299
- } catch (err) {
300
- return 0;
301
- }
302
- };
303
-
304
- const findProductWithPopulateAndPagination = async (
305
- condition,
306
- pop,
307
- page,
308
- limit
309
- ) => {
310
- try {
311
- const products = await Product.find(condition)
312
- .sort({ _id: -1 })
313
- .skip((page - 1) * parseInt(limit))
314
- .limit(parseInt(limit))
315
- .populate(pop);
316
- return products;
317
- } catch (err) {
318
- return 0;
319
- }
320
- };
321
-
322
- module.exports = {
323
- newProductInstance,
324
- createNewProduct,
325
- findProductById,
326
- updateProductById,
327
- updateProducts,
328
- deleteProductById,
329
- findProduct,
330
- findProducts,
331
- findSingleProduct,
332
- countProductDocument,
333
- findProductWithPopulateAndPagination,
334
- Product,
335
- ProductModel: Product,
336
- };
@@ -1,158 +0,0 @@
1
- const mongoose = require("mongoose");
2
- const { Schema } = mongoose;
3
- const ProductAttachmentSchema = new Schema(
4
- {
5
- type: { type: String, default: "default" },
6
- designJobId: {
7
- type: Schema.Types.ObjectId,
8
- ref: "JobDesign",
9
- default: null,
10
- },
11
- oldId: { type: String, default: "" },
12
- templateId: { type: Schema.Types.ObjectId, ref: "Template", default: null },
13
- remoteUrl: { type: String, default: "" },
14
- webImageId: { type: Number, default: null },
15
- default: { type: Boolean, default: false },
16
- productId: { type: Schema.Types.ObjectId, ref: "Product", default: null },
17
- url: { type: String, default: "" },
18
- thumbUrl: { type: String, default: "" },
19
- width: { type: Number, default: 0 },
20
- workspaceId: {
21
- type: Schema.Types.ObjectId,
22
- ref: "Workspace",
23
- default: null,
24
- },
25
- height: { type: Number, default: 0 },
26
- variantIds: [
27
- { type: Schema.Types.ObjectId, ref: "ProductVariant", default: null },
28
- ],
29
- createdBy: { type: Schema.Types.ObjectId, ref: "User", default: null },
30
- position: { type: Number, default: 1 },
31
- updatedBy: { type: Schema.Types.ObjectId, ref: "User", default: null },
32
- isDeleted: { type: Boolean, default: false },
33
- },
34
- { timestamps: true, toJSON: { virtuals: true }, toObject: { virtuals: true } }
35
- );
36
-
37
- ProductAttachmentSchema.virtual("products", {
38
- ref: "Product",
39
- localField: "productId",
40
- foreignField: "_id",
41
- });
42
-
43
- const ProductAttachment = mongoose.model(
44
- "ProductAttachment",
45
- ProductAttachmentSchema
46
- );
47
-
48
- const createNewProductAttachment = async (productAttachmentData) => {
49
- try {
50
- return await ProductAttachment.create(productAttachmentData);
51
- } catch (error) {
52
- console.log(error);
53
- return null;
54
- }
55
- };
56
-
57
- const insertProductAttachments = async (data) => {
58
- try {
59
- return await ProductAttachment.create(data);
60
- } catch (error) {
61
- console.log(error);
62
- return [];
63
- }
64
- };
65
-
66
- const findProductAttachmentById = async (productAttachmentId) => {
67
- try {
68
- return await ProductAttachment.findById(productAttachmentId);
69
- } catch (error) {
70
- console.log(error);
71
- return null;
72
- }
73
- };
74
-
75
- const updateProductAttachmentById = async (
76
- criteria,
77
- updateData,
78
- options = {}
79
- ) => {
80
- try {
81
- return await ProductAttachment.findByIdAndUpdate(
82
- criteria,
83
- updateData,
84
- options
85
- );
86
- } catch (error) {
87
- console.log(error);
88
- return null;
89
- }
90
- };
91
-
92
- const deleteProductAttachmentById = async (productAttachmentId) => {
93
- try {
94
- return await ProductAttachment.findByIdAndDelete(productAttachmentId);
95
- } catch (error) {
96
- console.log(error);
97
- return null;
98
- }
99
- };
100
-
101
- const findProductAttachment = async (criteria) => {
102
- try {
103
- return await ProductAttachment.findOne(criteria);
104
- } catch (error) {
105
- console.log(error);
106
- return null;
107
- }
108
- };
109
-
110
- const findProductAttachments = async (criteria) => {
111
- try {
112
- return await ProductAttachment.find(criteria);
113
- } catch (error) {
114
- console.log(error);
115
- return [];
116
- }
117
- };
118
-
119
- const updateManyProductAttachments = async (
120
- criteria,
121
- updatedData,
122
- options = {}
123
- ) => {
124
- try {
125
- return await ProductAttachment.updateMany(criteria, updatedData, options);
126
- } catch (error) {
127
- return [];
128
- }
129
- };
130
-
131
- const findAndUpdateProductAttachment = async (
132
- criteria,
133
- updatedData,
134
- options
135
- ) => {
136
- try {
137
- return await ProductAttachment.findOneAndUpdate(
138
- criteria,
139
- updatedData,
140
- options
141
- );
142
- } catch (error) {
143
- return [];
144
- }
145
- };
146
-
147
- module.exports = {
148
- createNewProductAttachment,
149
- insertProductAttachments,
150
- updateManyProductAttachments,
151
- findProductAttachmentById,
152
- updateProductAttachmentById,
153
- deleteProductAttachmentById,
154
- findProductAttachment,
155
- findProductAttachments,
156
- ProductAttachment,
157
- findAndUpdateProductAttachment,
158
- };