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/User.js CHANGED
@@ -1,7 +1,124 @@
1
1
  const mongoose = require('mongoose');
2
2
  const { policySchema } = require('database-connector/models/Policy');
3
- var ObjectId = require('mongodb').ObjectID;
4
3
 
4
+ /**
5
+ * @swagger
6
+ * components:
7
+ * schemas:
8
+ * User:
9
+ * type: object
10
+ * required:
11
+ * - password
12
+ * properties:
13
+ * id:
14
+ * type: string
15
+ * description: The user identifier
16
+ * password:
17
+ * type: string
18
+ * minLength: 8
19
+ * description: User password (must contain at least one letter and one number)
20
+ * username:
21
+ * type: string
22
+ * description: Unique username
23
+ * role:
24
+ * type: string
25
+ * enum: [user, admin, seller, paymentManager, manager, SuperManager]
26
+ * default: user
27
+ * description: User role
28
+ * isAdmin:
29
+ * type: boolean
30
+ * default: false
31
+ * description: Whether the user is an admin
32
+ * companyName:
33
+ * type: string
34
+ * description: Company name
35
+ * phone:
36
+ * type: string
37
+ * description: User phone number
38
+ * verificationCode:
39
+ * type: string
40
+ * description: Verification code for account
41
+ * isVerified:
42
+ * type: boolean
43
+ * default: false
44
+ * description: Whether the user is verified
45
+ * welcome:
46
+ * type: boolean
47
+ * default: false
48
+ * description: Welcome status
49
+ * profileImage:
50
+ * type: string
51
+ * description: Profile image URL
52
+ * discountCode:
53
+ * type: string
54
+ * description: Discount code
55
+ * email:
56
+ * type: string
57
+ * description: User email address
58
+ * favouritsProductst:
59
+ * type: array
60
+ * items:
61
+ * type: object
62
+ * properties:
63
+ * productId:
64
+ * type: string
65
+ * description: List of favorite products
66
+ * adresse:
67
+ * type: object
68
+ * properties:
69
+ * latitude:
70
+ * type: number
71
+ * longitude:
72
+ * type: number
73
+ * countryCode:
74
+ * type: string
75
+ * country:
76
+ * type: string
77
+ * city:
78
+ * type: string
79
+ * postalCode:
80
+ * type: string
81
+ * locality:
82
+ * type: string
83
+ * apartmentNumber:
84
+ * type: string
85
+ * streetName:
86
+ * type: string
87
+ * region:
88
+ * type: string
89
+ * fullAddress:
90
+ * type: string
91
+ * proximityRange:
92
+ * type: number
93
+ * default: 20
94
+ * description: Proximity range in kilometers
95
+ * storeCategorieIds:
96
+ * type: array
97
+ * items:
98
+ * type: string
99
+ * description: Store category references
100
+ * storeSubs:
101
+ * type: array
102
+ * items:
103
+ * type: string
104
+ * description: Subscribed stores
105
+ * createdAt:
106
+ * type: string
107
+ * format: date-time
108
+ * updatedAt:
109
+ * type: string
110
+ * format: date-time
111
+ * example:
112
+ * id: "507f1f77bcf86cd799439011"
113
+ * username: "john_doe"
114
+ * role: "user"
115
+ * email: "john.doe@example.com"
116
+ * phone: "+1234567890"
117
+ * isVerified: true
118
+ * proximityRange: 25
119
+ * createdAt: "2025-11-01T10:30:00.000Z"
120
+ * updatedAt: "2025-12-01T15:45:00.000Z"
121
+ */
5
122
  const userSchema = new mongoose.Schema(
6
123
  {
7
124
  password: {
@@ -1,5 +1,44 @@
1
1
  const mongoose = require("mongoose");
2
2
 
3
+ /**
4
+ * @swagger
5
+ * components:
6
+ * schemas:
7
+ * UserAction:
8
+ * type: object
9
+ * required:
10
+ * - type
11
+ * properties:
12
+ * id:
13
+ * type: string
14
+ * description: The user action identifier
15
+ * userId:
16
+ * type: string
17
+ * description: Reference to the user
18
+ * type:
19
+ * type: string
20
+ * description: Type of action
21
+ * deviceId:
22
+ * type: string
23
+ * description: Device identifier
24
+ * sessionId:
25
+ * type: string
26
+ * description: Session identifier
27
+ * details:
28
+ * type: object
29
+ * description: Additional details about the action
30
+ * timestamp:
31
+ * type: string
32
+ * format: date-time
33
+ * description: When the action occurred
34
+ * example:
35
+ * id: "507f1f77bcf86cd799439011"
36
+ * userId: "507f1f77bcf86cd799439012"
37
+ * type: "product_view"
38
+ * deviceId: "device123"
39
+ * sessionId: "session456"
40
+ * timestamp: "2025-12-07T10:30:00.000Z"
41
+ */
3
42
  const UserActionSchema = new mongoose.Schema({
4
43
  userId: {
5
44
  type: mongoose.Schema.Types.ObjectId,
package/models/View.js CHANGED
@@ -1,12 +1,52 @@
1
1
  const mongoose = require('mongoose');
2
2
 
3
+ /**
4
+ * @swagger
5
+ * components:
6
+ * schemas:
7
+ * View:
8
+ * type: object
9
+ * required:
10
+ * - date
11
+ * properties:
12
+ * id:
13
+ * type: string
14
+ * description: The view identifier
15
+ * sellerId:
16
+ * type: string
17
+ * description: Reference to the seller
18
+ * clientId:
19
+ * type: string
20
+ * description: Reference to the client
21
+ * storeId:
22
+ * type: string
23
+ * description: Reference to the store
24
+ * productId:
25
+ * type: string
26
+ * description: Reference to the product
27
+ * date:
28
+ * type: string
29
+ * format: date-time
30
+ * description: The date of the view
31
+ * region:
32
+ * type: string
33
+ * description: Region where the view occurred
34
+ * example:
35
+ * id: "507f1f77bcf86cd799439011"
36
+ * sellerId: "507f1f77bcf86cd799439012"
37
+ * clientId: "507f1f77bcf86cd799439013"
38
+ * storeId: "507f1f77bcf86cd799439014"
39
+ * productId: "507f1f77bcf86cd799439015"
40
+ * date: "2025-12-07T10:30:00.000Z"
41
+ * region: "North Region"
42
+ */
3
43
  const viewsSchema = new mongoose.Schema({
4
- sellerId: { type: mongoose.Schema.Types.ObjectId, ref: 'Seller' },
5
- clientId: { type: mongoose.Schema.Types.ObjectId, ref: 'Client' },
6
- storeId: { type: mongoose.Schema.Types.ObjectId, ref: 'Store' },
7
- productId: { type: mongoose.Schema.Types.ObjectId, ref: 'Product' },
8
- date: { type: Date, required: true },
9
- region: { type: String }, // If you want to track region for each view
44
+ sellerId: { type: mongoose.Schema.Types.ObjectId, ref: 'Seller' },
45
+ clientId: { type: mongoose.Schema.Types.ObjectId, ref: 'Client' },
46
+ storeId: { type: mongoose.Schema.Types.ObjectId, ref: 'Store' },
47
+ productId: { type: mongoose.Schema.Types.ObjectId, ref: 'Product' },
48
+ date: { type: Date, required: true },
49
+ region: { type: String }
10
50
  });
11
51
 
12
52
  module.exports = mongoose.model('View', viewsSchema);
package/models/index.js CHANGED
@@ -31,7 +31,7 @@ const SubscriptionOffer = require('./SubscriptionOffer');
31
31
  const FlashDeal = require('./FlashDeal');
32
32
  const Notification = require('./Notification');
33
33
  const PaymentType = require('./PaymentType');
34
- const { policySchema } = require('./Policy');
34
+ const Policy = require('./Policy');
35
35
  const ReductionOffer = require('./ReductionOffer');
36
36
  const Sale = require('./Sale');
37
37
  const StoreCategory = require('./StoreCategory');
@@ -41,7 +41,7 @@ const UserAction = require('./UserAction.js');
41
41
  module.exports = {
42
42
  connectToDatabase,
43
43
  PaymentType,
44
- policySchema,
44
+ Policy,
45
45
  ReductionOffer,
46
46
  Sale,
47
47
  StoreCategory,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "database-connector",
3
- "version": "1.0.7",
3
+ "version": "1.1.0",
4
4
  "main": "models/index.js",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"
@@ -10,6 +10,6 @@
10
10
  "license": "ISC",
11
11
  "description": "",
12
12
  "dependencies": {
13
- "mongoose": "^6.2.10"
13
+ "mongoose": "^6.2.10"
14
14
  }
15
15
  }
@@ -1,74 +0,0 @@
1
- const mongoose = require('mongoose');
2
- var ObjectId = require('mongodb').ObjectID;
3
-
4
- const orderSchema = new mongoose.Schema(
5
- {
6
- userId: {
7
- type: mongoose.Schema.Types.ObjectId,
8
- required: true,
9
- ref: 'User',
10
- },
11
- storeId: {
12
- type: mongoose.Schema.Types.ObjectId,
13
- required: true,
14
- ref: 'Store',
15
- },
16
- billId: {
17
- type: mongoose.Schema.Types.ObjectId,
18
- required: true,
19
- ref: 'Bill',
20
- },
21
-
22
- clientSecret: {
23
- type: String,
24
- },
25
- paymentId: {
26
- type: String,
27
- },
28
- paymentMethod: {
29
- type: String,
30
- },
31
-
32
- items: [
33
- {
34
- productId: { type: String, required: true },
35
- variantId: { type: String, required: true },
36
- quantity: { type: Number, required: true, default: 1 },
37
- discountQuantity: { type: Number, required: true, default: 0 },
38
- totalPrice: { type: Number, required: true },
39
- discount: { type: Number, required: true },
40
- },
41
- {
42
- timestamps: true,
43
- },
44
- ],
45
-
46
- origin: {
47
- city: { type: String },
48
- state: { type: String },
49
- country: { type: String },
50
- postalCode: { type: String },
51
- phone: { type: String },
52
- street1: { type: String },
53
- street2: { type: String },
54
- longitude: { type: Number },
55
- latitude: { type: Number },
56
- },
57
- billingAdress: {
58
- city: { type: String },
59
- state: { type: String },
60
- country: { type: String },
61
- postalCode: { type: String },
62
- phone: { type: String },
63
- street1: { type: String },
64
- street2: { type: String },
65
- longitude: { type: Number },
66
- latitude: { type: Number },
67
- },
68
-
69
- total: { type: Number, required: true, default: 0 },
70
- status: { type: String, required: true, enum: ['pending', 'succeeded', 'cancelled', 'delivered'], default: 'pending' },
71
- },
72
- { timestamps: true }
73
- );
74
- // module.exports = mongoose.model('Order', orderSchema);