shuttlepro-shared 1.4.72 → 1.4.74
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.
- package/common/repositories/userRole.repository.js +8 -4
- package/dump.rdb +0 -0
- package/models/Automation.js +1 -0
- package/models/Message.js +1 -0
- package/models/Shipper.js +0 -31
- package/models/UserRole.js +2 -1
- package/package.json +1 -1
|
@@ -15,7 +15,7 @@ const updateCachedMembers = async (workspaceId) => {
|
|
|
15
15
|
.populate({
|
|
16
16
|
path: "roleId",
|
|
17
17
|
select:
|
|
18
|
-
"id name userId userShift permissionId modulePermissions workspaceId",
|
|
18
|
+
"id name userId userShift permissionId modulePermissions workspaceId extraCapabilities scope",
|
|
19
19
|
populate: [{ path: "permissionId", select: "id name" }],
|
|
20
20
|
})
|
|
21
21
|
.populate({
|
|
@@ -35,14 +35,14 @@ 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")
|
|
42
42
|
.populate({
|
|
43
43
|
path: "roleId",
|
|
44
44
|
select:
|
|
45
|
-
"id name userId userShift permissionId modulePermissions workspaceId",
|
|
45
|
+
"id name userId userShift permissionId modulePermissions workspaceId extraCapabilities scope",
|
|
46
46
|
populate: [{ path: "permissionId", select: "id name" }],
|
|
47
47
|
})
|
|
48
48
|
.populate({
|
|
@@ -165,6 +165,8 @@ const getUserRoleWithPermissions = async (workspaceId, userId) => {
|
|
|
165
165
|
parentRole: data?.roleId?.permissionId?.name || "",
|
|
166
166
|
parentRoleId: data?.roleId?.permissionId?._id?.toString() || "",
|
|
167
167
|
defaultModule: data?.roleId?.defaultModule || "",
|
|
168
|
+
extraCapabilities: data?.roleId?.extraCapabilities || [],
|
|
169
|
+
scope: data?.roleId?.scope || "workspace",
|
|
168
170
|
};
|
|
169
171
|
return roleWithPermissions || null;
|
|
170
172
|
}
|
|
@@ -197,7 +199,7 @@ const findUserWorkspaces = async (userId) => {
|
|
|
197
199
|
.select("userId roleId workspaceId")
|
|
198
200
|
.populate({
|
|
199
201
|
path: "roleId",
|
|
200
|
-
select: "id name userId userShift permissionId modulePermissions",
|
|
202
|
+
select: "id name userId userShift permissionId modulePermissions extraCapabilities scope",
|
|
201
203
|
populate: [{ path: "permissionId", select: "id name" }],
|
|
202
204
|
})
|
|
203
205
|
.populate({
|
|
@@ -217,6 +219,8 @@ const findUserWorkspaces = async (userId) => {
|
|
|
217
219
|
_id: ur?.workspaceId?._id?.toString(),
|
|
218
220
|
role: ur?.roleId?.name || "",
|
|
219
221
|
permissions: ur?.roleId?.modulePermissions?.modules || [],
|
|
222
|
+
extraCapabilities: ur?.roleId?.extraCapabilities || [],
|
|
223
|
+
scope: ur?.roleId?.scope || "workspace",
|
|
220
224
|
};
|
|
221
225
|
});
|
|
222
226
|
return userRoleWithWorkspaces || [];
|
package/dump.rdb
ADDED
|
Binary file
|
package/models/Automation.js
CHANGED
package/models/Message.js
CHANGED
package/models/Shipper.js
CHANGED
|
@@ -41,7 +41,6 @@ const shipperInformationSchema = new Schema({
|
|
|
41
41
|
const shipperSchema = new mongoose.Schema(
|
|
42
42
|
{
|
|
43
43
|
type: { type: String, default: "" },
|
|
44
|
-
name: { type: String, default: "" },
|
|
45
44
|
userName: { type: String, default: "" },
|
|
46
45
|
password: { type: String, default: "" },
|
|
47
46
|
clientId: { type: String, default: "" },
|
|
@@ -65,34 +64,4 @@ const shipperSchema = new mongoose.Schema(
|
|
|
65
64
|
{ timestamps: true, toJSON: { virtuals: true }, toObject: { virtuals: true } }
|
|
66
65
|
);
|
|
67
66
|
|
|
68
|
-
/**
|
|
69
|
-
* Auto-generate shipper name if not provided
|
|
70
|
-
* Format: "{TYPE} {NUMBER}" e.g., "DAEWOO 1", "DAEWOO 2", etc.
|
|
71
|
-
*/
|
|
72
|
-
shipperSchema.pre("save", async function (next) {
|
|
73
|
-
// Only auto-generate if name is empty or not provided
|
|
74
|
-
if (!this.name || this.name.trim() === "") {
|
|
75
|
-
if (this.type && this.workspaceId) {
|
|
76
|
-
try {
|
|
77
|
-
// Count existing shippers of the same type in the same workspace (including deleted ones for numbering)
|
|
78
|
-
const ShipperModel = this.constructor;
|
|
79
|
-
const count = await ShipperModel.countDocuments({
|
|
80
|
-
type: this.type,
|
|
81
|
-
workspaceId: this.workspaceId,
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
// Generate name: "TYPE NUMBER" (starting from 1)
|
|
85
|
-
this.name = `${this.type} ${count + 1}`;
|
|
86
|
-
} catch (error) {
|
|
87
|
-
// If counting fails, use a simple fallback
|
|
88
|
-
this.name = `${this.type} 1`;
|
|
89
|
-
}
|
|
90
|
-
} else {
|
|
91
|
-
// Fallback if type or workspaceId is missing
|
|
92
|
-
this.name = this.type || "Shipper";
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
next();
|
|
96
|
-
});
|
|
97
|
-
|
|
98
67
|
module.exports = mongoose.model("shipper", shipperSchema);
|
package/models/UserRole.js
CHANGED