shuttlepro-shared 1.3.68 → 1.3.69
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/models/Chatbot.js +1 -0
- package/models/Product.js +6 -0
- package/models/User.js +10 -0
- package/models/Workspace.js +2 -0
- package/package.json +2 -1
- package/utils/services/embedding-api.service.js +50 -0
package/models/Chatbot.js
CHANGED
package/models/Product.js
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
const mongoose = require("mongoose");
|
|
2
2
|
const { Schema } = mongoose;
|
|
3
3
|
const axios = require("axios");
|
|
4
|
+
const {
|
|
5
|
+
updateEmbedding,
|
|
6
|
+
deleteEmbedding,
|
|
7
|
+
} = require("../utils/services/embedding-api.service");
|
|
4
8
|
const NewProduct = require("./NewProduct"); // Make sure to import NewProduct model
|
|
5
9
|
|
|
6
10
|
const categorySchema = new Schema({
|
|
@@ -165,6 +169,7 @@ const updateNewProduct = async (doc, next) => {
|
|
|
165
169
|
newProductData,
|
|
166
170
|
{ upsert: true, new: true }
|
|
167
171
|
);
|
|
172
|
+
await updateEmbedding(newProductData.id, newProductData.workspaceId);
|
|
168
173
|
}
|
|
169
174
|
} catch (error) {
|
|
170
175
|
console.error("Error updating NewProduct:", error);
|
|
@@ -177,6 +182,7 @@ const deleteNewProduct = async (doc, next) => {
|
|
|
177
182
|
try {
|
|
178
183
|
if (doc) {
|
|
179
184
|
await NewProduct.deleteOne({ id: doc._id });
|
|
185
|
+
await deleteEmbedding(doc._id);
|
|
180
186
|
}
|
|
181
187
|
} catch (error) {
|
|
182
188
|
console.error("Error deleting from NewProduct:", error);
|
package/models/User.js
CHANGED
|
@@ -31,6 +31,16 @@ const UserSchema = new Schema(
|
|
|
31
31
|
type: Schema.Types.ObjectId,
|
|
32
32
|
ref: "User",
|
|
33
33
|
},
|
|
34
|
+
deviceTokens: {
|
|
35
|
+
type: [
|
|
36
|
+
{
|
|
37
|
+
token: { type: String, required: true },
|
|
38
|
+
platform: { type: String, enum: ["ios", "android", "web"] },
|
|
39
|
+
lastUsedAt: { type: String },
|
|
40
|
+
},
|
|
41
|
+
],
|
|
42
|
+
default: [],
|
|
43
|
+
},
|
|
34
44
|
},
|
|
35
45
|
{ timestamps: true, toJSON: { virtuals: true }, toObject: { virtuals: true } }
|
|
36
46
|
);
|
package/models/Workspace.js
CHANGED
|
@@ -76,6 +76,7 @@ const ReasonSchema = new mongoose.Schema({
|
|
|
76
76
|
reason: { type: String, required: true },
|
|
77
77
|
color: { type: String, default: "#000000" },
|
|
78
78
|
categoryTitle: { type: String, required: true },
|
|
79
|
+
isDefault: { type: Boolean, default: false },
|
|
79
80
|
});
|
|
80
81
|
const ResolutionReasonCategorySchema = new mongoose.Schema({
|
|
81
82
|
_id: {
|
|
@@ -239,6 +240,7 @@ const workspaceSchema = new mongoose.Schema(
|
|
|
239
240
|
color: { type: String, default: "" },
|
|
240
241
|
},
|
|
241
242
|
],
|
|
243
|
+
sendReadReceipts: { type: Boolean, default: true },
|
|
242
244
|
chatGptApiKey: String,
|
|
243
245
|
skuSeparator: { type: String, default: "-" },
|
|
244
246
|
uniqueNo: { type: Number, default: 0 },
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "shuttlepro-shared",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.69",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
"@babel/plugin-proposal-decorators": "^7.22.5",
|
|
17
17
|
"@babel/preset-env": "^7.22.5",
|
|
18
18
|
"@babel/register": "^7.22.5",
|
|
19
|
+
"axios": "^0.21.1",
|
|
19
20
|
"bull": "^4.10.4",
|
|
20
21
|
"cors": "^2.8.5",
|
|
21
22
|
"express": "^4.17.1",
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
const axios = require("axios");
|
|
2
|
+
|
|
3
|
+
const axiosInstance = axios.create({
|
|
4
|
+
timeout: 5000, // 5 seconds
|
|
5
|
+
});
|
|
6
|
+
|
|
7
|
+
const EMBEDDING_SERVICE_URL = process.env.EMBEDDING_SERVER_URL;
|
|
8
|
+
|
|
9
|
+
const updateEmbedding = async (productId, workspaceId) => {
|
|
10
|
+
if (!EMBEDDING_SERVICE_URL) {
|
|
11
|
+
console.warn("⚠️ EMBEDDING_SERVICE_URL not set. Skipping update call.");
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
try {
|
|
16
|
+
await axiosInstance.post(
|
|
17
|
+
`${EMBEDDING_SERVICE_URL}/embedding/${workspaceId}/${productId}`
|
|
18
|
+
);
|
|
19
|
+
console.log(`✅ Updated embedding for productId: ${productId}`);
|
|
20
|
+
} catch (error) {
|
|
21
|
+
console.error(
|
|
22
|
+
`❌ Failed to update embedding for productId: ${productId}`,
|
|
23
|
+
error
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const deleteEmbedding = async (productId) => {
|
|
29
|
+
if (!EMBEDDING_SERVICE_URL) {
|
|
30
|
+
console.warn("⚠️ EMBEDDING_SERVICE_URL not set. Skipping delete call.");
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
try {
|
|
35
|
+
await axiosInstance.delete(
|
|
36
|
+
`${EMBEDDING_SERVICE_URL}/embedding/${productId}`
|
|
37
|
+
);
|
|
38
|
+
console.log(`✅ Deleted embedding for productId: ${productId}`);
|
|
39
|
+
} catch (error) {
|
|
40
|
+
console.error(
|
|
41
|
+
`❌ Failed to delete embedding for productId: ${productId}`,
|
|
42
|
+
error
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
module.exports = {
|
|
48
|
+
updateEmbedding,
|
|
49
|
+
deleteEmbedding,
|
|
50
|
+
};
|