shuttlepro-shared 1.5.44 → 1.5.46

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) {
@@ -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",
@@ -450,6 +450,16 @@ const workspaceSchema = new mongoose.Schema(
450
450
  type: Boolean,
451
451
  default: false,
452
452
  },
453
+ /**
454
+ * OMS "Tagged" tab. When true, unpublished orders with a custom tag leave Pending/Confirmed,
455
+ * show in the Tagged tab, are skipped by auto-publish, and are published with a shipper the
456
+ * agent picks. Set by admins in Settings → General Settings
457
+ * (mainApp PUT /settings/update-tagged-orders-tab).
458
+ */
459
+ enableTaggedOrdersTab: {
460
+ type: Boolean,
461
+ default: false,
462
+ },
453
463
  productNavigationLink: { type: String, default: "" },
454
464
  productCategory: { type: String, default: "" },
455
465
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shuttlepro-shared",
3
- "version": "1.5.44",
3
+ "version": "1.5.46",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {