database-connector 2.4.14 → 2.4.16

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/Plan.js CHANGED
@@ -23,10 +23,18 @@ const mongoose = require('mongoose');
23
23
  * price:
24
24
  * type: number
25
25
  * description: Plan price for one store
26
- * additionalStoreReductionPercentage:
27
- * type: number
28
- * description: Percentage of reduction on each new store added to the subscription
29
- * default: 0
26
+ * storeReductionRules:
27
+ * type: array
28
+ * items:
29
+ * type: object
30
+ * properties:
31
+ * storeNumber:
32
+ * type: number
33
+ * description: The store position number (2 for second store, 3 for third, etc.)
34
+ * reductionPercentage:
35
+ * type: number
36
+ * description: Percentage of reduction for this store number
37
+ * description: Array of reduction rules for each additional store. First store uses full plan price.
30
38
  * reductionOffers:
31
39
  * type: array
32
40
  * items:
@@ -42,7 +50,13 @@ const mongoose = require('mongoose');
42
50
  * type: "Annual"
43
51
  * months: 12
44
52
  * price: 99.99
45
- * additionalStoreReductionPercentage: 10
53
+ * storeReductionRules:
54
+ * - storeNumber: 2
55
+ * reductionPercentage: 10
56
+ * - storeNumber: 3
57
+ * reductionPercentage: 15
58
+ * - storeNumber: 4
59
+ * reductionPercentage: 20
46
60
  * status: "active"
47
61
  */
48
62
  const planSchema = new mongoose.Schema(
@@ -51,13 +65,6 @@ const planSchema = new mongoose.Schema(
51
65
  type: String,
52
66
  required: true,
53
67
  unique: false,
54
- validate: {
55
- validator: function (value) {
56
- const predefinedTypes = ['Annual', 'Semi-annual', 'Quarterly', 'Monthly'];
57
- return predefinedTypes.includes(value) || /^[a-zA-Z\s]+$/.test(value);
58
- },
59
- message: props => `${props.value} is not a valid plan type!`
60
- }
61
68
  },
62
69
  months: {
63
70
  type: Number,
@@ -68,12 +75,21 @@ const planSchema = new mongoose.Schema(
68
75
  type: Number,
69
76
  required: true,
70
77
  },
71
- additionalStoreReductionPercentage: {
72
- type: Number,
73
- default: 0,
74
- min: 0,
75
- max: 100,
76
- },
78
+ storeReductionRules: [
79
+ {
80
+ storeNumber: {
81
+ type: Number,
82
+ required: true,
83
+ min: 2,
84
+ },
85
+ reductionPercentage: {
86
+ type: Number,
87
+ required: true,
88
+ min: 0,
89
+ max: 100,
90
+ },
91
+ }
92
+ ],
77
93
  reductionOffers: [
78
94
  {
79
95
  type: mongoose.Schema.Types.ObjectId,
@@ -18,6 +18,10 @@ const mongoose = require('mongoose');
18
18
  * type: number
19
19
  * default: 15
20
20
  * description: Maximum number of targeted users for system operations
21
+ * max_stores_in_plan:
22
+ * type: number
23
+ * default: 10
24
+ * description: Maximum number of stores allowed in a plan
21
25
  * createdAt:
22
26
  * type: string
23
27
  * format: date-time
@@ -28,6 +32,7 @@ const mongoose = require('mongoose');
28
32
  * id: "507f1f77bcf86cd799439011"
29
33
  * max_pollution_threshold: 20
30
34
  * max_targeted_users: 15
35
+ * max_stores_in_plan: 10
31
36
  * createdAt: "2025-11-01T10:30:00.000Z"
32
37
  * updatedAt: "2025-12-01T15:45:00.000Z"
33
38
  */
@@ -41,6 +46,10 @@ const SettingsSchema = new mongoose.Schema(
41
46
  type: Number,
42
47
  default: 15,
43
48
  },
49
+ max_stores_in_plan: {
50
+ type: Number,
51
+ default: 10,
52
+ },
44
53
  },
45
54
  {
46
55
  timestamps: true,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "database-connector",
3
- "version": "2.4.14",
3
+ "version": "2.4.16",
4
4
  "description": "MongoDB models package with Mongoose schemas for e-commerce applications. Includes User, Product, Store, Order and more with built-in validation and virtual properties.",
5
5
  "main": "models/index.js",
6
6
  "scripts": {