database-connector 1.0.7 → 1.1.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.
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: {
package/models/Policy.js CHANGED
@@ -1,96 +1,214 @@
1
1
  const { Schema, model } = require('mongoose');
2
2
 
3
+ /**
4
+ * @swagger
5
+ * components:
6
+ * schemas:
7
+ * Policy:
8
+ * type: object
9
+ * properties:
10
+ * workingTime:
11
+ * type: object
12
+ * properties:
13
+ * openTime:
14
+ * type: string
15
+ * default: ""
16
+ * closeTime:
17
+ * type: string
18
+ * default: ""
19
+ * pickup:
20
+ * type: object
21
+ * properties:
22
+ * timeLimit:
23
+ * type: number
24
+ * delivery:
25
+ * type: object
26
+ * properties:
27
+ * delivery:
28
+ * type: boolean
29
+ * zone:
30
+ * type: object
31
+ * properties:
32
+ * centerPoint:
33
+ * type: object
34
+ * properties:
35
+ * latitude:
36
+ * type: number
37
+ * longitude:
38
+ * type: number
39
+ * radius:
40
+ * type: number
41
+ * pricing:
42
+ * type: object
43
+ * properties:
44
+ * fixe:
45
+ * type: number
46
+ * km:
47
+ * type: number
48
+ * reservation:
49
+ * type: object
50
+ * properties:
51
+ * duration:
52
+ * type: number
53
+ * payment:
54
+ * type: object
55
+ * properties:
56
+ * free:
57
+ * type: boolean
58
+ * partial:
59
+ * type: object
60
+ * properties:
61
+ * fixe:
62
+ * type: number
63
+ * percentage:
64
+ * type: number
65
+ * total:
66
+ * type: boolean
67
+ * cancelation:
68
+ * type: object
69
+ * properties:
70
+ * restrictions:
71
+ * type: object
72
+ * properties:
73
+ * fixe:
74
+ * type: number
75
+ * percentage:
76
+ * type: number
77
+ * return:
78
+ * type: object
79
+ * properties:
80
+ * duration:
81
+ * type: number
82
+ * productStatus:
83
+ * type: string
84
+ * returnMethod:
85
+ * type: string
86
+ * refund:
87
+ * type: object
88
+ * properties:
89
+ * order:
90
+ * type: object
91
+ * properties:
92
+ * fixe:
93
+ * type: number
94
+ * percentage:
95
+ * type: number
96
+ * shipping:
97
+ * type: object
98
+ * properties:
99
+ * fixe:
100
+ * type: number
101
+ * percentage:
102
+ * type: number
103
+ * order:
104
+ * type: object
105
+ * properties:
106
+ * notification:
107
+ * type: object
108
+ * properties:
109
+ * realtime:
110
+ * type: boolean
111
+ * time:
112
+ * type: number
113
+ * perOrdersNbr:
114
+ * type: number
115
+ * sendMode:
116
+ * type: object
117
+ * properties:
118
+ * mail:
119
+ * type: boolean
120
+ * sms:
121
+ * type: boolean
122
+ * popup:
123
+ * type: boolean
124
+ * vibration:
125
+ * type: boolean
126
+ * ringing:
127
+ * type: boolean
128
+ */
3
129
  exports.policySchema = new Schema(
4
- {
5
-
6
- workingTime : {
7
- type : {
8
- openTime: { type: String , default : ""},
9
- closeTime: { type: String , default : ""} ,
10
- } ,
11
- },
12
- pickup: {
13
- type : {
14
- timeLimit : { type: Number , default : null} ,
15
- } ,
16
- },
17
- delivery: {
18
- type : {
19
- delivery : {type : Boolean, default : null } ,
20
- zone : {
21
- centerPoint : {
22
- latitude : { type : Number , default : null} ,
23
- longitude : { type : Number , default : null} ,
24
- } ,
25
- radius : { type : Number , default : null } ,
26
- } ,
27
- pricing : {
28
- fixe : {type : Number , default : null} ,
29
- km : {type : Number , default : null} ,
30
- } ,
31
- }
32
-
33
- } ,
34
-
35
- reservation : {
36
- type : {
37
- duration : {type : Number , default : null} ,
38
- payment : {
39
- free : {type : Boolean , default : null} ,
40
- partial : {
41
- fixe : {type : Number , default : null} ,
42
- percentage : {type : Number , default : null} ,
43
- } ,
44
- total : {type : Boolean , default : null} ,
45
- } ,
46
- cancelation : {
47
- restrictions : {
48
- fixe : {type : Number , default : null} ,
49
- percentage : {type : Number , default : null} ,
50
- }
51
- } ,
52
- } ,
53
- } ,
54
- return : {
55
- type : {
56
- duration : {type : Number , default : null} ,
57
- productStatus : {type : String , default : ""} ,
58
- returnMethod : {type : String , default : ""} ,
59
- refund : {
60
- order : {
61
- fixe : {type : Number , default : null} ,
62
- percentage : {type : Number , default : null} ,
63
- } ,
64
- shipping : {
65
- fixe : {type : Number , default : null} ,
66
- percentage : {type : Number , default : null} ,
67
- },
68
- } ,
69
- } ,
70
-
71
- } ,
72
- order : {
73
- type : {
74
-
75
- notification : {
76
- realtime :{type : Boolean , default : null} ,
77
- time :{type : Number , default : null} ,
78
- perOrdersNbr :{type : Number , default : null} ,
79
- sendMode : {
80
- mail :{type : Boolean , default : null} ,
81
- sms :{type : Boolean , default : null} ,
82
- popup :{type : Boolean , default : null} ,
83
- vibration :{type : Boolean , default : null} ,
84
- ringing :{type : Boolean , default : null} ,
85
- } ,
86
- }
87
-
88
- }
89
- }
90
- },
91
130
  {
92
-
93
- }
131
+ workingTime: {
132
+ type: {
133
+ openTime: { type: String, default: '' },
134
+ closeTime: { type: String, default: '' }
135
+ }
136
+ },
137
+ pickup: {
138
+ type: {
139
+ timeLimit: { type: Number, default: null }
140
+ }
141
+ },
142
+ delivery: {
143
+ type: {
144
+ delivery: { type: Boolean, default: null },
145
+ zone: {
146
+ centerPoint: {
147
+ latitude: { type: Number, default: null },
148
+ longitude: { type: Number, default: null }
149
+ },
150
+ radius: { type: Number, default: null }
151
+ },
152
+ pricing: {
153
+ fixe: { type: Number, default: null },
154
+ km: { type: Number, default: null }
155
+ }
156
+ }
157
+ },
158
+ reservation: {
159
+ type: {
160
+ duration: { type: Number, default: null },
161
+ payment: {
162
+ free: { type: Boolean, default: null },
163
+ partial: {
164
+ fixe: { type: Number, default: null },
165
+ percentage: { type: Number, default: null }
166
+ },
167
+ total: { type: Boolean, default: null }
168
+ },
169
+ cancelation: {
170
+ restrictions: {
171
+ fixe: { type: Number, default: null },
172
+ percentage: { type: Number, default: null }
173
+ }
174
+ }
175
+ }
176
+ },
177
+ return: {
178
+ type: {
179
+ duration: { type: Number, default: null },
180
+ productStatus: { type: String, default: '' },
181
+ returnMethod: { type: String, default: '' },
182
+ refund: {
183
+ order: {
184
+ fixe: { type: Number, default: null },
185
+ percentage: { type: Number, default: null }
186
+ },
187
+ shipping: {
188
+ fixe: { type: Number, default: null },
189
+ percentage: { type: Number, default: null }
190
+ }
191
+ }
192
+ }
193
+ },
194
+ order: {
195
+ type: {
196
+ notification: {
197
+ realtime: { type: Boolean, default: null },
198
+ time: { type: Number, default: null },
199
+ perOrdersNbr: { type: Number, default: null },
200
+ sendMode: {
201
+ mail: { type: Boolean, default: null },
202
+ sms: { type: Boolean, default: null },
203
+ popup: { type: Boolean, default: null },
204
+ vibration: { type: Boolean, default: null },
205
+ ringing: { type: Boolean, default: null }
206
+ }
207
+ }
208
+ }
209
+ }
210
+ },
211
+ {}
94
212
  );
95
213
 
96
-
214
+ module.exports = model('Policy', planSchema);