shuttlepro-shared 1.3.36 → 1.3.38
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.
|
@@ -35,7 +35,7 @@ const updateCachedMembers = async (workspaceId) => {
|
|
|
35
35
|
|
|
36
36
|
const getMembers = async (workspaceId) => {
|
|
37
37
|
let members = await getRedisData(workspaceId, MEMBERS);
|
|
38
|
-
|
|
38
|
+
|
|
39
39
|
if (!members || members?.length === 0) {
|
|
40
40
|
members = await UserRole.find({ workspaceId })
|
|
41
41
|
.select("userId role userShift roleId isOwner workspaceId")
|
|
@@ -54,7 +54,7 @@ const getMembers = async (workspaceId) => {
|
|
|
54
54
|
.exec();
|
|
55
55
|
await setRedisData(workspaceId, members, MEMBERS, 3600);
|
|
56
56
|
}
|
|
57
|
-
|
|
57
|
+
|
|
58
58
|
return members;
|
|
59
59
|
};
|
|
60
60
|
|
package/models/Product.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const mongoose = require("mongoose");
|
|
2
2
|
const { Schema } = mongoose;
|
|
3
3
|
const axios = require("axios");
|
|
4
|
-
const
|
|
4
|
+
const NewProduct = require("./NewProduct"); // Make sure to import NewProduct model
|
|
5
5
|
|
|
6
6
|
const categorySchema = new Schema({
|
|
7
7
|
_id: false,
|
package/models/Workspace.js
CHANGED
|
@@ -3,6 +3,15 @@ const SettingModel = require("./Setting");
|
|
|
3
3
|
const SocialMediaSettingModel = require("./SocialMediaSetting");
|
|
4
4
|
const { Schema } = mongoose;
|
|
5
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
|
+
|
|
6
15
|
//TODO: task manager and default location creation
|
|
7
16
|
const shiftSchema = new mongoose.Schema(
|
|
8
17
|
{
|
|
@@ -364,5 +373,22 @@ workspaceSchema.add({
|
|
|
364
373
|
chatGptApiKey: commonOptions,
|
|
365
374
|
});
|
|
366
375
|
|
|
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();
|
|
391
|
+
});
|
|
392
|
+
|
|
367
393
|
const Workspace = mongoose.model("Workspace", workspaceSchema);
|
|
368
394
|
module.exports = Workspace;
|