shuttlepro-shared 1.5.5 → 1.5.7

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.
@@ -70,6 +70,27 @@ const findIntegrationsByWorkspace = async (workspaceId, filter = {}) => {
70
70
  );
71
71
  };
72
72
 
73
+ /**
74
+ * Find integration by filter directly from DB (bypasses cache).
75
+ */
76
+ const findIntegrationByFilterFromDb = async (
77
+ filter,
78
+ bodyFilter = {},
79
+ workspaceId = null
80
+ ) => {
81
+ const query = { ...filter };
82
+
83
+ if (workspaceId) {
84
+ query.workspaceId = workspaceId;
85
+ }
86
+
87
+ Object.entries(bodyFilter).forEach(([key, value]) => {
88
+ query[`body.${key}`] = value;
89
+ });
90
+
91
+ return Integration.findOne(query).lean().exec();
92
+ };
93
+
73
94
  /**
74
95
  * Find integration by filter (supports both workspace & non-workspace).
75
96
  */
@@ -200,6 +221,7 @@ module.exports = {
200
221
  findIntegrationsByWorkspaceId,
201
222
  findIntegrationsByWorkspace,
202
223
  findIntegrationByFilter,
224
+ findIntegrationByFilterFromDb,
203
225
  findAllIntegrations,
204
226
  updateIntegration,
205
227
  updateIntegrationByFilter,
@@ -66,6 +66,16 @@ const FeedbackBotSchema = new Schema(
66
66
  type: Date,
67
67
  default: null,
68
68
  },
69
+ type: {
70
+ type: String,
71
+ enum: ["shop", "order"],
72
+ default: "order",
73
+ },
74
+ shopId: {
75
+ type: Schema.Types.ObjectId,
76
+ ref: "Shop",
77
+ default: null,
78
+ },
69
79
  // Store reference to order/workflow if applicable
70
80
  orderId: {
71
81
  type: String,
@@ -91,6 +101,8 @@ FeedbackBotSchema.index({ chatbotId: 1 });
91
101
  FeedbackBotSchema.index({ status: 1 });
92
102
  // Index for order_id based queries (allows multiple feedback per conversation)
93
103
  FeedbackBotSchema.index({ workspaceId: 1, phoneNumber: 1, orderId: 1 });
104
+ FeedbackBotSchema.index({ shopId: 1 });
105
+ FeedbackBotSchema.index({ type: 1 });
94
106
 
95
107
  module.exports = FeedbackBotSchema;
96
108
 
package/models/Shop.js CHANGED
@@ -29,7 +29,8 @@ const ShopSchema = new mongoose.Schema(
29
29
  },
30
30
  qrInitialMessage: {
31
31
  type: String,
32
- default: "",
32
+ required: [true, "Initial message is required for shop feedback QR"],
33
+ trim: true,
33
34
  },
34
35
  isActive: {
35
36
  type: Boolean,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shuttlepro-shared",
3
- "version": "1.5.05",
3
+ "version": "1.5.07",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {