flykup_model_development 3.1.2 → 3.1.4

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.
@@ -18,7 +18,8 @@ const notificationSchema = new mongoose.Schema(
18
18
  'new_video',
19
19
  "new_product",
20
20
  'admin_broadcast',
21
- 'seller_broadcast'
21
+ 'seller_broadcast',
22
+ 'live_stream_start'
22
23
  ],
23
24
  required: true,
24
25
  },
@@ -58,9 +58,6 @@
58
58
 
59
59
  // const OrderPayment = mongoose.model('orderPayment', paymentSchema);
60
60
  // export default OrderPayment;
61
-
62
- // models/OrderPayment.js
63
- // models/OrderPayment.js
64
61
  import mongoose from 'mongoose';
65
62
 
66
63
  const paymentSchema = new mongoose.Schema({
@@ -79,17 +76,35 @@ const paymentSchema = new mongoose.Schema({
79
76
  enum: ['RAZORPAY', 'CASHFREE'],
80
77
  required: true
81
78
  },
82
-
79
+
83
80
  // Razorpay-specific fields
84
- razorpayOrderId: String,
81
+ razorpayOrderId: {
82
+ type: String,
83
+ // ✅ This field is now required only if the gateway is RAZORPAY
84
+ required: function() {
85
+ return this.paymentGateway === 'RAZORPAY';
86
+ }
87
+ },
85
88
  razorpayPaymentId: {
86
89
  type: String,
87
90
  default: null
88
91
  },
89
-
92
+
90
93
  // Cashfree-specific fields
91
- cfPaymentSessionId: String,
92
- cfOrderId: String,
94
+ cfPaymentSessionId: {
95
+ type: String,
96
+ // ✅ This field is now required only if the gateway is CASHFREE
97
+ required: function() {
98
+ return this.paymentGateway === 'CASHFREE';
99
+ }
100
+ },
101
+ cfOrderId: {
102
+ type: String,
103
+ // ✅ This field is now required only if the gateway is CASHFREE
104
+ required: function() {
105
+ return this.paymentGateway === 'CASHFREE';
106
+ }
107
+ },
93
108
 
94
109
  amount: {
95
110
  type: Number,
@@ -119,7 +134,7 @@ const paymentSchema = new mongoose.Schema({
119
134
  default: 'PENDING'
120
135
  }
121
136
  }]
122
- }, {
137
+ }, {
123
138
  timestamps: true
124
139
  });
125
140
 
@@ -128,31 +143,9 @@ paymentSchema.index({ razorpayOrderId: 1 });
128
143
  paymentSchema.index({ cfOrderId: 1 });
129
144
  paymentSchema.index({ orderId: 1 });
130
145
 
131
- // Add a pre-save middleware to handle validation
132
- paymentSchema.pre('save', function(next) {
133
- // If using Razorpay, validate Razorpay fields
134
- if (this.paymentGateway === 'RAZORPAY') {
135
- if (!this.razorpayOrderId) {
136
- return next(new Error('razorpayOrderId is required for RAZORPAY payments'));
137
- }
138
- // Remove Cashfree fields
139
- this.cfPaymentSessionId = undefined;
140
- this.cfOrderId = undefined;
141
- }
142
- // If using Cashfree, validate Cashfree fields
143
- else if (this.paymentGateway === 'CASHFREE') {
144
- if (!this.cfPaymentSessionId || !this.cfOrderId) {
145
- return next(new Error('cfPaymentSessionId and cfOrderId are required for CASHFREE payments'));
146
- }
147
- // Remove Razorpay fields
148
- this.razorpayOrderId = undefined;
149
- this.razorpayPaymentId = undefined;
150
- }
151
- next();
152
- });
153
-
146
+ // The pre-save middleware is no longer needed and should be removed.
154
147
 
155
148
  const OrderPayment =
156
149
  mongoose.models.OrderPayment || mongoose.model('orderPayment', paymentSchema);
157
150
 
158
- export default OrderPayment;
151
+ export default OrderPayment;
@@ -11,7 +11,7 @@ const ProductListingSchema = new Schema(
11
11
  images: [
12
12
  {
13
13
  key: { type: String, maxLength: 255, default: null },
14
- },
14
+ }
15
15
  ],
16
16
  category: String,
17
17
  subcategory: String,
@@ -44,13 +44,11 @@ const ProductListingSchema = new Schema(
44
44
  countryOfOrigin: String,
45
45
  netQuantity: { type: String, default: null }, // ADDED (String to accommodate units like '500g')
46
46
  packagingType: { type: String, default: null }, // ADDED
47
- weight: {
48
- // For shipping calculations
47
+ weight: { // For shipping calculations
49
48
  value: { type: Number, default: null },
50
49
  unit: { type: String, default: null },
51
50
  },
52
- dimensions: {
53
- // For shipping calculations
51
+ dimensions: { // For shipping calculations
54
52
  length: { type: Number, default: null },
55
53
  width: { type: Number, default: null },
56
54
  height: { type: Number, default: null },
@@ -82,9 +80,9 @@ const ProductListingSchema = new Schema(
82
80
  },
83
81
  commissionRate: {
84
82
  type: Number,
85
- min: [0, "Commission rate cannot be negative."],
83
+ min: [0, 'Commission rate cannot be negative.'],
86
84
  // max: [100, 'Commission rate cannot exceed 100%.'], // Max was 25, changed to 100 based on frontend
87
- max: [100, "Commission rate cannot exceed 100%."],
85
+ max: [100, 'Commission rate cannot exceed 100%.'],
88
86
  default: null,
89
87
  // Removed Mongoose-level required validation dependent on allowDropshipping
90
88
  // Let application logic handle this if needed, or adjust validator
@@ -95,52 +93,37 @@ const ProductListingSchema = new Schema(
95
93
  // validate: { ... } // Keep or remove validation as needed
96
94
  },
97
95
  hasReturn: {
98
- type: Boolean,
99
- default: false,
100
- },
101
- returnDays: {
102
- type: Number,
103
- min: 0,
104
- default: null,
105
- },
106
- size: {
107
- type: String,
108
- default: null,
109
- },
96
+ type: Boolean,
97
+ default: false
98
+ },
99
+ returnDays: {
100
+ type: Number,
101
+ min: 0,
102
+ default: null
103
+ },
104
+ size: {
105
+ type: String,
106
+ default: null
107
+ },
110
108
  isActive: {
111
109
  type: Boolean,
112
110
  default: true,
113
- },
114
- ratingSummary: {
115
- averageRating: { type: Number, default: 0 },
116
- totalRatings: { type: Number, default: 0 },
117
- ratingDistribution: {
111
+ },ratingSummary: {
112
+ averageRating: { type: Number, default: 0 },
113
+ totalRatings: { type: Number, default: 0 },
114
+ ratingDistribution: {
118
115
  1: { type: Number, default: 0 },
119
116
  2: { type: Number, default: 0 },
120
117
  3: { type: Number, default: 0 },
121
118
  4: { type: Number, default: 0 },
122
- 5: { type: Number, default: 0 },
123
- },
124
- },
125
- flashSale: {
126
- isActive: { type: Boolean, default: false },
127
- flashSaleId: { type: mongoose.Schema.Types.ObjectId, ref: 'FlashSale' },
128
- flashPrice: { type: Number, default: null },
129
- flashStock: { type: Number, default: 0 },
130
- originalPrice: { type: Number, default: null },
131
- endsAt: { type: Date, default: null },
132
- startsAt: { type: Date, default: null }
133
- },
134
- totalReviews: { type: Number, default: 0 },
119
+ 5: { type: Number, default: 0 }
120
+ }
121
+ },
122
+ totalReviews: { type: Number, default: 0 }
135
123
  },
136
124
  { timestamps: true }
137
125
  );
138
126
 
139
- // Optional: Ensure strict mode is not preventing fields if you intended flexibility (default is true)
140
- // ProductListingSchema.set('strict', false); // Use with caution
141
-
142
127
  // Safe export to prevent OverwriteModelError
143
- const ProductListing =
144
- mongoose.models.productlistings ||
145
- mongoose.model("productlistings", ProductListingSchema);
128
+ const ProductListing = mongoose.models.productlistings || mongoose.model("productlistings", ProductListingSchema);
146
129
  export default ProductListing;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "flykup_model_development",
3
- "version": "3.1.2",
3
+ "version": "3.1.4",
4
4
  "main": "index.js",
5
5
  "type": "module",
6
6
  "private": false,