database-connector 2.3.3 → 2.3.5

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.
@@ -56,7 +56,37 @@ const mongoose = require('mongoose');
56
56
  * description: Products in this flash deal
57
57
  * discountCode:
58
58
  * type: string
59
- * description: Discount code
59
+ * description: Discount code (main code or template)
60
+ * codeType:
61
+ * type: string
62
+ * enum: [unique, specific]
63
+ * default: unique
64
+ * description: Code type - unique (single code for all) or specific (individual codes per user)
65
+ * campaignObjective:
66
+ * type: string
67
+ * enum: [followers, specific, all]
68
+ * default: followers
69
+ * description: Campaign objective - target followers, specific users, or all users
70
+ * campaignPurpose:
71
+ * type: string
72
+ * enum: [increase_revenue, attract_new_clients]
73
+ * description: Campaign purpose (only when campaignObjective is 'all')
74
+ * targetUserIds:
75
+ * type: array
76
+ * items:
77
+ * type: object
78
+ * properties:
79
+ * userId:
80
+ * type: string
81
+ * description: Reference to target user
82
+ * used:
83
+ * type: boolean
84
+ * default: false
85
+ * description: Whether the user has used the code
86
+ * code:
87
+ * type: string
88
+ * description: Individual promo code (null for unique code type)
89
+ * description: Array of targeted users with their specific codes and usage status
60
90
  * qauntiyFlashDeal:
61
91
  * type: number
62
92
  * default: 0
@@ -65,6 +95,11 @@ const mongoose = require('mongoose');
65
95
  * type: boolean
66
96
  * default: true
67
97
  * description: Whether the flash deal is active
98
+ * history:
99
+ * type: array
100
+ * items:
101
+ * type: object
102
+ * description: History of flash deal updates
68
103
  * createdAt:
69
104
  * type: string
70
105
  * format: date-time
@@ -139,8 +174,42 @@ const FlashDealSchema = new mongoose.Schema(
139
174
  ],
140
175
  discountCode: {
141
176
  type: String,
177
+ required: false,
178
+ },
179
+ codeType: {
180
+ type: String,
181
+ enum: ['unique', 'specific'],
182
+ default: 'unique',
183
+ required: true,
184
+ },
185
+ campaignObjective: {
186
+ type: String,
187
+ enum: ['followers', 'specific', 'all'],
188
+ default: 'followers',
142
189
  required: true,
143
190
  },
191
+ campaignPurpose: {
192
+ type: String,
193
+ enum: ['increase_revenue', 'attract_new_clients'],
194
+ default: null,
195
+ },
196
+ targetUserIds: [
197
+ {
198
+ userId: {
199
+ type: mongoose.Schema.Types.ObjectId,
200
+ ref: 'User',
201
+ required: true,
202
+ },
203
+ used: {
204
+ type: Boolean,
205
+ default: false,
206
+ },
207
+ code: {
208
+ type: String,
209
+ default: null,
210
+ },
211
+ },
212
+ ],
144
213
  qauntiyFlashDeal: {
145
214
  type: Number,
146
215
  required: true,
@@ -150,7 +219,16 @@ const FlashDealSchema = new mongoose.Schema(
150
219
  type: Boolean,
151
220
  required: true,
152
221
  default: true
153
- }
222
+ },
223
+ history: [
224
+ {
225
+ type: mongoose.Schema.Types.Mixed,
226
+ timestamp: {
227
+ type: Date,
228
+ default: Date.now,
229
+ },
230
+ },
231
+ ]
154
232
  },
155
233
  {
156
234
  timestamps: true
package/models/Offer.js CHANGED
@@ -63,6 +63,10 @@ const mongoose = require('mongoose');
63
63
  * enum: [followers, all, specific]
64
64
  * default: all
65
65
  * description: Who can see this offer
66
+ * campaignPurpose:
67
+ * type: string
68
+ * enum: [increase_revenue, attract_new_clients]
69
+ * description: Campaign purpose (only when type is 'all')
66
70
  * userIds:
67
71
  * type: array
68
72
  * items:
@@ -72,6 +76,11 @@ const mongoose = require('mongoose');
72
76
  * type: boolean
73
77
  * default: false
74
78
  * description: Whether to add this offer to the slider
79
+ * history:
80
+ * type: array
81
+ * items:
82
+ * type: object
83
+ * description: History of offer updates
75
84
  * createdAt:
76
85
  * type: string
77
86
  * format: date-time
@@ -151,9 +160,14 @@ const OfferSchema = new mongoose.Schema(
151
160
  },
152
161
  type: {
153
162
  type: String,
154
- default: 'all',
163
+ default: 'followers',
155
164
  enum: ['followers', 'all', 'specific'],
156
165
  },
166
+ campaignPurpose: {
167
+ type: String,
168
+ enum: ['increase_revenue', 'attract_new_clients'],
169
+ default: null,
170
+ },
157
171
  userIds: {
158
172
  type: [mongoose.Schema.Types.ObjectId],
159
173
  ref: 'User',
@@ -163,6 +177,15 @@ const OfferSchema = new mongoose.Schema(
163
177
  type: Boolean,
164
178
  default: false,
165
179
  },
180
+ history: [
181
+ {
182
+ type: mongoose.Schema.Types.Mixed,
183
+ timestamp: {
184
+ type: Date,
185
+ default: Date.now,
186
+ },
187
+ },
188
+ ],
166
189
  },
167
190
  {
168
191
  timestamps: true,
@@ -0,0 +1,41 @@
1
+ const mongoose = require('mongoose');
2
+
3
+ /**
4
+ * @swagger
5
+ * components:
6
+ * schemas:
7
+ * Settings:
8
+ * type: object
9
+ * properties:
10
+ * id:
11
+ * type: string
12
+ * description: The settings identifier
13
+ * max_pollution_threshold:
14
+ * type: number
15
+ * default: 20
16
+ * description: Maximum pollution threshold for notification system (notifications per day)
17
+ * createdAt:
18
+ * type: string
19
+ * format: date-time
20
+ * updatedAt:
21
+ * type: string
22
+ * format: date-time
23
+ * example:
24
+ * id: "507f1f77bcf86cd799439011"
25
+ * max_pollution_threshold: 20
26
+ * createdAt: "2025-11-01T10:30:00.000Z"
27
+ * updatedAt: "2025-12-01T15:45:00.000Z"
28
+ */
29
+ const SettingsSchema = new mongoose.Schema(
30
+ {
31
+ max_pollution_threshold: {
32
+ type: Number,
33
+ default: 20,
34
+ },
35
+ },
36
+ {
37
+ timestamps: true,
38
+ }
39
+ );
40
+
41
+ module.exports = mongoose.model('Settings', SettingsSchema);
package/models/User.js CHANGED
@@ -109,6 +109,29 @@ const { policySchema } = require('database-connector/models/Policy');
109
109
  * items:
110
110
  * type: string
111
111
  * description: Subscribed stores
112
+ * notification:
113
+ * type: object
114
+ * properties:
115
+ * orderNotifications:
116
+ * type: boolean
117
+ * offerNotification:
118
+ * type: boolean
119
+ * mail:
120
+ * type: boolean
121
+ * sms:
122
+ * type: boolean
123
+ * platforme:
124
+ * type: boolean
125
+ * popup:
126
+ * type: boolean
127
+ * vibration:
128
+ * type: boolean
129
+ * ringing:
130
+ * type: boolean
131
+ * maxNotif:
132
+ * type: number
133
+ * default: null
134
+ * description: Maximum number of notifications per day (null = unlimited)
112
135
  * createdAt:
113
136
  * type: string
114
137
  * format: date-time
@@ -261,6 +284,7 @@ const userSchema = new mongoose.Schema(
261
284
  popup: { type: Boolean, default: null },
262
285
  vibration: { type: Boolean, default: null },
263
286
  ringing: { type: Boolean, default: null },
287
+ maxNotif: { type: Number, default: null },
264
288
  },
265
289
 
266
290
  pickupPersons: [
package/models/index.js CHANGED
@@ -62,6 +62,7 @@ const Sale = require('./Sale');
62
62
  const StoreCategory = require('./StoreCategory');
63
63
  const UserAction = require('./UserAction.js');
64
64
  const Advertisement = require('./Advertisement');
65
+ const Settings = require('./Settings');
65
66
 
66
67
 
67
68
  module.exports = {
@@ -95,5 +96,6 @@ module.exports = {
95
96
  SubscriptionOffer,
96
97
  UserAction,
97
98
  Advertisement,
99
+ Settings,
98
100
  ObjectId: mongoose.Types.ObjectId,
99
101
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "database-connector",
3
- "version": "2.3.3",
3
+ "version": "2.3.5",
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": {