database-connector 1.0.7 → 2.0.0

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.
@@ -1,5 +1,78 @@
1
1
 
2
2
  const mongoose = require('mongoose');
3
+
4
+ /**
5
+ * @swagger
6
+ * components:
7
+ * schemas:
8
+ * FlashDeal:
9
+ * type: object
10
+ * required:
11
+ * - name
12
+ * - description
13
+ * - discountCode
14
+ * properties:
15
+ * id:
16
+ * type: string
17
+ * description: The flash deal identifier
18
+ * name:
19
+ * type: string
20
+ * description: Flash deal name
21
+ * description:
22
+ * type: string
23
+ * description: Flash deal description
24
+ * image:
25
+ * type: string
26
+ * description: Flash deal image
27
+ * startDate:
28
+ * type: string
29
+ * format: date-time
30
+ * description: Start date of the flash deal
31
+ * endDate:
32
+ * type: string
33
+ * format: date-time
34
+ * description: End date of the flash deal
35
+ * discountType:
36
+ * type: string
37
+ * enum: [percentage, amount]
38
+ * default: percentage
39
+ * discount:
40
+ * type: number
41
+ * default: 0
42
+ * description: Discount value
43
+ * productIds:
44
+ * type: array
45
+ * items:
46
+ * type: string
47
+ * description: Products in this flash deal
48
+ * discountCode:
49
+ * type: string
50
+ * description: Discount code
51
+ * qauntiyFlashDeal:
52
+ * type: number
53
+ * default: 0
54
+ * description: Quantity available for flash deal
55
+ * active:
56
+ * type: boolean
57
+ * default: true
58
+ * description: Whether the flash deal is active
59
+ * createdAt:
60
+ * type: string
61
+ * format: date-time
62
+ * updatedAt:
63
+ * type: string
64
+ * format: date-time
65
+ * example:
66
+ * id: "507f1f77bcf86cd799439011"
67
+ * name: "Black Friday Sale"
68
+ * description: "Huge discounts on electronics"
69
+ * discountType: "percentage"
70
+ * discount: 50
71
+ * discountCode: "BF2025"
72
+ * active: true
73
+ * createdAt: "2025-11-01T10:30:00.000Z"
74
+ * updatedAt: "2025-12-01T15:45:00.000Z"
75
+ */
3
76
  const FlashDealSchema = new mongoose.Schema(
4
77
  {
5
78
  name: {
@@ -52,11 +125,11 @@ const FlashDealSchema = new mongoose.Schema(
52
125
  active: {
53
126
  type: Boolean,
54
127
  required: true,
55
- default: true,
56
- },
128
+ default: true
129
+ }
57
130
  },
58
131
  {
59
- timestamps: true,
132
+ timestamps: true
60
133
  }
61
134
  );
62
135
 
@@ -1,6 +1,65 @@
1
- const { Timestamp } = require('mongodb');
2
1
  const mongoose = require('mongoose');
3
2
 
3
+ /**
4
+ * @swagger
5
+ * components:
6
+ * schemas:
7
+ * Notification:
8
+ * type: object
9
+ * required:
10
+ * - owner_id
11
+ * - title
12
+ * - content
13
+ * - id
14
+ * - type
15
+ * - sub_type
16
+ * properties:
17
+ * id:
18
+ * type: string
19
+ * description: The notification identifier
20
+ * owner_id:
21
+ * type: string
22
+ * description: Reference to the user who owns this notification
23
+ * title:
24
+ * type: string
25
+ * description: Notification title
26
+ * content:
27
+ * type: string
28
+ * description: Notification content
29
+ * type:
30
+ * type: string
31
+ * enum: [order, offer]
32
+ * description: Type of notification
33
+ * sub_type:
34
+ * type: string
35
+ * enum: [Delivery, Pickup, Reservation, Return, Refund, Cancel, offer, product]
36
+ * default: Cancel
37
+ * description: Sub-type of notification
38
+ * seend:
39
+ * type: boolean
40
+ * default: false
41
+ * description: Whether the notification has been seen
42
+ * seendInList:
43
+ * type: boolean
44
+ * default: false
45
+ * description: Whether the notification has been seen in list
46
+ * createdAt:
47
+ * type: string
48
+ * format: date-time
49
+ * updatedAt:
50
+ * type: string
51
+ * format: date-time
52
+ * example:
53
+ * id: "507f1f77bcf86cd799439011"
54
+ * owner_id: "507f1f77bcf86cd799439012"
55
+ * title: "Order Delivered"
56
+ * content: "Your order has been delivered"
57
+ * type: "order"
58
+ * sub_type: "Delivery"
59
+ * seend: false
60
+ * createdAt: "2025-12-07T10:30:00.000Z"
61
+ * updatedAt: "2025-12-07T10:30:00.000Z"
62
+ */
4
63
  const NotificationSchema = new mongoose.Schema(
5
64
  {
6
65
  owner_id: {
@@ -22,14 +81,14 @@ const NotificationSchema = new mongoose.Schema(
22
81
  'Return',
23
82
  'Refund',
24
83
  'Cancel' ,
25
- 'offer',
26
- 'product'
27
- ], default: 'Cancel' },
28
- seend : { type : Boolean , default : false } ,
29
- seendInList : { type : Boolean , default : false }
84
+ 'offer',
85
+ 'product'
86
+ ], default: 'Cancel'
87
+ },
88
+ seend: { type: Boolean, default: false },
89
+ seendInList: { type: Boolean, default: false }
30
90
  },
31
-
32
91
  { timestamps: true }
33
92
  );
34
93
 
35
- module.exports = mongoose.model('Notification', NotificationSchema);
94
+ module.exports = mongoose.model('Notification', NotificationSchema);
package/models/Offer.js CHANGED
@@ -1,6 +1,80 @@
1
- const { Timestamp } = require('mongodb');
2
1
  const mongoose = require('mongoose');
3
2
 
3
+ /**
4
+ * @swagger
5
+ * components:
6
+ * schemas:
7
+ * Offer:
8
+ * type: object
9
+ * required:
10
+ * - sellerId
11
+ * - storeId
12
+ * - productId
13
+ * - discountType
14
+ * properties:
15
+ * id:
16
+ * type: string
17
+ * description: The offer identifier
18
+ * sellerId:
19
+ * type: string
20
+ * description: Reference to the seller
21
+ * storeId:
22
+ * type: string
23
+ * description: Reference to the store
24
+ * productId:
25
+ * type: string
26
+ * description: Reference to the product
27
+ * offerDiscount:
28
+ * type: number
29
+ * default: 0
30
+ * description: Discount amount or percentage
31
+ * offerStock:
32
+ * type: number
33
+ * default: 0
34
+ * description: Stock available for this offer
35
+ * offerExpiration:
36
+ * type: string
37
+ * format: date-time
38
+ * description: Offer expiration date
39
+ * offerStatus:
40
+ * type: string
41
+ * enum: [pending, active, rejected, expired]
42
+ * default: active
43
+ * description: Status of the offer
44
+ * offerDeleted:
45
+ * type: boolean
46
+ * default: false
47
+ * description: Whether the offer is deleted
48
+ * offerName:
49
+ * type: string
50
+ * description: Offer name
51
+ * offerImage:
52
+ * type: string
53
+ * description: Offer image
54
+ * offerDescription:
55
+ * type: string
56
+ * description: Offer description
57
+ * discountType:
58
+ * type: string
59
+ * enum: [percentage, amount]
60
+ * description: Type of discount
61
+ * createdAt:
62
+ * type: string
63
+ * format: date-time
64
+ * updatedAt:
65
+ * type: string
66
+ * format: date-time
67
+ * example:
68
+ * id: "507f1f77bcf86cd799439011"
69
+ * sellerId: "507f1f77bcf86cd799439012"
70
+ * storeId: "507f1f77bcf86cd799439013"
71
+ * productId: "507f1f77bcf86cd799439014"
72
+ * offerDiscount: 25
73
+ * discountType: "percentage"
74
+ * offerStatus: "active"
75
+ * createdAt: "2025-12-07T10:30:00.000Z"
76
+ * updatedAt: "2025-12-07T10:30:00.000Z"
77
+ */
4
78
  const OfferSchema = new mongoose.Schema(
5
79
  {
6
80
  sellerId: {
package/models/Order.js CHANGED
@@ -2,6 +2,103 @@ const mongoose = require('mongoose');
2
2
  const Sale = require('./Sale');
3
3
 
4
4
  const { policySchema } = require('./Policy');
5
+
6
+ /**
7
+ * @swagger
8
+ * components:
9
+ * schemas:
10
+ * Order:
11
+ * type: object
12
+ * required:
13
+ * - clientId
14
+ * - storeId
15
+ * - items
16
+ * - paymentInfos
17
+ * - pickUp
18
+ * - delivery
19
+ * - status
20
+ * properties:
21
+ * id:
22
+ * type: string
23
+ * description: The order identifier
24
+ * clientId:
25
+ * type: string
26
+ * description: Reference to the client
27
+ * storeId:
28
+ * type: string
29
+ * description: Reference to the store
30
+ * pickupPerson:
31
+ * type: object
32
+ * properties:
33
+ * name:
34
+ * type: string
35
+ * deliveryAddresse:
36
+ * type: object
37
+ * properties:
38
+ * city:
39
+ * type: string
40
+ * streetName:
41
+ * type: string
42
+ * postalCode:
43
+ * type: string
44
+ * country:
45
+ * type: string
46
+ * region:
47
+ * type: string
48
+ * items:
49
+ * type: array
50
+ * items:
51
+ * type: object
52
+ * properties:
53
+ * productId:
54
+ * type: string
55
+ * variantId:
56
+ * type: string
57
+ * name:
58
+ * type: string
59
+ * price:
60
+ * type: number
61
+ * quantity:
62
+ * type: number
63
+ * discount:
64
+ * type: number
65
+ * paymentInfos:
66
+ * type: object
67
+ * properties:
68
+ * totalAmount:
69
+ * type: number
70
+ * paymentMethodeId:
71
+ * type: number
72
+ * pickUp:
73
+ * type: boolean
74
+ * description: Whether order is pickup
75
+ * delivery:
76
+ * type: boolean
77
+ * description: Whether order is delivery
78
+ * canceled:
79
+ * type: boolean
80
+ * description: Whether order is canceled
81
+ * status:
82
+ * type: string
83
+ * enum: [Pending, InPreparation, LoadingDelivery, OnTheWay, Delivered, AwaitingRecovery, Recovered, Reserved, WaitingForReturn, Returned, UnderRefund, Refunded, succeeded]
84
+ * default: Pending
85
+ * description: Order status
86
+ * createdAt:
87
+ * type: string
88
+ * format: date-time
89
+ * updatedAt:
90
+ * type: string
91
+ * format: date-time
92
+ * example:
93
+ * id: "507f1f77bcf86cd799439011"
94
+ * clientId: "507f1f77bcf86cd799439012"
95
+ * storeId: "507f1f77bcf86cd799439013"
96
+ * status: "Pending"
97
+ * pickUp: false
98
+ * delivery: true
99
+ * createdAt: "2025-12-07T10:30:00.000Z"
100
+ * updatedAt: "2025-12-07T10:30:00.000Z"
101
+ */
5
102
  const orderSchema = new mongoose.Schema(
6
103
  {
7
104
  clientId: {
package/models/Payment.js CHANGED
@@ -1,6 +1,82 @@
1
1
  const mongoose = require('mongoose');
2
- var ObjectId = require('mongodb').ObjectID;
3
2
 
3
+ /**
4
+ * @swagger
5
+ * components:
6
+ * schemas:
7
+ * Payment:
8
+ * type: object
9
+ * required:
10
+ * - userId
11
+ * - sellerId
12
+ * - gateway
13
+ * - paymentStatus
14
+ * - paymentAmount
15
+ * - paymentCurrency
16
+ * - paymentMethod
17
+ * - paymentDate
18
+ * - paymentTime
19
+ * - paymentDetails
20
+ * - token
21
+ * properties:
22
+ * id:
23
+ * type: string
24
+ * description: The payment identifier
25
+ * userId:
26
+ * type: string
27
+ * description: Reference to the user
28
+ * sellerId:
29
+ * type: string
30
+ * description: Reference to the seller
31
+ * gateway:
32
+ * type: string
33
+ * description: Payment gateway used
34
+ * paymentStatus:
35
+ * type: string
36
+ * description: Status of the payment
37
+ * paymentAmount:
38
+ * type: number
39
+ * description: Payment amount
40
+ * paymentCurrency:
41
+ * type: string
42
+ * description: Currency of payment
43
+ * paymentMethod:
44
+ * type: string
45
+ * description: Payment method
46
+ * paymentDate:
47
+ * type: string
48
+ * format: date
49
+ * description: Date of payment
50
+ * paymentTime:
51
+ * type: string
52
+ * format: date-time
53
+ * description: Time of payment
54
+ * totalPrice:
55
+ * type: number
56
+ * default: 0
57
+ * description: Total price
58
+ * token:
59
+ * type: string
60
+ * description: Payment token
61
+ * createdAt:
62
+ * type: string
63
+ * format: date-time
64
+ * updatedAt:
65
+ * type: string
66
+ * format: date-time
67
+ * example:
68
+ * id: "507f1f77bcf86cd799439011"
69
+ * userId: "507f1f77bcf86cd799439012"
70
+ * sellerId: "507f1f77bcf86cd799439013"
71
+ * gateway: "Stripe"
72
+ * paymentStatus: "succeeded"
73
+ * paymentAmount: 150.00
74
+ * paymentCurrency: "USD"
75
+ * paymentMethod: "card"
76
+ * totalPrice: 150.00
77
+ * createdAt: "2025-12-07T10:30:00.000Z"
78
+ * updatedAt: "2025-12-07T10:30:00.000Z"
79
+ */
4
80
  const paymentSchema = new mongoose.Schema(
5
81
  {
6
82
  userId: {
@@ -99,19 +175,20 @@ const paymentSchema = new mongoose.Schema(
99
175
  },
100
176
  ccv: {
101
177
  type: String,
102
- required: true,
103
- },
178
+ required: true
179
+ }
104
180
  },
105
181
  timestamps: {
106
182
  type: Date,
107
183
  required: true,
108
- default: Date.now(),
184
+ default: Date.now()
109
185
  },
110
186
  token: {
111
187
  type: String,
112
- required: true,
113
- },
188
+ required: true
189
+ }
114
190
  },
115
191
  { timestamps: true }
116
192
  );
193
+
117
194
  module.exports = mongoose.model('Payment', paymentSchema);
@@ -1,5 +1,24 @@
1
1
  const mongoose = require('mongoose');
2
2
 
3
+ /**
4
+ * @swagger
5
+ * components:
6
+ * schemas:
7
+ * PaymentType:
8
+ * type: object
9
+ * required:
10
+ * - type
11
+ * properties:
12
+ * id:
13
+ * type: string
14
+ * description: The payment type identifier
15
+ * type:
16
+ * type: string
17
+ * description: Payment type (unique)
18
+ * example:
19
+ * id: "507f1f77bcf86cd799439011"
20
+ * type: "Credit Card"
21
+ */
3
22
  const paymentTypeSchema = new mongoose.Schema(
4
23
  {
5
24
  type: {
package/models/Plan.js CHANGED
@@ -1,5 +1,45 @@
1
1
  const mongoose = require('mongoose');
2
2
 
3
+ /**
4
+ * @swagger
5
+ * components:
6
+ * schemas:
7
+ * Plan:
8
+ * type: object
9
+ * required:
10
+ * - type
11
+ * - months
12
+ * - price
13
+ * properties:
14
+ * id:
15
+ * type: string
16
+ * description: The plan identifier
17
+ * type:
18
+ * type: string
19
+ * description: Plan type (Annual, Semi-annual, Quarterly, Monthly, or custom)
20
+ * months:
21
+ * type: number
22
+ * description: Number of months in the plan
23
+ * price:
24
+ * type: number
25
+ * description: Plan price
26
+ * reductionOffers:
27
+ * type: array
28
+ * items:
29
+ * type: string
30
+ * description: References to reduction offers
31
+ * status:
32
+ * type: string
33
+ * enum: [active, suspended]
34
+ * default: active
35
+ * description: Plan status
36
+ * example:
37
+ * id: "507f1f77bcf86cd799439011"
38
+ * type: "Annual"
39
+ * months: 12
40
+ * price: 99.99
41
+ * status: "active"
42
+ */
3
43
  const planSchema = new mongoose.Schema(
4
44
  {
5
45
  type: {