shuttlepro-shared 1.2.9 → 1.2.11
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.
|
@@ -68,7 +68,11 @@ const findIntegrationsByWorkspace = async (workspaceId, filter = {}) => {
|
|
|
68
68
|
/**
|
|
69
69
|
* Find integration by filter (supports both workspace & non-workspace).
|
|
70
70
|
*/
|
|
71
|
-
const findIntegrationByFilter = async (
|
|
71
|
+
const findIntegrationByFilter = async (
|
|
72
|
+
filter,
|
|
73
|
+
bodyFilter = {},
|
|
74
|
+
workspaceId = null
|
|
75
|
+
) => {
|
|
72
76
|
const allIntegrations = await getCachedAllIntegrations();
|
|
73
77
|
|
|
74
78
|
let filteredIntegrations = allIntegrations;
|
|
@@ -79,8 +83,12 @@ const findIntegrationByFilter = async (filter, workspaceId = null) => {
|
|
|
79
83
|
}
|
|
80
84
|
|
|
81
85
|
return (
|
|
82
|
-
filteredIntegrations.find(
|
|
83
|
-
|
|
86
|
+
filteredIntegrations.find(
|
|
87
|
+
(item) =>
|
|
88
|
+
Object.entries(filter).every(([key, value]) => item[key] === value) &&
|
|
89
|
+
Object.entries(bodyFilter).every(
|
|
90
|
+
([key, value]) => item.body?.[key] === value
|
|
91
|
+
)
|
|
84
92
|
) || null
|
|
85
93
|
);
|
|
86
94
|
};
|
|
@@ -1,90 +1,3 @@
|
|
|
1
|
-
// const { getRedisData, setRedisData } = require("../../config/redis");
|
|
2
|
-
// const Label = require("../../models/Label");
|
|
3
|
-
|
|
4
|
-
// const CACHE_KEY_ALL = "labels_all";
|
|
5
|
-
|
|
6
|
-
// const getCachedLabels = async () => {
|
|
7
|
-
// let labels = await getRedisData(CACHE_KEY_ALL);
|
|
8
|
-
// if (!labels) {
|
|
9
|
-
// labels = await Label.find().lean().exec();
|
|
10
|
-
// await setRedisData(CACHE_KEY_ALL, JSON.stringify(labels));
|
|
11
|
-
// } else {
|
|
12
|
-
// labels = JSON.parse(labels);
|
|
13
|
-
// }
|
|
14
|
-
// return labels;
|
|
15
|
-
// };
|
|
16
|
-
|
|
17
|
-
// const updateCachedLabels = async () => {
|
|
18
|
-
// const labels = await Label.find().lean().exec();
|
|
19
|
-
// await setRedisData(CACHE_KEY_ALL, JSON.stringify(labels));
|
|
20
|
-
// };
|
|
21
|
-
|
|
22
|
-
// const createLabel = async (data) => {
|
|
23
|
-
// const newLabel = new Label(data);
|
|
24
|
-
// const savedLabel = await newLabel.save();
|
|
25
|
-
// await updateCachedLabels();
|
|
26
|
-
// return savedLabel;
|
|
27
|
-
// };
|
|
28
|
-
|
|
29
|
-
// const findLabelById = async (id) => {
|
|
30
|
-
// const labels = await getCachedLabels();
|
|
31
|
-
// return labels.find((l) => l._id.toString() === id) || null;
|
|
32
|
-
// };
|
|
33
|
-
|
|
34
|
-
// const findLabel = async (filter) => {
|
|
35
|
-
// const labels = await getCachedLabels();
|
|
36
|
-
// return (
|
|
37
|
-
// labels.find((l) =>
|
|
38
|
-
// Object.entries(filter).every(([key, value]) => l[key] === value)
|
|
39
|
-
// ) || null
|
|
40
|
-
// );
|
|
41
|
-
// };
|
|
42
|
-
|
|
43
|
-
// const findAllLabels = async (filter = {}) => {
|
|
44
|
-
// const labels = await getCachedLabels();
|
|
45
|
-
// return labels.filter((l) =>
|
|
46
|
-
// Object.entries(filter).every(([key, value]) => l[key] === value)
|
|
47
|
-
// );
|
|
48
|
-
// };
|
|
49
|
-
|
|
50
|
-
// const updateLabelById = async (id, data) => {
|
|
51
|
-
// const updatedLabel = await Label.findByIdAndUpdate(id, data, {
|
|
52
|
-
// new: true,
|
|
53
|
-
// }).exec();
|
|
54
|
-
// if (updatedLabel) {
|
|
55
|
-
// await updateCachedLabels();
|
|
56
|
-
// }
|
|
57
|
-
// return updatedLabel;
|
|
58
|
-
// };
|
|
59
|
-
// const updateLabel = async (filter, data) => {
|
|
60
|
-
// const updatedLabel = await Label.findOneAndUpdate(filter, data, {
|
|
61
|
-
// new: true,
|
|
62
|
-
// }).exec();
|
|
63
|
-
// if (updatedLabel) {
|
|
64
|
-
// await updateCachedLabels();
|
|
65
|
-
// }
|
|
66
|
-
// return updatedLabel;
|
|
67
|
-
// };
|
|
68
|
-
|
|
69
|
-
// const deleteLabel = async (id) => {
|
|
70
|
-
// const deletedLabel = await Label.findByIdAndDelete(id).exec();
|
|
71
|
-
// if (deletedLabel) {
|
|
72
|
-
// await updateCachedLabels();
|
|
73
|
-
// }
|
|
74
|
-
// return deletedLabel;
|
|
75
|
-
// };
|
|
76
|
-
|
|
77
|
-
// module.exports = {
|
|
78
|
-
// createLabel,
|
|
79
|
-
// findLabelById,
|
|
80
|
-
// findLabel,
|
|
81
|
-
// findAllLabels,
|
|
82
|
-
// updateLabel,
|
|
83
|
-
// deleteLabel,
|
|
84
|
-
// updateLabelById,
|
|
85
|
-
// };
|
|
86
|
-
|
|
87
|
-
const R = require("ramda");
|
|
88
1
|
const Label = require("../../models/Label");
|
|
89
2
|
const {
|
|
90
3
|
setRedisData,
|
|
@@ -143,6 +56,16 @@ const findAllLabels = async (query = {}) => {
|
|
|
143
56
|
return await withCache(JSON.stringify(query), () => Label.find(query).exec());
|
|
144
57
|
};
|
|
145
58
|
|
|
59
|
+
const findLabelById = async (labelId) => {
|
|
60
|
+
return await withCache(CACHE_KEYS.LABEL_DETAILS(labelId), () =>
|
|
61
|
+
Label.findById(labelId).exec()
|
|
62
|
+
);
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
const findLabel = async (query = {}) => {
|
|
66
|
+
return await Label.findOne(query).exec();
|
|
67
|
+
};
|
|
68
|
+
|
|
146
69
|
const updateLabel = async (labelId, updateData) => {
|
|
147
70
|
const updatedLabel = await Label.findByIdAndUpdate(labelId, updateData, {
|
|
148
71
|
new: true,
|
|
@@ -165,7 +88,8 @@ module.exports = {
|
|
|
165
88
|
createLabel,
|
|
166
89
|
findLabels,
|
|
167
90
|
findAllLabels,
|
|
91
|
+
findLabelById,
|
|
92
|
+
findLabel,
|
|
168
93
|
updateLabel,
|
|
169
94
|
deleteLabel,
|
|
170
95
|
};
|
|
171
|
-
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
const { Schema, model } = require("mongoose");
|
|
2
|
+
|
|
3
|
+
const ChatMemberSchema = new Schema(
|
|
4
|
+
{
|
|
5
|
+
userName: { type: String, default: "" },
|
|
6
|
+
phoneNo: { type: String, default: "" },
|
|
7
|
+
email: { type: String, default: "" },
|
|
8
|
+
workspaceId: {
|
|
9
|
+
type: Schema.Types.ObjectId,
|
|
10
|
+
ref: "Workspace",
|
|
11
|
+
default: null,
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
{ timestamps: true, toJSON: { virtuals: true }, toObject: { virtuals: true } }
|
|
15
|
+
);
|
|
16
|
+
|
|
17
|
+
module.exports = model("ChatMember", ChatMemberSchema);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "shuttlepro-shared",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.11",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -22,7 +22,6 @@
|
|
|
22
22
|
"helmet": "^8.0.0",
|
|
23
23
|
"jsonwebtoken": "^9.0.2",
|
|
24
24
|
"mongoose": "^8.7.1",
|
|
25
|
-
"ramda": "^0.30.1",
|
|
26
25
|
"redis": "^4.6.14",
|
|
27
26
|
"socket.io": "^4.8.1"
|
|
28
27
|
}
|