flykup_model_production 1.0.26 → 1.0.31

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.
@@ -41,6 +41,7 @@ const AdminSchema = new Schema(
41
41
  type: Boolean,
42
42
  default: false
43
43
  },
44
+
44
45
  twoFactorBackupCodes: [{
45
46
  type: String
46
47
  }],
@@ -52,6 +53,8 @@ const AdminSchema = new Schema(
52
53
  { timestamps: true }
53
54
  );
54
55
 
56
+
57
+
55
58
  // ✅ Fix: Use AdminSchema instead of Schema
56
59
  const Admin = mongoose.models.Admin || mongoose.model("Admin", AdminSchema);
57
60
 
@@ -265,7 +265,7 @@ const orderSchema = new mongoose.Schema(
265
265
  },
266
266
  deliveryCharge: {
267
267
  type: Number,
268
- default: 40
268
+ default: 0
269
269
  },
270
270
  statusTimeline: {
271
271
  ordered: Date,
@@ -86,7 +86,7 @@ const bundleSaleSchema = new Schema({
86
86
  return this.bundleSaleId != null;
87
87
  }
88
88
  },
89
- bundleTitle: { type: String }, // Quick reference title
89
+ bundleTitle: { type: String },
90
90
  bundleMRP: { type: Number, min: 0, default: null }, // Original MRP
91
91
  sellingPrice: { type: Number, min: 0, default: null }, // Actual selling price
92
92
  bundleImage: { // Bundle thumbnail image
@@ -177,6 +177,11 @@ const showSchema = new Schema(
177
177
  enum: ['created', 'live', 'cancelled', 'ended'],
178
178
  default: 'created'
179
179
  },
180
+ visibility: {
181
+ type: String,
182
+ enum: ['public', 'private'],
183
+
184
+ },
180
185
  viewerCount: {
181
186
  type: Number,
182
187
  default: 0,
@@ -208,6 +213,7 @@ const showSchema = new Schema(
208
213
  }
209
214
  },
210
215
  productPrice: { type: Number, min: 0, default: null },
216
+
211
217
  },
212
218
  ],
213
219
  default: [],
@@ -281,12 +287,14 @@ const showSchema = new Schema(
281
287
  { timestamps: true }
282
288
  );
283
289
 
284
- // ✅ ADD THIS PRE-SAVE MIDDLEWARE TO CLEAN INVALID DATA
290
+ // ✅ FIXED PRE-SAVE MIDDLEWARE - Only clean arrays when explicitly modified
285
291
  showSchema.pre('save', function(next) {
286
292
  const doc = this;
287
293
 
288
- // Clean up buyNowProducts - remove items without required fields
289
- if (doc.buyNowProducts && Array.isArray(doc.buyNowProducts)) {
294
+ // FIX: Only filter buyNowProducts if this field was explicitly modified
295
+ // This prevents data loss when saving unrelated fields (like liveBundleFlashSales)
296
+ if (doc.isModified('buyNowProducts') && doc.buyNowProducts && Array.isArray(doc.buyNowProducts)) {
297
+ console.log(`🧹 [Pre-Save] Cleaning buyNowProducts (was modified)`);
290
298
  doc.buyNowProducts = doc.buyNowProducts.filter(product =>
291
299
  product &&
292
300
  product.productId &&
@@ -294,8 +302,9 @@ showSchema.pre('save', function(next) {
294
302
  );
295
303
  }
296
304
 
297
- // Clean up auctionProducts
298
- if (doc.auctionProducts && Array.isArray(doc.auctionProducts)) {
305
+ // FIX: Only filter auctionProducts if this field was explicitly modified
306
+ if (doc.isModified('auctionProducts') && doc.auctionProducts && Array.isArray(doc.auctionProducts)) {
307
+ console.log(`🧹 [Pre-Save] Cleaning auctionProducts (was modified)`);
299
308
  doc.auctionProducts = doc.auctionProducts.filter(product =>
300
309
  product &&
301
310
  product.productId &&
@@ -304,8 +313,9 @@ showSchema.pre('save', function(next) {
304
313
  );
305
314
  }
306
315
 
307
- // Clean up giveawayProducts
308
- if (doc.giveawayProducts && Array.isArray(doc.giveawayProducts)) {
316
+ // FIX: Only filter giveawayProducts if this field was explicitly modified
317
+ if (doc.isModified('giveawayProducts') && doc.giveawayProducts && Array.isArray(doc.giveawayProducts)) {
318
+ console.log(`🧹 [Pre-Save] Cleaning giveawayProducts (was modified)`);
309
319
  doc.giveawayProducts = doc.giveawayProducts.filter(product =>
310
320
  product &&
311
321
  product.productId &&
@@ -591,6 +601,7 @@ export default Show;
591
601
  // if (!doc.hasCoHost) {
592
602
  // doc.coHost = null;
593
603
  // }
604
+
594
605
 
595
606
  // next();
596
607
  // });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "flykup_model_production",
3
- "version": "1.0.26",
3
+ "version": "1.0.31",
4
4
  "main": "index.js",
5
5
  "type": "module",
6
6
  "private": false,