shuttlepro-shared 1.2.18 → 1.2.19

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.
@@ -0,0 +1,71 @@
1
+ const mongoose = require("mongoose");
2
+ const { Schema } = mongoose;
3
+
4
+ const NewProductSchema = new Schema(
5
+ {
6
+ id: {
7
+ type: Schema.Types.ObjectId,
8
+ ref: "Product",
9
+ default: null,
10
+ },
11
+ name: { type: String, default: "" },
12
+ description: { type: String, default: "" },
13
+ sku: { type: String, default: "" },
14
+ price: { type: String, default: 0 },
15
+ quantity: { type: Number, default: 0 },
16
+ imageUrl: { type: String, default: "" },
17
+ costPrice: { type: String, default: 0 },
18
+ salePrice: { type: String, default: 0 },
19
+ webProductId: { type: Number, default: null },
20
+ variants: [],
21
+ attachments: [],
22
+ workspaceId: {
23
+ type: Schema.Types.ObjectId,
24
+ ref: "Workspace",
25
+ default: null,
26
+ },
27
+ },
28
+ {
29
+ timestamps: true,
30
+ toJSON: { virtuals: true },
31
+ toObject: { virtuals: true },
32
+ }
33
+ );
34
+
35
+ // Adding compound text index for name, sku, and variants
36
+ NewProductSchema.index({
37
+ name: "text",
38
+ sku: "text",
39
+ "variants.name": "text",
40
+ "variants.sku": "text",
41
+ });
42
+
43
+ // Adding separate indexes for frequent query conditions
44
+ NewProductSchema.index({
45
+ workspaceId: 1,
46
+ name: 1,
47
+ });
48
+
49
+ NewProductSchema.index({
50
+ workspaceId: 1,
51
+ sku: 1,
52
+ });
53
+
54
+ NewProductSchema.index({
55
+ workspaceId: 1,
56
+ "variants.name": 1,
57
+ });
58
+
59
+ NewProductSchema.index({
60
+ workspaceId: 1,
61
+ "variants.sku": 1,
62
+ });
63
+
64
+ // Index for attachments existence check
65
+ NewProductSchema.index({
66
+ attachments: 1,
67
+ });
68
+
69
+ const NewProduct = mongoose.model("NewProduct", NewProductSchema);
70
+
71
+ module.exports = NewProduct;
package/models.js CHANGED
@@ -38,7 +38,7 @@ const Profile = require("./models/Profile");
38
38
  const Chatbot = require("./models/Chatbot");
39
39
  const Step = require("./models/Step");
40
40
  const Role = require("./models/Role");
41
-
41
+ const NewProduct = require("./models/NewProduct");
42
42
  module.exports = {
43
43
  Website,
44
44
  ProductQueue,
@@ -80,4 +80,5 @@ module.exports = {
80
80
  Chatbot,
81
81
  Step,
82
82
  Role,
83
+ NewProduct,
83
84
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shuttlepro-shared",
3
- "version": "1.2.18",
3
+ "version": "1.2.19",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {