@mac777/project-pinecone-models 1.1.23 → 1.1.25
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/dist/EmailVerification.d.ts +45 -0
- package/dist/EmailVerification.js +70 -0
- package/dist/Event.d.ts +9 -9
- package/dist/Event.js +54 -3
- package/dist/HostProfile.d.ts +96 -0
- package/dist/HostProfile.js +142 -0
- package/dist/PaymentDetails.d.ts +60 -0
- package/dist/PaymentDetails.js +120 -0
- package/dist/Payout.d.ts +12 -12
- package/dist/PhoneVerification.d.ts +54 -0
- package/dist/PhoneVerification.js +91 -0
- package/dist/User.d.ts +52 -195
- package/dist/User.js +86 -197
- package/dist/User.v2.d.ts +18 -18
- package/dist/VerificationDocument.d.ts +60 -0
- package/dist/VerificationDocument.js +111 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +12 -1
- package/package.json +1 -1
- package/src/EmailVerification.ts +71 -0
- package/src/Event.ts +108 -3
- package/src/HostProfile.ts +145 -0
- package/src/PaymentDetails.ts +127 -0
- package/src/PhoneVerification.ts +93 -0
- package/src/User.ts +95 -201
- package/src/VerificationDocument.ts +117 -0
- package/src/index.ts +7 -0
package/dist/User.js
CHANGED
|
@@ -4,238 +4,127 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const mongoose_1 = __importDefault(require("mongoose"));
|
|
7
|
+
/**
|
|
8
|
+
* User Schema (Refactored)
|
|
9
|
+
* Core identity and authentication only
|
|
10
|
+
* Related data moved to separate collections:
|
|
11
|
+
* - HostProfile
|
|
12
|
+
* - PaymentDetails
|
|
13
|
+
* - VerificationDocument
|
|
14
|
+
* - EmailVerification
|
|
15
|
+
* - PhoneVerification
|
|
16
|
+
*/
|
|
7
17
|
const userSchema = new mongoose_1.default.Schema({
|
|
18
|
+
// Identity
|
|
8
19
|
firstName: {
|
|
9
20
|
type: String,
|
|
10
|
-
required: true
|
|
21
|
+
required: true,
|
|
22
|
+
trim: true
|
|
11
23
|
},
|
|
12
24
|
lastName: {
|
|
13
25
|
type: String,
|
|
14
|
-
required: true
|
|
26
|
+
required: true,
|
|
27
|
+
trim: true
|
|
15
28
|
},
|
|
16
29
|
email: {
|
|
17
30
|
type: String,
|
|
18
31
|
required: true,
|
|
19
|
-
unique: true
|
|
32
|
+
unique: true,
|
|
33
|
+
lowercase: true,
|
|
34
|
+
trim: true,
|
|
35
|
+
index: true
|
|
20
36
|
},
|
|
37
|
+
// Auth
|
|
21
38
|
password: {
|
|
22
|
-
type: String
|
|
23
|
-
required: false
|
|
39
|
+
type: String // Optional for OAuth users
|
|
24
40
|
},
|
|
25
|
-
|
|
41
|
+
provider: {
|
|
26
42
|
type: String,
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
moderation: {
|
|
30
|
-
isSuspended: {
|
|
31
|
-
type: Boolean,
|
|
32
|
-
default: false
|
|
33
|
-
},
|
|
34
|
-
suspensionReason: {
|
|
35
|
-
type: String,
|
|
36
|
-
required: false
|
|
37
|
-
},
|
|
38
|
-
suspendedAt: {
|
|
39
|
-
type: Date,
|
|
40
|
-
required: false
|
|
41
|
-
},
|
|
42
|
-
isVerified: {
|
|
43
|
-
type: Boolean,
|
|
44
|
-
default: false
|
|
45
|
-
},
|
|
46
|
-
verifiedAt: {
|
|
47
|
-
type: Date,
|
|
48
|
-
required: false
|
|
49
|
-
},
|
|
50
|
-
},
|
|
51
|
-
emailVerified: {
|
|
52
|
-
type: Boolean,
|
|
53
|
-
default: false
|
|
43
|
+
enum: ['google', 'local', 'facebook'],
|
|
44
|
+
default: 'local'
|
|
54
45
|
},
|
|
55
|
-
|
|
46
|
+
googleId: {
|
|
56
47
|
type: String,
|
|
57
|
-
|
|
48
|
+
sparse: true,
|
|
49
|
+
unique: true
|
|
58
50
|
},
|
|
59
|
-
|
|
60
|
-
type:
|
|
61
|
-
required: false
|
|
51
|
+
refreshToken: {
|
|
52
|
+
type: String
|
|
62
53
|
},
|
|
54
|
+
// Contact
|
|
63
55
|
phoneNumber: {
|
|
64
56
|
type: String,
|
|
65
|
-
|
|
57
|
+
sparse: true,
|
|
58
|
+
trim: true
|
|
59
|
+
},
|
|
60
|
+
// Verification Status (denormalized for quick access)
|
|
61
|
+
emailVerified: {
|
|
62
|
+
type: Boolean,
|
|
63
|
+
default: false,
|
|
64
|
+
index: true
|
|
66
65
|
},
|
|
67
66
|
phoneVerified: {
|
|
68
67
|
type: Boolean,
|
|
69
68
|
default: false
|
|
70
69
|
},
|
|
71
|
-
|
|
70
|
+
// Role
|
|
71
|
+
role: {
|
|
72
72
|
type: String,
|
|
73
|
-
|
|
73
|
+
enum: ['user', 'host', 'admin'],
|
|
74
|
+
default: 'user',
|
|
75
|
+
index: true
|
|
74
76
|
},
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
77
|
+
// Moderation (flattened from nested object)
|
|
78
|
+
isSuspended: {
|
|
79
|
+
type: Boolean,
|
|
80
|
+
default: false,
|
|
81
|
+
index: true
|
|
78
82
|
},
|
|
79
|
-
|
|
80
|
-
type: String
|
|
81
|
-
required: false
|
|
83
|
+
suspensionReason: {
|
|
84
|
+
type: String
|
|
82
85
|
},
|
|
83
|
-
|
|
84
|
-
type:
|
|
85
|
-
default: false
|
|
86
|
+
suspendedAt: {
|
|
87
|
+
type: Date
|
|
86
88
|
},
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
enum: ['bkash', 'bank_transfer'],
|
|
91
|
-
default: 'bkash'
|
|
92
|
-
}, // "bkash" | "bank_transfer"
|
|
93
|
-
bkashNumber: {
|
|
94
|
-
type: String,
|
|
95
|
-
required: false
|
|
96
|
-
}, // "+8801712345678"
|
|
97
|
-
accountName: {
|
|
98
|
-
type: String,
|
|
99
|
-
required: false
|
|
100
|
-
}, // Must match NID
|
|
101
|
-
// Bank details (if method = bank_transfer)
|
|
102
|
-
bankName: {
|
|
103
|
-
type: String,
|
|
104
|
-
required: false
|
|
105
|
-
},
|
|
106
|
-
accountNumber: {
|
|
107
|
-
type: String,
|
|
108
|
-
required: false
|
|
109
|
-
},
|
|
110
|
-
branchName: {
|
|
111
|
-
type: String,
|
|
112
|
-
required: false
|
|
113
|
-
},
|
|
114
|
-
routingNumber: {
|
|
115
|
-
type: String,
|
|
116
|
-
required: false
|
|
117
|
-
},
|
|
118
|
-
verified: {
|
|
119
|
-
type: Boolean,
|
|
120
|
-
default: false
|
|
121
|
-
}, // Admin verified
|
|
122
|
-
verifiedAt: {
|
|
123
|
-
type: Date,
|
|
124
|
-
required: false
|
|
125
|
-
}
|
|
89
|
+
suspendedBy: {
|
|
90
|
+
type: mongoose_1.default.Schema.Types.ObjectId,
|
|
91
|
+
ref: 'User'
|
|
126
92
|
},
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
default: 'user'
|
|
93
|
+
// Legacy fields (kept for backward compatibility during transition)
|
|
94
|
+
organization: {
|
|
95
|
+
type: String // Deprecated: use HostProfile.organizationName
|
|
131
96
|
},
|
|
132
|
-
|
|
133
|
-
type: String
|
|
134
|
-
required: false
|
|
97
|
+
nidNumber: {
|
|
98
|
+
type: String // Deprecated: use VerificationDocument
|
|
135
99
|
},
|
|
136
|
-
|
|
137
|
-
type:
|
|
138
|
-
|
|
139
|
-
default: 'local'
|
|
100
|
+
nidVerified: {
|
|
101
|
+
type: Boolean,
|
|
102
|
+
default: false // Deprecated: use VerificationDocument status
|
|
140
103
|
},
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
},
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
organizationName: {
|
|
148
|
-
type: String,
|
|
149
|
-
required: false
|
|
150
|
-
},
|
|
151
|
-
role: {
|
|
152
|
-
type: String,
|
|
153
|
-
enum: ['event_organizer', 'venue_owner', 'authorized_rep', 'artist'],
|
|
154
|
-
required: false
|
|
155
|
-
},
|
|
156
|
-
contactPerson: {
|
|
157
|
-
name: {
|
|
158
|
-
type: String,
|
|
159
|
-
required: false
|
|
160
|
-
},
|
|
161
|
-
email: {
|
|
162
|
-
type: String,
|
|
163
|
-
required: false
|
|
164
|
-
},
|
|
165
|
-
phone: {
|
|
166
|
-
type: String,
|
|
167
|
-
required: false
|
|
168
|
-
},
|
|
169
|
-
designation: {
|
|
170
|
-
type: String,
|
|
171
|
-
required: false
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
},
|
|
175
|
-
// Verification (for hosts)
|
|
176
|
-
verification: {
|
|
177
|
-
status: {
|
|
178
|
-
type: String,
|
|
179
|
-
enum: ['unverified', 'pending', 'verified', 'rejected'],
|
|
180
|
-
default: 'unverified'
|
|
181
|
-
},
|
|
182
|
-
documents: [{
|
|
183
|
-
type: {
|
|
184
|
-
type: String,
|
|
185
|
-
enum: ['nid', 'trade_license', 'tax_certificate', 'other'],
|
|
186
|
-
required: true
|
|
187
|
-
},
|
|
188
|
-
url: {
|
|
189
|
-
type: String,
|
|
190
|
-
required: true
|
|
191
|
-
},
|
|
192
|
-
filename: {
|
|
193
|
-
type: String,
|
|
194
|
-
required: true
|
|
195
|
-
},
|
|
196
|
-
uploadedAt: {
|
|
197
|
-
type: Date,
|
|
198
|
-
default: Date.now
|
|
199
|
-
}
|
|
200
|
-
}],
|
|
201
|
-
submittedAt: {
|
|
202
|
-
type: Date,
|
|
203
|
-
required: false
|
|
204
|
-
},
|
|
205
|
-
reviewedAt: {
|
|
206
|
-
type: Date,
|
|
207
|
-
required: false
|
|
208
|
-
},
|
|
209
|
-
reviewedBy: {
|
|
210
|
-
type: mongoose_1.default.Schema.Types.ObjectId,
|
|
211
|
-
ref: 'User',
|
|
212
|
-
required: false
|
|
213
|
-
},
|
|
214
|
-
rejectionReason: {
|
|
215
|
-
type: String,
|
|
216
|
-
required: false
|
|
217
|
-
}
|
|
218
|
-
},
|
|
219
|
-
// Profile Completeness Tracking
|
|
220
|
-
profileCompleteness: {
|
|
221
|
-
hasContactInfo: {
|
|
222
|
-
type: Boolean,
|
|
223
|
-
default: false
|
|
224
|
-
},
|
|
225
|
-
hasPaymentDetails: {
|
|
226
|
-
type: Boolean,
|
|
227
|
-
default: false
|
|
228
|
-
},
|
|
229
|
-
hasVerificationDocs: {
|
|
230
|
-
type: Boolean,
|
|
231
|
-
default: false
|
|
232
|
-
},
|
|
233
|
-
isComplete: {
|
|
234
|
-
type: Boolean,
|
|
235
|
-
default: false
|
|
236
|
-
}
|
|
104
|
+
// Metadata
|
|
105
|
+
lastLoginAt: {
|
|
106
|
+
type: Date
|
|
107
|
+
},
|
|
108
|
+
lastLoginIP: {
|
|
109
|
+
type: String
|
|
237
110
|
}
|
|
238
111
|
}, {
|
|
239
|
-
timestamps: true
|
|
112
|
+
timestamps: true,
|
|
113
|
+
toJSON: { virtuals: true },
|
|
114
|
+
toObject: { virtuals: true }
|
|
115
|
+
});
|
|
116
|
+
// Indexes for common queries
|
|
117
|
+
userSchema.index({ email: 1 });
|
|
118
|
+
userSchema.index({ role: 1, isSuspended: 1 });
|
|
119
|
+
userSchema.index({ phoneNumber: 1 }, { sparse: true });
|
|
120
|
+
userSchema.index({ googleId: 1 }, { sparse: true });
|
|
121
|
+
userSchema.index({ emailVerified: 1, role: 1 });
|
|
122
|
+
// Virtual: Full Name
|
|
123
|
+
userSchema.virtual('fullName').get(function () {
|
|
124
|
+
return `${this.firstName} ${this.lastName}`;
|
|
125
|
+
});
|
|
126
|
+
// Virtual: Is Active
|
|
127
|
+
userSchema.virtual('isActive').get(function () {
|
|
128
|
+
return !this.isSuspended;
|
|
240
129
|
});
|
|
241
130
|
exports.default = userSchema;
|
package/dist/User.v2.d.ts
CHANGED
|
@@ -6,20 +6,21 @@ declare const userSchema: mongoose.Schema<any, mongoose.Model<any, any, any, any
|
|
|
6
6
|
status: "deleted" | "active" | "suspended";
|
|
7
7
|
role: "user" | "host" | "admin";
|
|
8
8
|
payout?: {
|
|
9
|
-
method: "bkash" | "bank_transfer";
|
|
10
9
|
verified: boolean;
|
|
10
|
+
method: "bkash" | "bank_transfer";
|
|
11
|
+
verifiedAt?: NativeDate | null | undefined;
|
|
11
12
|
bkash?: {
|
|
12
13
|
number?: string | null | undefined;
|
|
13
14
|
} | null | undefined;
|
|
14
|
-
verifiedAt?: NativeDate | null | undefined;
|
|
15
15
|
bank?: {
|
|
16
|
-
accountNumber?: string | null | undefined;
|
|
17
|
-
accountName?: string | null | undefined;
|
|
18
16
|
bankName?: string | null | undefined;
|
|
17
|
+
accountNumber?: string | null | undefined;
|
|
19
18
|
branchName?: string | null | undefined;
|
|
20
19
|
routingNumber?: string | null | undefined;
|
|
20
|
+
accountName?: string | null | undefined;
|
|
21
21
|
} | null | undefined;
|
|
22
22
|
} | null | undefined;
|
|
23
|
+
lastLoginAt?: NativeDate | null | undefined;
|
|
23
24
|
profile?: {
|
|
24
25
|
firstName: string;
|
|
25
26
|
lastName: string;
|
|
@@ -51,28 +52,28 @@ declare const userSchema: mongoose.Schema<any, mongoose.Model<any, any, any, any
|
|
|
51
52
|
auth?: {
|
|
52
53
|
provider: "google" | "local";
|
|
53
54
|
password?: string | null | undefined;
|
|
54
|
-
refreshToken?: string | null | undefined;
|
|
55
55
|
googleId?: string | null | undefined;
|
|
56
|
+
refreshToken?: string | null | undefined;
|
|
56
57
|
} | null | undefined;
|
|
57
|
-
lastLoginAt?: NativeDate | null | undefined;
|
|
58
58
|
} & mongoose.DefaultTimestampProps, mongoose.Document<unknown, {}, mongoose.FlatRecord<{
|
|
59
59
|
status: "deleted" | "active" | "suspended";
|
|
60
60
|
role: "user" | "host" | "admin";
|
|
61
61
|
payout?: {
|
|
62
|
-
method: "bkash" | "bank_transfer";
|
|
63
62
|
verified: boolean;
|
|
63
|
+
method: "bkash" | "bank_transfer";
|
|
64
|
+
verifiedAt?: NativeDate | null | undefined;
|
|
64
65
|
bkash?: {
|
|
65
66
|
number?: string | null | undefined;
|
|
66
67
|
} | null | undefined;
|
|
67
|
-
verifiedAt?: NativeDate | null | undefined;
|
|
68
68
|
bank?: {
|
|
69
|
-
accountNumber?: string | null | undefined;
|
|
70
|
-
accountName?: string | null | undefined;
|
|
71
69
|
bankName?: string | null | undefined;
|
|
70
|
+
accountNumber?: string | null | undefined;
|
|
72
71
|
branchName?: string | null | undefined;
|
|
73
72
|
routingNumber?: string | null | undefined;
|
|
73
|
+
accountName?: string | null | undefined;
|
|
74
74
|
} | null | undefined;
|
|
75
75
|
} | null | undefined;
|
|
76
|
+
lastLoginAt?: NativeDate | null | undefined;
|
|
76
77
|
profile?: {
|
|
77
78
|
firstName: string;
|
|
78
79
|
lastName: string;
|
|
@@ -104,10 +105,9 @@ declare const userSchema: mongoose.Schema<any, mongoose.Model<any, any, any, any
|
|
|
104
105
|
auth?: {
|
|
105
106
|
provider: "google" | "local";
|
|
106
107
|
password?: string | null | undefined;
|
|
107
|
-
refreshToken?: string | null | undefined;
|
|
108
108
|
googleId?: string | null | undefined;
|
|
109
|
+
refreshToken?: string | null | undefined;
|
|
109
110
|
} | null | undefined;
|
|
110
|
-
lastLoginAt?: NativeDate | null | undefined;
|
|
111
111
|
} & mongoose.DefaultTimestampProps>, {}, mongoose.ResolveSchemaOptions<{
|
|
112
112
|
timestamps: true;
|
|
113
113
|
strict: true;
|
|
@@ -115,20 +115,21 @@ declare const userSchema: mongoose.Schema<any, mongoose.Model<any, any, any, any
|
|
|
115
115
|
status: "deleted" | "active" | "suspended";
|
|
116
116
|
role: "user" | "host" | "admin";
|
|
117
117
|
payout?: {
|
|
118
|
-
method: "bkash" | "bank_transfer";
|
|
119
118
|
verified: boolean;
|
|
119
|
+
method: "bkash" | "bank_transfer";
|
|
120
|
+
verifiedAt?: NativeDate | null | undefined;
|
|
120
121
|
bkash?: {
|
|
121
122
|
number?: string | null | undefined;
|
|
122
123
|
} | null | undefined;
|
|
123
|
-
verifiedAt?: NativeDate | null | undefined;
|
|
124
124
|
bank?: {
|
|
125
|
-
accountNumber?: string | null | undefined;
|
|
126
|
-
accountName?: string | null | undefined;
|
|
127
125
|
bankName?: string | null | undefined;
|
|
126
|
+
accountNumber?: string | null | undefined;
|
|
128
127
|
branchName?: string | null | undefined;
|
|
129
128
|
routingNumber?: string | null | undefined;
|
|
129
|
+
accountName?: string | null | undefined;
|
|
130
130
|
} | null | undefined;
|
|
131
131
|
} | null | undefined;
|
|
132
|
+
lastLoginAt?: NativeDate | null | undefined;
|
|
132
133
|
profile?: {
|
|
133
134
|
firstName: string;
|
|
134
135
|
lastName: string;
|
|
@@ -160,10 +161,9 @@ declare const userSchema: mongoose.Schema<any, mongoose.Model<any, any, any, any
|
|
|
160
161
|
auth?: {
|
|
161
162
|
provider: "google" | "local";
|
|
162
163
|
password?: string | null | undefined;
|
|
163
|
-
refreshToken?: string | null | undefined;
|
|
164
164
|
googleId?: string | null | undefined;
|
|
165
|
+
refreshToken?: string | null | undefined;
|
|
165
166
|
} | null | undefined;
|
|
166
|
-
lastLoginAt?: NativeDate | null | undefined;
|
|
167
167
|
} & mongoose.DefaultTimestampProps> & {
|
|
168
168
|
_id: mongoose.Types.ObjectId;
|
|
169
169
|
} & {
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import mongoose from "mongoose";
|
|
2
|
+
/**
|
|
3
|
+
* Verification Document Schema
|
|
4
|
+
* Stores uploaded verification documents (NID, licenses, etc.)
|
|
5
|
+
*/
|
|
6
|
+
declare const verificationDocumentSchema: mongoose.Schema<any, mongoose.Model<any, any, any, any, any, any>, {}, {}, {}, {}, {
|
|
7
|
+
timestamps: true;
|
|
8
|
+
}, {
|
|
9
|
+
userId: mongoose.Types.ObjectId;
|
|
10
|
+
status: "pending" | "approved" | "rejected";
|
|
11
|
+
type: "other" | "nid" | "passport" | "trade_license" | "tax_certificate" | "incorporation_cert";
|
|
12
|
+
url: string;
|
|
13
|
+
filename: string;
|
|
14
|
+
expiresAt?: NativeDate | null | undefined;
|
|
15
|
+
rejectionReason?: string | null | undefined;
|
|
16
|
+
reviewedBy?: mongoose.Types.ObjectId | null | undefined;
|
|
17
|
+
reviewedAt?: NativeDate | null | undefined;
|
|
18
|
+
mimeType?: string | null | undefined;
|
|
19
|
+
documentNumber?: string | null | undefined;
|
|
20
|
+
fileSize?: number | null | undefined;
|
|
21
|
+
notes?: string | null | undefined;
|
|
22
|
+
uploadedFrom?: string | null | undefined;
|
|
23
|
+
} & mongoose.DefaultTimestampProps, mongoose.Document<unknown, {}, mongoose.FlatRecord<{
|
|
24
|
+
userId: mongoose.Types.ObjectId;
|
|
25
|
+
status: "pending" | "approved" | "rejected";
|
|
26
|
+
type: "other" | "nid" | "passport" | "trade_license" | "tax_certificate" | "incorporation_cert";
|
|
27
|
+
url: string;
|
|
28
|
+
filename: string;
|
|
29
|
+
expiresAt?: NativeDate | null | undefined;
|
|
30
|
+
rejectionReason?: string | null | undefined;
|
|
31
|
+
reviewedBy?: mongoose.Types.ObjectId | null | undefined;
|
|
32
|
+
reviewedAt?: NativeDate | null | undefined;
|
|
33
|
+
mimeType?: string | null | undefined;
|
|
34
|
+
documentNumber?: string | null | undefined;
|
|
35
|
+
fileSize?: number | null | undefined;
|
|
36
|
+
notes?: string | null | undefined;
|
|
37
|
+
uploadedFrom?: string | null | undefined;
|
|
38
|
+
} & mongoose.DefaultTimestampProps>, {}, mongoose.ResolveSchemaOptions<{
|
|
39
|
+
timestamps: true;
|
|
40
|
+
}>> & mongoose.FlatRecord<{
|
|
41
|
+
userId: mongoose.Types.ObjectId;
|
|
42
|
+
status: "pending" | "approved" | "rejected";
|
|
43
|
+
type: "other" | "nid" | "passport" | "trade_license" | "tax_certificate" | "incorporation_cert";
|
|
44
|
+
url: string;
|
|
45
|
+
filename: string;
|
|
46
|
+
expiresAt?: NativeDate | null | undefined;
|
|
47
|
+
rejectionReason?: string | null | undefined;
|
|
48
|
+
reviewedBy?: mongoose.Types.ObjectId | null | undefined;
|
|
49
|
+
reviewedAt?: NativeDate | null | undefined;
|
|
50
|
+
mimeType?: string | null | undefined;
|
|
51
|
+
documentNumber?: string | null | undefined;
|
|
52
|
+
fileSize?: number | null | undefined;
|
|
53
|
+
notes?: string | null | undefined;
|
|
54
|
+
uploadedFrom?: string | null | undefined;
|
|
55
|
+
} & mongoose.DefaultTimestampProps> & {
|
|
56
|
+
_id: mongoose.Types.ObjectId;
|
|
57
|
+
} & {
|
|
58
|
+
__v: number;
|
|
59
|
+
}>;
|
|
60
|
+
export default verificationDocumentSchema;
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const mongoose_1 = __importDefault(require("mongoose"));
|
|
7
|
+
/**
|
|
8
|
+
* Verification Document Schema
|
|
9
|
+
* Stores uploaded verification documents (NID, licenses, etc.)
|
|
10
|
+
*/
|
|
11
|
+
const verificationDocumentSchema = new mongoose_1.default.Schema({
|
|
12
|
+
userId: {
|
|
13
|
+
type: mongoose_1.default.Schema.Types.ObjectId,
|
|
14
|
+
ref: 'User',
|
|
15
|
+
required: true,
|
|
16
|
+
index: true
|
|
17
|
+
},
|
|
18
|
+
// Document Info
|
|
19
|
+
type: {
|
|
20
|
+
type: String,
|
|
21
|
+
enum: ['nid', 'passport', 'trade_license', 'tax_certificate', 'incorporation_cert', 'other'],
|
|
22
|
+
required: true,
|
|
23
|
+
index: true
|
|
24
|
+
},
|
|
25
|
+
documentNumber: {
|
|
26
|
+
type: String,
|
|
27
|
+
trim: true
|
|
28
|
+
},
|
|
29
|
+
// File
|
|
30
|
+
url: {
|
|
31
|
+
type: String,
|
|
32
|
+
required: true
|
|
33
|
+
},
|
|
34
|
+
filename: {
|
|
35
|
+
type: String,
|
|
36
|
+
required: true
|
|
37
|
+
},
|
|
38
|
+
fileSize: {
|
|
39
|
+
type: Number
|
|
40
|
+
},
|
|
41
|
+
mimeType: {
|
|
42
|
+
type: String
|
|
43
|
+
},
|
|
44
|
+
// Status
|
|
45
|
+
status: {
|
|
46
|
+
type: String,
|
|
47
|
+
enum: ['pending', 'approved', 'rejected'],
|
|
48
|
+
default: 'pending',
|
|
49
|
+
index: true
|
|
50
|
+
},
|
|
51
|
+
// Review
|
|
52
|
+
reviewedAt: {
|
|
53
|
+
type: Date
|
|
54
|
+
},
|
|
55
|
+
reviewedBy: {
|
|
56
|
+
type: mongoose_1.default.Schema.Types.ObjectId,
|
|
57
|
+
ref: 'User'
|
|
58
|
+
},
|
|
59
|
+
rejectionReason: {
|
|
60
|
+
type: String
|
|
61
|
+
},
|
|
62
|
+
notes: {
|
|
63
|
+
type: String
|
|
64
|
+
},
|
|
65
|
+
// Metadata
|
|
66
|
+
expiresAt: {
|
|
67
|
+
type: Date // For documents with expiry (e.g., passport)
|
|
68
|
+
},
|
|
69
|
+
uploadedFrom: {
|
|
70
|
+
type: String // IP address
|
|
71
|
+
}
|
|
72
|
+
}, {
|
|
73
|
+
timestamps: true
|
|
74
|
+
});
|
|
75
|
+
// Indexes
|
|
76
|
+
verificationDocumentSchema.index({ userId: 1, type: 1 });
|
|
77
|
+
verificationDocumentSchema.index({ status: 1, createdAt: -1 });
|
|
78
|
+
verificationDocumentSchema.index({ userId: 1, status: 1 });
|
|
79
|
+
// Compound index for admin queries
|
|
80
|
+
verificationDocumentSchema.index({ status: 1, type: 1, createdAt: -1 });
|
|
81
|
+
// Methods
|
|
82
|
+
verificationDocumentSchema.methods.approve = function (reviewedBy, notes) {
|
|
83
|
+
this.status = 'approved';
|
|
84
|
+
this.reviewedAt = new Date();
|
|
85
|
+
this.reviewedBy = reviewedBy;
|
|
86
|
+
this.rejectionReason = undefined;
|
|
87
|
+
if (notes)
|
|
88
|
+
this.notes = notes;
|
|
89
|
+
return this.save();
|
|
90
|
+
};
|
|
91
|
+
verificationDocumentSchema.methods.reject = function (reviewedBy, reason, notes) {
|
|
92
|
+
this.status = 'rejected';
|
|
93
|
+
this.reviewedAt = new Date();
|
|
94
|
+
this.reviewedBy = reviewedBy;
|
|
95
|
+
this.rejectionReason = reason;
|
|
96
|
+
if (notes)
|
|
97
|
+
this.notes = notes;
|
|
98
|
+
return this.save();
|
|
99
|
+
};
|
|
100
|
+
verificationDocumentSchema.methods.isExpired = function () {
|
|
101
|
+
if (!this.expiresAt)
|
|
102
|
+
return false;
|
|
103
|
+
return this.expiresAt < new Date();
|
|
104
|
+
};
|
|
105
|
+
verificationDocumentSchema.methods.isPending = function () {
|
|
106
|
+
return this.status === 'pending';
|
|
107
|
+
};
|
|
108
|
+
verificationDocumentSchema.methods.isApproved = function () {
|
|
109
|
+
return this.status === 'approved';
|
|
110
|
+
};
|
|
111
|
+
exports.default = verificationDocumentSchema;
|
package/dist/index.d.ts
CHANGED
|
@@ -12,3 +12,8 @@ export { default as reviewSchema } from './Review';
|
|
|
12
12
|
export type { IAuditLog } from './AuditLog';
|
|
13
13
|
export type { IReview } from './Review';
|
|
14
14
|
export { AuditSeverity, AuditCategory, AuditStatus } from './AuditLog';
|
|
15
|
+
export { default as emailVerificationSchema } from './EmailVerification';
|
|
16
|
+
export { default as phoneVerificationSchema } from './PhoneVerification';
|
|
17
|
+
export { default as hostProfileSchema } from './HostProfile';
|
|
18
|
+
export { default as paymentDetailsSchema } from './PaymentDetails';
|
|
19
|
+
export { default as verificationDocumentSchema } from './VerificationDocument';
|
package/dist/index.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.AuditStatus = exports.AuditCategory = exports.AuditSeverity = exports.reviewSchema = exports.auditLogSchema = exports.payoutSchema = exports.eventViewsSchema = exports.userSchema = exports.orderSchema = exports.paymentSchema = exports.bkashSchema = exports.mediaSchema = exports.ticketSchema = exports.eventSchema = void 0;
|
|
6
|
+
exports.verificationDocumentSchema = exports.paymentDetailsSchema = exports.hostProfileSchema = exports.phoneVerificationSchema = exports.emailVerificationSchema = exports.AuditStatus = exports.AuditCategory = exports.AuditSeverity = exports.reviewSchema = exports.auditLogSchema = exports.payoutSchema = exports.eventViewsSchema = exports.userSchema = exports.orderSchema = exports.paymentSchema = exports.bkashSchema = exports.mediaSchema = exports.ticketSchema = exports.eventSchema = void 0;
|
|
7
7
|
// Shared database models for Pinecone microservices
|
|
8
8
|
var Event_1 = require("./Event");
|
|
9
9
|
Object.defineProperty(exports, "eventSchema", { enumerable: true, get: function () { return __importDefault(Event_1).default; } });
|
|
@@ -31,3 +31,14 @@ var AuditLog_2 = require("./AuditLog");
|
|
|
31
31
|
Object.defineProperty(exports, "AuditSeverity", { enumerable: true, get: function () { return AuditLog_2.AuditSeverity; } });
|
|
32
32
|
Object.defineProperty(exports, "AuditCategory", { enumerable: true, get: function () { return AuditLog_2.AuditCategory; } });
|
|
33
33
|
Object.defineProperty(exports, "AuditStatus", { enumerable: true, get: function () { return AuditLog_2.AuditStatus; } });
|
|
34
|
+
// New schemas for refactored architecture
|
|
35
|
+
var EmailVerification_1 = require("./EmailVerification");
|
|
36
|
+
Object.defineProperty(exports, "emailVerificationSchema", { enumerable: true, get: function () { return __importDefault(EmailVerification_1).default; } });
|
|
37
|
+
var PhoneVerification_1 = require("./PhoneVerification");
|
|
38
|
+
Object.defineProperty(exports, "phoneVerificationSchema", { enumerable: true, get: function () { return __importDefault(PhoneVerification_1).default; } });
|
|
39
|
+
var HostProfile_1 = require("./HostProfile");
|
|
40
|
+
Object.defineProperty(exports, "hostProfileSchema", { enumerable: true, get: function () { return __importDefault(HostProfile_1).default; } });
|
|
41
|
+
var PaymentDetails_1 = require("./PaymentDetails");
|
|
42
|
+
Object.defineProperty(exports, "paymentDetailsSchema", { enumerable: true, get: function () { return __importDefault(PaymentDetails_1).default; } });
|
|
43
|
+
var VerificationDocument_1 = require("./VerificationDocument");
|
|
44
|
+
Object.defineProperty(exports, "verificationDocumentSchema", { enumerable: true, get: function () { return __importDefault(VerificationDocument_1).default; } });
|