shuttlepro-shared 1.5.44 → 1.5.47

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.
@@ -1,17 +1,30 @@
1
- const { getRedisData, setRedisData } = require("../../config/redis");
1
+ const {
2
+ getRedisData,
3
+ setRedisData,
4
+ deleteRedisData,
5
+ } = require("../../config/redis");
2
6
 
3
7
  const NotificationSettings = require("../../models/NotificationSettings");
4
8
 
9
+ // Settings are per user per workspace, so the key needs both.
10
+ const cacheKey = (workspaceId, userId) =>
11
+ `notificationSettings-${workspaceId}-${userId}`;
12
+
13
+ // Apps still on an older shuttlepro-shared read the user-only key. Drop it on
14
+ // save so they reload from the DB instead of serving a stale copy for an hour.
15
+ const clearLegacyKey = (userId) =>
16
+ deleteRedisData(`notificationSettings-${userId}`);
17
+
5
18
  const getNotificationFromCache = async (workspaceId, userId) => {
6
19
  let notificationSettings = await getRedisData(
7
- `notificationSettings-${userId}`
20
+ cacheKey(workspaceId, userId)
8
21
  );
9
22
  if (!notificationSettings) {
10
23
  notificationSettings = await NotificationSettings.findOne({
11
24
  workspaceId,
12
25
  createdBy: userId,
13
26
  });
14
- await setRedisData(`notificationSettings-${userId}`, notificationSettings);
27
+ await setRedisData(cacheKey(workspaceId, userId), notificationSettings);
15
28
  }
16
29
  return notificationSettings;
17
30
  };
@@ -49,6 +62,9 @@ const defaultNotifications = async (workspaceId, userId = null) => {
49
62
  sound: {
50
63
  play: true,
51
64
  },
65
+ alert: {
66
+ show: true,
67
+ },
52
68
  createdBy: userId,
53
69
  };
54
70
  return await NotificationSettings.create(obj);
@@ -75,12 +91,17 @@ const updateUserNotificationSettings = async (body, userId) => {
75
91
  if (notificationSettings) {
76
92
  notificationSettings[type] = value;
77
93
  const updatedSettings = await notificationSettings.save();
78
- await setRedisData(`notificationSettings-${userId}`, updatedSettings);
94
+ await setRedisData(
95
+ cacheKey(body.workspaceId, userId),
96
+ updatedSettings
97
+ );
98
+ await clearLegacyKey(userId);
79
99
  return updatedSettings;
80
100
  } else {
81
101
  const newSettings = await defaultNotifications(body.workspaceId, userId);
82
102
 
83
- await setRedisData(`notificationSettings-${userId}`, newSettings);
103
+ await setRedisData(cacheKey(body.workspaceId, userId), newSettings);
104
+ await clearLegacyKey(userId);
84
105
  return newSettings;
85
106
  }
86
107
  } catch (error) {
@@ -34,6 +34,7 @@ const conversationSchema = new mongoose.Schema(
34
34
  "smtp_gmail",
35
35
  "shuttle_smtp",
36
36
  "qlyro",
37
+ "qlyroWebChat",
37
38
  ],
38
39
  required: true,
39
40
  },
@@ -24,6 +24,7 @@ const IntegrationSchema = new mongoose.Schema(
24
24
  "sms",
25
25
  "shuttle_smtp",
26
26
  "qlyro",
27
+ "qlyroWebChat",
27
28
  ],
28
29
  },
29
30
  chatbot: { type: Boolean, default: false },
@@ -52,6 +53,14 @@ const IntegrationSchema = new mongoose.Schema(
52
53
  { timestamps: true, toJSON: { virtuals: true }, toObject: { virtuals: true } }
53
54
  );
54
55
 
56
+ // Qlyro Webchat: a website's chat button is found by its widget id on every
57
+ // page view. Partial, so it only holds Qlyro Webchat channels (each gets a
58
+ // unique widget id when created) and other platforms are unaffected.
59
+ IntegrationSchema.index(
60
+ { "body.widgetId": 1 },
61
+ { unique: true, partialFilterExpression: { type: "qlyroWebChat" } }
62
+ );
63
+
55
64
  IntegrationSchema.virtual("conversations", {
56
65
  ref: "Conversation",
57
66
  localField: "_id",
@@ -118,6 +118,19 @@ const NotificationSettingsSchema = new Schema(
118
118
  },
119
119
  },
120
120
 
121
+ // Bottom-right notification toasts and customer-message popups.
122
+ alert: {
123
+ type: {
124
+ show: {
125
+ type: Boolean,
126
+ default: true,
127
+ },
128
+ },
129
+ default: {
130
+ show: true,
131
+ },
132
+ },
133
+
121
134
  default: {
122
135
  type: Boolean,
123
136
  default: true,
package/models/Order.js CHANGED
@@ -187,11 +187,22 @@ const OrderSchema = new Schema(
187
187
  presentedCurrency: {},
188
188
  exchangeRate: { type: Number, default: 0 },
189
189
  markedInventory: { type: Boolean, default: false },
190
+ // Workspace-local tags added by agents in OMS. Separate from Shopify's own tags.
191
+ customTags: [
192
+ {
193
+ _id: false,
194
+ name: { type: String, trim: true, default: "" },
195
+ shopifySynced: { type: Boolean, default: false },
196
+ addedBy: { type: Schema.Types.ObjectId, ref: "User", default: null },
197
+ addedAt: { type: Date, default: Date.now },
198
+ },
199
+ ],
190
200
  },
191
201
  { timestamps: true, toJSON: { virtuals: true }, toObject: { virtuals: true } }
192
202
  );
193
203
 
194
204
  OrderSchema.index({ workspaceId: 1, websiteId: 1, webOrderId: 1 });
205
+ OrderSchema.index({ workspaceId: 1, "customTags.name": 1 });
195
206
 
196
207
  OrderSchema.virtual("checkPoints", {
197
208
  ref: "Checkpoint",
package/models/Website.js CHANGED
@@ -8,6 +8,9 @@ const websiteSchema = new mongoose.Schema(
8
8
  default: "",
9
9
  },
10
10
  accessToken: { type: String, default: "" },
11
+ refreshToken: { type: String, default: "" },
12
+ accessTokenExpires: { type: Date, default: null },
13
+ refreshTokenExpires: { type: Date, default: null },
11
14
  url: { type: String, default: "" },
12
15
  consumerKey: { type: String, default: "" },
13
16
  consumerSecret: { type: String, default: "" },
@@ -435,6 +435,14 @@ const workspaceSchema = new mongoose.Schema(
435
435
  chatbotTokenSaving: {
436
436
  type: Boolean,
437
437
  },
438
+ /**
439
+ * "AI chat summary" switch: true = after an AI chat is closed, aiSummaryApp writes a short
440
+ * summary for agents. No default on purpose: missing = off. Set by admins in Settings →
441
+ * General Settings (mainApp PUT /settings/update-ai-conversation-summary); off removes the field.
442
+ */
443
+ aiConversationSummary: {
444
+ type: Boolean,
445
+ },
438
446
  /** When true (default), ShuttleBot includes product photos with product detail replies. */
439
447
  chatbotShowProductImages: {
440
448
  type: Boolean,
@@ -450,6 +458,16 @@ const workspaceSchema = new mongoose.Schema(
450
458
  type: Boolean,
451
459
  default: false,
452
460
  },
461
+ /**
462
+ * OMS "Tagged" tab. When true, unpublished orders with a custom tag leave Pending/Confirmed,
463
+ * show in the Tagged tab, are skipped by auto-publish, and are published with a shipper the
464
+ * agent picks. Set by admins in Settings → General Settings
465
+ * (mainApp PUT /settings/update-tagged-orders-tab).
466
+ */
467
+ enableTaggedOrdersTab: {
468
+ type: Boolean,
469
+ default: false,
470
+ },
453
471
  productNavigationLink: { type: String, default: "" },
454
472
  productCategory: { type: String, default: "" },
455
473
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shuttlepro-shared",
3
- "version": "1.5.44",
3
+ "version": "1.5.47",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {