database-connector 2.5.3 → 2.5.5

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
@@ -241,6 +241,10 @@ const { policySchema } = require('./Policy');
241
241
  * type: string
242
242
  * nullable: true
243
243
  * description: Link to the invoice document
244
+ * currency:
245
+ * type: string
246
+ * nullable: true
247
+ * description: Currency code for the order (e.g. USD, EUR, DZD)
244
248
  * status:
245
249
  * type: string
246
250
  * enum: [Pending, Payed, InPreparation, LoadingDelivery, OnTheWay, Delivered, AwaitingRecovery, Recovered, Reserved, WaitingForReturn, Returned, UnderRefund, Refunded, succeeded]
@@ -468,6 +472,10 @@ const orderSchema = new mongoose.Schema(
468
472
  type: String,
469
473
  default: null,
470
474
  },
475
+ currency: {
476
+ type: String,
477
+ default: null,
478
+ },
471
479
  status: {
472
480
  type: String, required: true, enum: [
473
481
  'Pending',
package/models/Policy.js CHANGED
@@ -19,11 +19,17 @@ const { Schema } = require('mongoose');
19
19
  * pickup:
20
20
  * type: object
21
21
  * properties:
22
+ * enabled:
23
+ * type: boolean
24
+ * default: false
22
25
  * timeLimit:
23
26
  * type: number
24
27
  * delivery:
25
28
  * type: object
26
29
  * properties:
30
+ * enabled:
31
+ * type: boolean
32
+ * default: false
27
33
  * delivery:
28
34
  * type: boolean
29
35
  * zone:
@@ -125,6 +131,31 @@ const { Schema } = require('mongoose');
125
131
  * type: boolean
126
132
  * ringing:
127
133
  * type: boolean
134
+ * payment:
135
+ * type: object
136
+ * properties:
137
+ * enabled:
138
+ * type: boolean
139
+ * default: false
140
+ * paymentTypeIds:
141
+ * type: array
142
+ * items:
143
+ * type: string
144
+ * description: Array of PaymentType references
145
+ * credentials:
146
+ * type: array
147
+ * items:
148
+ * type: object
149
+ * properties:
150
+ * paymentTypeId:
151
+ * type: string
152
+ * description: Reference to PaymentType
153
+ * keys:
154
+ * type: object
155
+ * additionalProperties:
156
+ * type: string
157
+ * description: Key-value pairs for provider credentials (e.g. stripe secret key, paypal client id)
158
+ * description: Provider-specific credentials per payment type
128
159
  */
129
160
  const policySchema = new Schema(
130
161
  {
@@ -136,11 +167,13 @@ const policySchema = new Schema(
136
167
  },
137
168
  pickup: {
138
169
  type: {
170
+ enabled: { type: Boolean, default: false },
139
171
  timeLimit: { type: Number, default: null }
140
172
  }
141
173
  },
142
174
  delivery: {
143
175
  type: {
176
+ enabled: { type: Boolean, default: false },
144
177
  delivery: { type: Boolean, default: null },
145
178
  zone: {
146
179
  centerPoint: {
@@ -206,7 +239,19 @@ const policySchema = new Schema(
206
239
  }
207
240
  }
208
241
  }
209
- }
242
+ },
243
+ payment: {
244
+ type: {
245
+ enabled: { type: Boolean, default: false },
246
+ paymentTypeIds: [{ type: Schema.Types.ObjectId, ref: 'PaymentType' }],
247
+ credentials: [
248
+ {
249
+ paymentTypeId: { type: Schema.Types.ObjectId, ref: 'PaymentType' },
250
+ keys: { type: Map, of: String },
251
+ },
252
+ ]
253
+ }
254
+ },
210
255
  },
211
256
  {}
212
257
  );
package/models/Product.js CHANGED
@@ -65,6 +65,10 @@ const { policySchema } = require('database-connector/models/Policy');
65
65
  * type: boolean
66
66
  * default: false
67
67
  * description: Whether the product is deleted
68
+ * confirmed:
69
+ * type: boolean
70
+ * default: true
71
+ * description: Whether the product is confirmed/verified
68
72
  * discount:
69
73
  * type: number
70
74
  * default: 0
@@ -175,6 +179,10 @@ const productSchema = new mongoose.Schema(
175
179
  required: true,
176
180
  default: false,
177
181
  },
182
+ confirmed: {
183
+ type: Boolean,
184
+ default: true,
185
+ },
178
186
 
179
187
  discountCode: {
180
188
  type: String,
@@ -316,5 +324,6 @@ productSchema.index({ createdAt: -1 });
316
324
  productSchema.index({ price: 1 });
317
325
  productSchema.index({ tags: 1 });
318
326
  productSchema.index({ 'variants._id': 1 });
327
+ productSchema.index({ confirmed: 1 });
319
328
 
320
329
  module.exports = mongoose.model('Product', productSchema);
package/models/Store.js CHANGED
@@ -87,6 +87,95 @@ const { policySchema } = require('database-connector/models/Policy');
87
87
  * type: boolean
88
88
  * default: false
89
89
  * description: Whether the store is activated
90
+ * confirmed:
91
+ * type: boolean
92
+ * default: false
93
+ * description: Whether the store is confirmed/verified
94
+ * physicalMerchantInfo:
95
+ * type: object
96
+ * description: Info specific to physical merchant (Commerçant physique)
97
+ * properties:
98
+ * approximateSurface:
99
+ * type: number
100
+ * shopPhotos:
101
+ * type: array
102
+ * items:
103
+ * type: string
104
+ * mobileMerchantInfo:
105
+ * type: object
106
+ * description: Info specific to mobile merchant (Commerçant mobile)
107
+ * properties:
108
+ * coveredZones:
109
+ * type: array
110
+ * items:
111
+ * type: object
112
+ * properties:
113
+ * city:
114
+ * type: string
115
+ * region:
116
+ * type: string
117
+ * latitude:
118
+ * type: number
119
+ * longitude:
120
+ * type: number
121
+ * realTimePosition:
122
+ * type: boolean
123
+ * standPhoto:
124
+ * type: string
125
+ * visibleName:
126
+ * type: string
127
+ * producerInfo:
128
+ * type: object
129
+ * description: Info specific to producer (Producteur)
130
+ * properties:
131
+ * productionType:
132
+ * type: string
133
+ * productionMethods:
134
+ * type: array
135
+ * items:
136
+ * type: string
137
+ * visitPossible:
138
+ * type: boolean
139
+ * labels:
140
+ * type: array
141
+ * items:
142
+ * type: object
143
+ * properties:
144
+ * title:
145
+ * type: string
146
+ * link:
147
+ * type: string
148
+ * directSale:
149
+ * type: boolean
150
+ * saleLocations:
151
+ * type: array
152
+ * items:
153
+ * type: object
154
+ * properties:
155
+ * name:
156
+ * type: string
157
+ * latitude:
158
+ * type: number
159
+ * longitude:
160
+ * type: number
161
+ * deliveryScope:
162
+ * type: string
163
+ * enum: [local, national]
164
+ * availableQuantities:
165
+ * type: string
166
+ * enum: [small_series, volume, both]
167
+ * eMerchantInfo:
168
+ * type: object
169
+ * description: Info specific to e-merchant (E-commerçant)
170
+ * properties:
171
+ * websiteUrl:
172
+ * type: string
173
+ * platform:
174
+ * type: string
175
+ * onlineShopName:
176
+ * type: string
177
+ * approximateProductCount:
178
+ * type: number
90
179
  * subscriptionId:
91
180
  * type: string
92
181
  * description: Reference to subscription
@@ -376,6 +465,10 @@ const storeSchema = new mongoose.Schema(
376
465
  type: Boolean,
377
466
  default: false,
378
467
  },
468
+ confirmed: {
469
+ type: Boolean,
470
+ default: false,
471
+ },
379
472
  subscriptionId: {
380
473
  type: mongoose.Schema.Types.ObjectId,
381
474
  ref: 'Subscription',
@@ -398,6 +491,72 @@ const storeSchema = new mongoose.Schema(
398
491
  required: false,
399
492
  description: 'QR Code associated with the store',
400
493
  },
494
+ // Commerçant Physique specific info
495
+ physicalMerchantInfo: {
496
+ approximateSurface: { type: Number, default: null },
497
+ shopPhotos: [{ type: String }],
498
+ },
499
+ // Commerçant Mobile specific info
500
+ mobileMerchantInfo: {
501
+ coveredZones: [
502
+ {
503
+ city: { type: String },
504
+ region: { type: String },
505
+ latitude: { type: Number, default: null },
506
+ longitude: { type: Number, default: null },
507
+ },
508
+ ],
509
+ realTimePosition: { type: Boolean, default: false },
510
+ marketCalendar: [
511
+ {
512
+ date: { type: String },
513
+ location: { type: String },
514
+ marketName: { type: String },
515
+ },
516
+ ],
517
+ standPhoto: { type: String, default: null },
518
+ visibleName: { type: String, default: null },
519
+ },
520
+ // Producteur specific info
521
+ producerInfo: {
522
+ productionType: {
523
+ type: String,
524
+ default: null,
525
+ },
526
+ productionMethods: [{ type: String }],
527
+ visitPossible: { type: Boolean, default: false },
528
+ labels: [
529
+ {
530
+ title: { type: String },
531
+ link: { type: String },
532
+ },
533
+ ],
534
+ directSale: { type: Boolean, default: false },
535
+ saleLocations: [
536
+ {
537
+ name: { type: String },
538
+ latitude: { type: Number, default: null },
539
+ longitude: { type: Number, default: null },
540
+ },
541
+ ],
542
+ deliveryScope: {
543
+ type: String,
544
+ enum: ['local', 'national'],
545
+ default: null,
546
+ },
547
+ availableQuantities: {
548
+ type: String,
549
+ enum: ['small_series', 'volume', 'both'],
550
+ default: null,
551
+ },
552
+ },
553
+ // E-commerçant specific info
554
+ eMerchantInfo: {
555
+ websiteUrl: { type: String, default: null },
556
+ platform: { type: String, default: null },
557
+ onlineShopName: { type: String, default: null },
558
+ approximateProductCount: { type: Number, default: null },
559
+ },
401
560
  },
402
561
 
403
562
  { timestamps: true, toJSON: { virtuals: true } }
@@ -425,5 +584,6 @@ storeSchema.index({ isActive: 1 });
425
584
  storeSchema.index({ activated: 1 });
426
585
  storeSchema.index({ storeCategorieIds: 1 });
427
586
  storeSchema.index({ ratingSum: -1, ratingCount: -1 });
587
+ storeSchema.index({ confirmed: 1 });
428
588
 
429
589
  module.exports = mongoose.model('Store', storeSchema);
package/models/User.js CHANGED
@@ -25,6 +25,10 @@ const { policySchema } = require('database-connector/models/Policy');
25
25
  * enum: [user, admin, seller, paymentManager, manager, SuperManager]
26
26
  * default: user
27
27
  * description: User role
28
+ * sellerType:
29
+ * type: string
30
+ * enum: [physical_merchant, mobile_merchant, producer, e_merchant]
31
+ * description: Type of seller (null if not a seller)
28
32
  * isAdmin:
29
33
  * type: boolean
30
34
  * default: false
@@ -179,6 +183,11 @@ const userSchema = new mongoose.Schema(
179
183
  enum: ['user', 'admin', 'seller', 'paymentManager', 'manager', 'SuperManager'],
180
184
  default: 'user',
181
185
  },
186
+ sellerType: {
187
+ type: String,
188
+ enum: ['physical_merchant', 'mobile_merchant', 'producer', 'e_merchant'],
189
+ default: null,
190
+ },
182
191
  isAdmin: { type: Boolean, default: false },
183
192
  companyName: {
184
193
  type: String,
@@ -393,6 +402,7 @@ userSchema.index({ username: 1 }, { unique: true });
393
402
  userSchema.index({ email: 1 }, { sparse: true });
394
403
  userSchema.index({ phone: 1 }, { sparse: true });
395
404
  userSchema.index({ role: 1 });
405
+ userSchema.index({ sellerType: 1 }, { sparse: true });
396
406
  userSchema.index({ storeSubs: 1 });
397
407
 
398
408
  module.exports = mongoose.model('User', userSchema);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "database-connector",
3
- "version": "2.5.3",
3
+ "version": "2.5.5",
4
4
  "description": "MongoDB models package with Mongoose schemas for e-commerce applications. Includes User, Product, Store, Order and more with built-in validation and virtual properties.",
5
5
  "main": "models/index.js",
6
6
  "scripts": {