shuttlepro-shared 1.2.24 → 1.2.26
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/index.js +8 -0
- package/common/repositories/notificationSetting.repository.js +38 -0
- package/common/repositories/settings.repository.js +32 -0
- package/common/repositories/socialMediaSetting.repository.js +33 -0
- package/common/repositories/userPermission.repository.js +31 -0
- package/common/repositories/userRole.repository.js +45 -0
- package/config/redis.js +0 -2
- package/models/NotificationSettings.js +130 -0
- package/models/Setting.js +18 -0
- package/models/SocialMediaSetting.js +28 -0
- package/package.json +1 -1
|
@@ -4,6 +4,10 @@ const descriptionTemplateRepository = require("./descriptionTemplates.repository
|
|
|
4
4
|
const shipperRepository = require("./shipper.repository");
|
|
5
5
|
const labelRepository = require("./label.repository");
|
|
6
6
|
const userRepository = require("./user.repository");
|
|
7
|
+
const userRoleRepository = require("./userRole.repository");
|
|
8
|
+
const settingRepository = require("./settings.repository");
|
|
9
|
+
const socialMediaSettingRepository = require("./socialMediaSetting.repository");
|
|
10
|
+
const notificationSettingRepository = require("./notificationSetting.repository");
|
|
7
11
|
const chatMemberRepository = require("./chatMember.repository");
|
|
8
12
|
|
|
9
13
|
exports.module = {
|
|
@@ -13,5 +17,9 @@ exports.module = {
|
|
|
13
17
|
shipperRepository,
|
|
14
18
|
labelRepository,
|
|
15
19
|
userRepository,
|
|
20
|
+
userRoleRepository,
|
|
21
|
+
settingRepository,
|
|
22
|
+
socialMediaSettingRepository,
|
|
23
|
+
notificationSettingRepository,
|
|
16
24
|
chatMemberRepository,
|
|
17
25
|
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
const NotificationSettings = require("../../models/NotificationSettings");
|
|
2
|
+
|
|
3
|
+
const createNotificationSetting = async (data) => {
|
|
4
|
+
const newSetting = new NotificationSettings(data);
|
|
5
|
+
const savedSetting = await newSetting.save();
|
|
6
|
+
return savedSetting;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
const findNotificationSetting = async (filter) => {
|
|
10
|
+
return await NotificationSettings.findOne(filter).exec();
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const updateNotificationSetting = async (id, data) => {
|
|
14
|
+
const updatedSetting = await NotificationSettings.findByIdAndUpdate(
|
|
15
|
+
id,
|
|
16
|
+
data,
|
|
17
|
+
{
|
|
18
|
+
new: true,
|
|
19
|
+
}
|
|
20
|
+
).exec();
|
|
21
|
+
|
|
22
|
+
return updatedSetting;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const deleteNotificationSetting = async (id) => {
|
|
26
|
+
const deletedSetting = await NotificationSettings.findByIdAndDelete(
|
|
27
|
+
id
|
|
28
|
+
).exec();
|
|
29
|
+
|
|
30
|
+
return deletedSetting;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
module.exports = {
|
|
34
|
+
createNotificationSetting,
|
|
35
|
+
findNotificationSetting,
|
|
36
|
+
updateNotificationSetting,
|
|
37
|
+
deleteNotificationSetting,
|
|
38
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
const Setting = require("../../models/Setting");
|
|
2
|
+
|
|
3
|
+
const createSetting = async (data) => {
|
|
4
|
+
const newSetting = new Setting(data);
|
|
5
|
+
const savedSetting = await newSetting.save();
|
|
6
|
+
return savedSetting;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
const findSetting = async (filter) => {
|
|
10
|
+
return await Setting.findOne(filter).exec();
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const updateSetting = async (id, data) => {
|
|
14
|
+
const updatedSetting = await Setting.findByIdAndUpdate(id, data, {
|
|
15
|
+
new: true,
|
|
16
|
+
}).exec();
|
|
17
|
+
|
|
18
|
+
return updatedSetting;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const deleteSetting = async (id) => {
|
|
22
|
+
const deletedSetting = await Setting.findByIdAndDelete(id).exec();
|
|
23
|
+
|
|
24
|
+
return deletedSetting;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
module.exports = {
|
|
28
|
+
createSetting,
|
|
29
|
+
findSetting,
|
|
30
|
+
updateSetting,
|
|
31
|
+
deleteSetting,
|
|
32
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
const SocialMediaSetting = require("../../models/SocialMediaSetting");
|
|
2
|
+
|
|
3
|
+
const createSocialMediaSetting = async (data) => {
|
|
4
|
+
const setting = new SocialMediaSetting(data);
|
|
5
|
+
const saved = await setting.save();
|
|
6
|
+
|
|
7
|
+
return saved;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
const findSocialMediaSetting = async (filter = {}) => {
|
|
11
|
+
return await SocialMediaSetting.findOne(filter).exec();
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
const updateSocialMediaSetting = async (id, data) => {
|
|
15
|
+
const updated = await SocialMediaSetting.findByIdAndUpdate(id, data, {
|
|
16
|
+
new: true,
|
|
17
|
+
}).exec();
|
|
18
|
+
|
|
19
|
+
return updated;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const deleteSocialMediaSetting = async (id) => {
|
|
23
|
+
const deleted = await SocialMediaSetting.findByIdAndDelete(id).exec();
|
|
24
|
+
|
|
25
|
+
return deleted;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
module.exports = {
|
|
29
|
+
createSocialMediaSetting,
|
|
30
|
+
findSocialMediaSetting,
|
|
31
|
+
updateSocialMediaSetting,
|
|
32
|
+
deleteSocialMediaSetting,
|
|
33
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
const UserPermission = require("../../models/UserPermission");
|
|
2
|
+
|
|
3
|
+
const createUserPermission = async (data) => {
|
|
4
|
+
const newPermission = new UserPermission(data);
|
|
5
|
+
const savedPermission = await newPermission.save();
|
|
6
|
+
return savedPermission;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
const findUserPermission = async (filter) => {
|
|
10
|
+
return await UserPermission.findOne(filter).exec();
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const updateUserPermission = async (id, data) => {
|
|
14
|
+
const updatedPermission = await UserPermission.findByIdAndUpdate(id, data, {
|
|
15
|
+
new: true,
|
|
16
|
+
}).exec();
|
|
17
|
+
|
|
18
|
+
return updatedPermission;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const deleteUserPermission = async (id) => {
|
|
22
|
+
const deletedPermission = await UserPermission.findByIdAndDelete(id).exec();
|
|
23
|
+
return deletedPermission;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
module.exports = {
|
|
27
|
+
createUserPermission,
|
|
28
|
+
findUserPermission,
|
|
29
|
+
updateUserPermission,
|
|
30
|
+
deleteUserPermission,
|
|
31
|
+
};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
const UserRole = require("../../models/UserRole");
|
|
2
|
+
|
|
3
|
+
const createUserRole = async (data) => {
|
|
4
|
+
const newRole = new UserRole(data);
|
|
5
|
+
const savedRole = await newRole.save();
|
|
6
|
+
return savedRole;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
const findUserRole = async (filter = {}) => {
|
|
10
|
+
const members = await UserRole.find(filter)
|
|
11
|
+
.select("userId role userShift roleId")
|
|
12
|
+
.populate({
|
|
13
|
+
path: "roleId",
|
|
14
|
+
select: "id name userId userShift permissionId modulePermissions",
|
|
15
|
+
populate: [{ path: "permissionId", select: "id name" }],
|
|
16
|
+
})
|
|
17
|
+
.populate({
|
|
18
|
+
path: "userId",
|
|
19
|
+
match: { isDeleted: false, suspended: false },
|
|
20
|
+
select: "firstName lastName role email picture userShift",
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
return members;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
const updateUserRole = async (id, data) => {
|
|
27
|
+
const updatedRole = await UserRole.findByIdAndUpdate(id, data, {
|
|
28
|
+
new: true,
|
|
29
|
+
}).exec();
|
|
30
|
+
|
|
31
|
+
return updatedRole;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
const deleteUserRole = async (id) => {
|
|
35
|
+
const deletedRole = await UserRole.findByIdAndDelete(id).exec();
|
|
36
|
+
|
|
37
|
+
return deletedRole;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
module.exports = {
|
|
41
|
+
createUserRole,
|
|
42
|
+
findUserRole,
|
|
43
|
+
updateUserRole,
|
|
44
|
+
deleteUserRole,
|
|
45
|
+
};
|
package/config/redis.js
CHANGED
|
@@ -42,7 +42,6 @@ const publishToChannel = async (channel, message) => {
|
|
|
42
42
|
try {
|
|
43
43
|
await connectRedis();
|
|
44
44
|
await publisher.publish(channel, JSON.stringify(message));
|
|
45
|
-
console.log(`📢 Message published to channel: ${channel}`);
|
|
46
45
|
} catch (err) {
|
|
47
46
|
console.error("❌ Error publishing message:", err);
|
|
48
47
|
}
|
|
@@ -57,7 +56,6 @@ const subscribeToChannel = async (channel, callback, expiry = false) => {
|
|
|
57
56
|
try {
|
|
58
57
|
await connectRedis();
|
|
59
58
|
await subscriber.subscribe(channel, (message) => {
|
|
60
|
-
console.log(`📥 Message received on channel: ${channel}`);
|
|
61
59
|
if (expiry) callback(message);
|
|
62
60
|
else callback(JSON.parse(message));
|
|
63
61
|
});
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
const { model, Schema } = require("mongoose");
|
|
2
|
+
|
|
3
|
+
const NotificationSettingsSchema = new Schema(
|
|
4
|
+
{
|
|
5
|
+
workspaceId: {
|
|
6
|
+
type: Schema.Types.ObjectId,
|
|
7
|
+
ref: "Workspace",
|
|
8
|
+
default: null,
|
|
9
|
+
},
|
|
10
|
+
|
|
11
|
+
orders: {
|
|
12
|
+
type: {
|
|
13
|
+
createOrder: {
|
|
14
|
+
type: Boolean,
|
|
15
|
+
default: false,
|
|
16
|
+
},
|
|
17
|
+
orderAssign: {
|
|
18
|
+
type: Boolean,
|
|
19
|
+
default: false,
|
|
20
|
+
},
|
|
21
|
+
orderComment: {
|
|
22
|
+
type: Boolean,
|
|
23
|
+
default: false,
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
default: {
|
|
27
|
+
createOrder: false,
|
|
28
|
+
orderAssign: false,
|
|
29
|
+
orderComment: false,
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
|
|
33
|
+
products: {
|
|
34
|
+
type: Boolean,
|
|
35
|
+
default: false,
|
|
36
|
+
},
|
|
37
|
+
|
|
38
|
+
socialProfiles: {
|
|
39
|
+
type: {
|
|
40
|
+
socialProfileComment: {
|
|
41
|
+
type: Boolean,
|
|
42
|
+
default: false,
|
|
43
|
+
},
|
|
44
|
+
story: {
|
|
45
|
+
type: Boolean,
|
|
46
|
+
default: false,
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
default: {
|
|
50
|
+
socialProfileComment: false,
|
|
51
|
+
story: false,
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
|
|
55
|
+
conversation: {
|
|
56
|
+
type: {
|
|
57
|
+
instaMessage: {
|
|
58
|
+
type: Boolean,
|
|
59
|
+
default: false,
|
|
60
|
+
},
|
|
61
|
+
fbMessage: {
|
|
62
|
+
type: Boolean,
|
|
63
|
+
default: false,
|
|
64
|
+
},
|
|
65
|
+
whatsapp: {
|
|
66
|
+
type: Boolean,
|
|
67
|
+
default: false,
|
|
68
|
+
},
|
|
69
|
+
instaComment: {
|
|
70
|
+
type: Boolean,
|
|
71
|
+
default: false,
|
|
72
|
+
},
|
|
73
|
+
fbComment: {
|
|
74
|
+
type: Boolean,
|
|
75
|
+
default: false,
|
|
76
|
+
},
|
|
77
|
+
email: {
|
|
78
|
+
type: Boolean,
|
|
79
|
+
default: false,
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
default: {
|
|
83
|
+
instaMessage: false,
|
|
84
|
+
fbMessage: false,
|
|
85
|
+
instaComment: false,
|
|
86
|
+
fbComment: false,
|
|
87
|
+
email: false,
|
|
88
|
+
whatsapp: false,
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
|
|
92
|
+
taskManager: {
|
|
93
|
+
type: {
|
|
94
|
+
cardAssign: {
|
|
95
|
+
type: Boolean,
|
|
96
|
+
default: false,
|
|
97
|
+
},
|
|
98
|
+
cardMove: {
|
|
99
|
+
type: Boolean,
|
|
100
|
+
default: false,
|
|
101
|
+
},
|
|
102
|
+
},
|
|
103
|
+
default: {
|
|
104
|
+
cardAssign: false,
|
|
105
|
+
cardMove: false,
|
|
106
|
+
},
|
|
107
|
+
},
|
|
108
|
+
|
|
109
|
+
sound: {
|
|
110
|
+
type: {
|
|
111
|
+
play: {
|
|
112
|
+
type: Boolean,
|
|
113
|
+
default: true,
|
|
114
|
+
},
|
|
115
|
+
},
|
|
116
|
+
default: {
|
|
117
|
+
play: true,
|
|
118
|
+
},
|
|
119
|
+
},
|
|
120
|
+
|
|
121
|
+
default: {
|
|
122
|
+
type: Boolean,
|
|
123
|
+
default: true,
|
|
124
|
+
},
|
|
125
|
+
createdBy: { type: Schema.Types.ObjectId, ref: "User", default: null },
|
|
126
|
+
},
|
|
127
|
+
{ timestamps: true, toJSON: { virtuals: true }, toObject: { virtuals: true } }
|
|
128
|
+
);
|
|
129
|
+
|
|
130
|
+
module.exports = model("NotificationSettings", NotificationSettingsSchema);
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
const { model, Schema } = require("mongoose");
|
|
2
|
+
|
|
3
|
+
const SettingSchema = new Schema(
|
|
4
|
+
{
|
|
5
|
+
workspaceId: {
|
|
6
|
+
type: Schema.Types.ObjectId,
|
|
7
|
+
ref: "Workspace",
|
|
8
|
+
default: null,
|
|
9
|
+
},
|
|
10
|
+
settings: [{ module: { type: String, default: "" }, options: {} }],
|
|
11
|
+
createdBy: { type: Schema.Types.ObjectId, ref: "User", default: null },
|
|
12
|
+
updateBy: { type: Schema.Types.ObjectId, ref: "User", default: null },
|
|
13
|
+
isDeleted: { type: Boolean, default: false },
|
|
14
|
+
},
|
|
15
|
+
{ timestamps: true, toJSON: { virtuals: true }, toObject: { virtuals: true } }
|
|
16
|
+
);
|
|
17
|
+
|
|
18
|
+
module.exports = model("Setting", SettingSchema);
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
const { Schema, model } = require("mongoose");
|
|
2
|
+
const SocialMediaSettingSchema = new Schema(
|
|
3
|
+
{
|
|
4
|
+
workspaceId: {
|
|
5
|
+
type: Schema.Types.ObjectId,
|
|
6
|
+
ref: "Workspace",
|
|
7
|
+
default: null,
|
|
8
|
+
},
|
|
9
|
+
approvers: [
|
|
10
|
+
{
|
|
11
|
+
type: Schema.Types.ObjectId,
|
|
12
|
+
ref: "User",
|
|
13
|
+
default: null,
|
|
14
|
+
},
|
|
15
|
+
],
|
|
16
|
+
publishers: [
|
|
17
|
+
{
|
|
18
|
+
type: Schema.Types.ObjectId,
|
|
19
|
+
ref: "User",
|
|
20
|
+
default: null,
|
|
21
|
+
},
|
|
22
|
+
],
|
|
23
|
+
defaultApprove: { type: Boolean, default: true },
|
|
24
|
+
defaultPublish: { type: Boolean, default: true },
|
|
25
|
+
},
|
|
26
|
+
{ timestamps: true, toJSON: { virtuals: true }, toObject: { virtuals: true } }
|
|
27
|
+
);
|
|
28
|
+
module.exports = model("SocialMediaSetting", SocialMediaSettingSchema);
|