flykup_model_development 3.1.54 → 3.1.55

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.
@@ -11,7 +11,7 @@ const ProductListingSchema = new Schema(
11
11
  isActive: { type: Boolean, default: false },
12
12
  flashSaleId: { type: mongoose.Schema.Types.ObjectId, ref: 'FlashSale' },
13
13
  flashPrice: { type: Number, default: 0 },
14
- flashStock: { type: Number, default: 0 }, // Dedicated flash sale quantity (separate from main inventory)
14
+ // REMOVED: flashStock field - now using main quantity
15
15
  originalPrice: { type: Number, default: 0 },
16
16
  endsAt: { type: Date, default: null },
17
17
  startsAt: { type: Date, default: null }
@@ -1,4 +1,4 @@
1
- // models/Stock.js - Simplified version without flash sale reservations
1
+ // models/Stock.js - Simplified
2
2
  import mongoose from "mongoose";
3
3
  const { Schema } = mongoose;
4
4
 
@@ -15,8 +15,12 @@ const stockSchema = new mongoose.Schema(
15
15
  default: 0,
16
16
  min: 0
17
17
  },
18
- // REMOVED: totalReserved field since we don't need reservations
19
- // REMOVED: flashSaleReservations array completely
18
+ title: String,
19
+ images: [{
20
+ key: String,
21
+ url: String
22
+ }],
23
+ // ❌ REMOVED: totalReserved, flashSaleReservations
20
24
  lowStockThreshold: {
21
25
  type: Number,
22
26
  default: 10
@@ -32,107 +36,66 @@ const stockSchema = new mongoose.Schema(
32
36
  lastRestocked: {
33
37
  type: Date,
34
38
  default: null
35
- }
39
+ },
40
+ stockUpdateHistory: [{
41
+ change: Number,
42
+ previousQuantity: Number,
43
+ newQuantity: Number,
44
+ reason: String,
45
+ updatedAt: { type: Date, default: Date.now }
46
+ }]
36
47
  },
37
48
  { timestamps: true }
38
49
  );
39
50
 
40
- // Indexes
41
- stockSchema.index({ productListingId: 1 });
42
- stockSchema.index({ isInStock: 1 });
43
- stockSchema.index({ quantity: 1 });
44
-
45
51
  const Stock = mongoose.models.stocks || mongoose.model("stocks", stockSchema);
46
52
  export default Stock;
47
53
 
48
54
 
49
-
50
- // // models/Stock.js
55
+ // // models/Stock.js - Simplified version without flash sale reservations
51
56
  // import mongoose from "mongoose";
52
57
  // const { Schema } = mongoose;
53
58
 
54
- // // Sub-schema for manual stock updates
55
- // const StockUpdateHistorySchema = new Schema({
56
- // change: { type: Number, required: true }, // e.g., +50 or -10
57
- // previousQuantity: { type: Number, required: true },
58
- // newQuantity: { type: Number, required: true },
59
- // reason: { type: String, default: "Manual update by seller" },
60
- // updatedAt: { type: Date, default: Date.now }
61
- // });
62
-
63
-
64
- // const StockSchema = new Schema(
59
+ // const stockSchema = new mongoose.Schema(
65
60
  // {
66
- // sellerId: {
67
- // type: Schema.Types.ObjectId,
68
- // ref: "sellers",
69
- // },
70
61
  // productListingId: {
71
62
  // type: Schema.Types.ObjectId,
72
63
  // ref: "productlistings",
64
+ // required: true,
65
+ // unique: true
73
66
  // },
74
- // title: String,
75
- // images: [{
76
- // key: String,
77
- // url: String
78
- // }],
79
67
  // quantity: {
80
68
  // type: Number,
81
- // min: 0,
82
69
  // default: 0,
70
+ // min: 0
83
71
  // },
84
- // // History for manual stock adjustments
85
- // stockUpdateHistory: [StockUpdateHistorySchema],
86
-
87
- // // Track reservations for flash sales
88
- // flashSaleReservations: [{
89
- // flashSaleId: {
90
- // type: Schema.Types.ObjectId,
91
- // ref: "FlashSale",
92
- // required: true
93
- // },
94
- // quantity: { type: Number, min: 0, default: 0 },
95
- // status: {
96
- // type: String,
97
- // enum: ['reserved', 'active', 'released', 'sold', 'partially_sold'],
98
- // default: 'reserved'
99
- // },
100
- // source: {
101
- // type: String,
102
- // enum: ['normal', 'live_stream'],
103
- // default: 'normal'
104
- // },
105
- // reservedAt: { type: Date, default: Date.now },
106
- // releasedAt: Date,
107
- // soldQuantity: { type: Number, default: 0 }
108
- // }],
109
- // totalReserved: {
72
+ // // REMOVED: totalReserved field since we don't need reservations
73
+ // // REMOVED: flashSaleReservations array completely
74
+ // lowStockThreshold: {
75
+ // type: Number,
76
+ // default: 10
77
+ // },
78
+ // reorderQuantity: {
110
79
  // type: Number,
111
- // min: 0,
112
- // default: 0
80
+ // default: 50
81
+ // },
82
+ // isInStock: {
83
+ // type: Boolean,
84
+ // default: true
85
+ // },
86
+ // lastRestocked: {
87
+ // type: Date,
88
+ // default: null
113
89
  // }
114
90
  // },
115
91
  // { timestamps: true }
116
92
  // );
117
93
 
118
- // // Pre-save hook to calculate totalReserved
119
- // StockSchema.pre('save', function(next) {
120
- // if (this.isModified('flashSaleReservations')) {
121
- // this.totalReserved = this.flashSaleReservations.reduce((total, reservation) => {
122
- // return total + (['reserved', 'active'].includes(reservation.status) ? reservation.quantity : 0);
123
- // }, 0);
124
- // }
125
- // next();
126
- // });
127
-
128
- // // Virtual for available quantity
129
- // StockSchema.virtual('availableQuantity').get(function() {
130
- // return Math.max(0, this.quantity - this.totalReserved);
131
- // });
94
+ // // Indexes
95
+ // stockSchema.index({ productListingId: 1 });
96
+ // stockSchema.index({ isInStock: 1 });
97
+ // stockSchema.index({ quantity: 1 });
132
98
 
133
- // // Ensure virtuals are included in JSON output
134
- // StockSchema.set('toJSON', { virtuals: true });
135
- // StockSchema.set('toObject', { virtuals: true });
99
+ // const Stock = mongoose.models.stocks || mongoose.model("stocks", stockSchema);
100
+ // export default Stock;
136
101
 
137
- // const Stock = mongoose.models.stocks || mongoose.model("stocks", StockSchema);
138
- // export default Stock;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "flykup_model_development",
3
- "version": "3.1.54",
3
+ "version": "3.1.55",
4
4
  "main": "index.js",
5
5
  "type": "module",
6
6
  "private": false,