@mac777/project-pinecone-models 1.1.23 → 1.1.24

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/Payout.d.ts CHANGED
@@ -18,6 +18,10 @@ declare const payoutSchema: mongoose.Schema<any, mongoose.Model<any, any, any, a
18
18
  platformFee?: number | null | undefined;
19
19
  refundAmount?: number | null | undefined;
20
20
  failedAt?: NativeDate | null | undefined;
21
+ bankName?: string | null | undefined;
22
+ accountNumber?: string | null | undefined;
23
+ branchName?: string | null | undefined;
24
+ routingNumber?: string | null | undefined;
21
25
  grossRevenue?: number | null | undefined;
22
26
  netPayout?: number | null | undefined;
23
27
  totalOrders?: number | null | undefined;
@@ -28,11 +32,7 @@ declare const payoutSchema: mongoose.Schema<any, mongoose.Model<any, any, any, a
28
32
  approvedAt?: NativeDate | null | undefined;
29
33
  rejectedBy?: mongoose.Types.ObjectId | null | undefined;
30
34
  rejectedAt?: NativeDate | null | undefined;
31
- accountNumber?: string | null | undefined;
32
35
  accountName?: string | null | undefined;
33
- bankName?: string | null | undefined;
34
- branchName?: string | null | undefined;
35
- routingNumber?: string | null | undefined;
36
36
  initiatedAt?: NativeDate | null | undefined;
37
37
  completedAt?: NativeDate | null | undefined;
38
38
  transactionId?: string | null | undefined;
@@ -56,6 +56,10 @@ declare const payoutSchema: mongoose.Schema<any, mongoose.Model<any, any, any, a
56
56
  platformFee?: number | null | undefined;
57
57
  refundAmount?: number | null | undefined;
58
58
  failedAt?: NativeDate | null | undefined;
59
+ bankName?: string | null | undefined;
60
+ accountNumber?: string | null | undefined;
61
+ branchName?: string | null | undefined;
62
+ routingNumber?: string | null | undefined;
59
63
  grossRevenue?: number | null | undefined;
60
64
  netPayout?: number | null | undefined;
61
65
  totalOrders?: number | null | undefined;
@@ -66,11 +70,7 @@ declare const payoutSchema: mongoose.Schema<any, mongoose.Model<any, any, any, a
66
70
  approvedAt?: NativeDate | null | undefined;
67
71
  rejectedBy?: mongoose.Types.ObjectId | null | undefined;
68
72
  rejectedAt?: NativeDate | null | undefined;
69
- accountNumber?: string | null | undefined;
70
73
  accountName?: string | null | undefined;
71
- bankName?: string | null | undefined;
72
- branchName?: string | null | undefined;
73
- routingNumber?: string | null | undefined;
74
74
  initiatedAt?: NativeDate | null | undefined;
75
75
  completedAt?: NativeDate | null | undefined;
76
76
  transactionId?: string | null | undefined;
@@ -96,6 +96,10 @@ declare const payoutSchema: mongoose.Schema<any, mongoose.Model<any, any, any, a
96
96
  platformFee?: number | null | undefined;
97
97
  refundAmount?: number | null | undefined;
98
98
  failedAt?: NativeDate | null | undefined;
99
+ bankName?: string | null | undefined;
100
+ accountNumber?: string | null | undefined;
101
+ branchName?: string | null | undefined;
102
+ routingNumber?: string | null | undefined;
99
103
  grossRevenue?: number | null | undefined;
100
104
  netPayout?: number | null | undefined;
101
105
  totalOrders?: number | null | undefined;
@@ -106,11 +110,7 @@ declare const payoutSchema: mongoose.Schema<any, mongoose.Model<any, any, any, a
106
110
  approvedAt?: NativeDate | null | undefined;
107
111
  rejectedBy?: mongoose.Types.ObjectId | null | undefined;
108
112
  rejectedAt?: NativeDate | null | undefined;
109
- accountNumber?: string | null | undefined;
110
113
  accountName?: string | null | undefined;
111
- bankName?: string | null | undefined;
112
- branchName?: string | null | undefined;
113
- routingNumber?: string | null | undefined;
114
114
  initiatedAt?: NativeDate | null | undefined;
115
115
  completedAt?: NativeDate | null | undefined;
116
116
  transactionId?: string | null | undefined;
@@ -0,0 +1,54 @@
1
+ import mongoose from "mongoose";
2
+ /**
3
+ * Phone Verification Schema
4
+ * Handles OTP generation, verification, and rate limiting
5
+ */
6
+ declare const phoneVerificationSchema: mongoose.Schema<any, mongoose.Model<any, any, any, any, any, any>, {}, {}, {}, {}, {
7
+ timestamps: true;
8
+ }, {
9
+ userId: mongoose.Types.ObjectId;
10
+ expiresAt: NativeDate;
11
+ verified: boolean;
12
+ attempts: number;
13
+ phoneNumber: string;
14
+ otp: string;
15
+ maxAttempts: number;
16
+ sentCount: number;
17
+ lastSentAt: NativeDate;
18
+ verifiedAt?: NativeDate | null | undefined;
19
+ lastAttemptAt?: NativeDate | null | undefined;
20
+ sentFrom?: string | null | undefined;
21
+ } & mongoose.DefaultTimestampProps, mongoose.Document<unknown, {}, mongoose.FlatRecord<{
22
+ userId: mongoose.Types.ObjectId;
23
+ expiresAt: NativeDate;
24
+ verified: boolean;
25
+ attempts: number;
26
+ phoneNumber: string;
27
+ otp: string;
28
+ maxAttempts: number;
29
+ sentCount: number;
30
+ lastSentAt: NativeDate;
31
+ verifiedAt?: NativeDate | null | undefined;
32
+ lastAttemptAt?: NativeDate | null | undefined;
33
+ sentFrom?: string | null | undefined;
34
+ } & mongoose.DefaultTimestampProps>, {}, mongoose.ResolveSchemaOptions<{
35
+ timestamps: true;
36
+ }>> & mongoose.FlatRecord<{
37
+ userId: mongoose.Types.ObjectId;
38
+ expiresAt: NativeDate;
39
+ verified: boolean;
40
+ attempts: number;
41
+ phoneNumber: string;
42
+ otp: string;
43
+ maxAttempts: number;
44
+ sentCount: number;
45
+ lastSentAt: NativeDate;
46
+ verifiedAt?: NativeDate | null | undefined;
47
+ lastAttemptAt?: NativeDate | null | undefined;
48
+ sentFrom?: string | null | undefined;
49
+ } & mongoose.DefaultTimestampProps> & {
50
+ _id: mongoose.Types.ObjectId;
51
+ } & {
52
+ __v: number;
53
+ }>;
54
+ export default phoneVerificationSchema;
@@ -0,0 +1,91 @@
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
+ * Phone Verification Schema
9
+ * Handles OTP generation, verification, and rate limiting
10
+ */
11
+ const phoneVerificationSchema = 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
+ phoneNumber: {
19
+ type: String,
20
+ required: true,
21
+ trim: true
22
+ },
23
+ otp: {
24
+ type: String,
25
+ required: true
26
+ },
27
+ expiresAt: {
28
+ type: Date,
29
+ required: true,
30
+ index: true
31
+ },
32
+ verified: {
33
+ type: Boolean,
34
+ default: false
35
+ },
36
+ verifiedAt: {
37
+ type: Date
38
+ },
39
+ // Attempt tracking (security)
40
+ attempts: {
41
+ type: Number,
42
+ default: 0
43
+ },
44
+ lastAttemptAt: {
45
+ type: Date
46
+ },
47
+ maxAttempts: {
48
+ type: Number,
49
+ default: 5
50
+ },
51
+ // Rate limiting
52
+ sentCount: {
53
+ type: Number,
54
+ default: 1
55
+ },
56
+ lastSentAt: {
57
+ type: Date,
58
+ default: Date.now
59
+ },
60
+ // Metadata
61
+ sentFrom: {
62
+ type: String // IP address
63
+ }
64
+ }, {
65
+ timestamps: true
66
+ });
67
+ // Indexes
68
+ phoneVerificationSchema.index({ userId: 1, phoneNumber: 1 });
69
+ phoneVerificationSchema.index({ userId: 1, verified: 1 });
70
+ phoneVerificationSchema.index({ phoneNumber: 1, verified: 1 });
71
+ // TTL Index: Auto-delete expired OTPs after they expire
72
+ phoneVerificationSchema.index({ expiresAt: 1 }, { expireAfterSeconds: 0 });
73
+ // Methods
74
+ phoneVerificationSchema.methods.isExpired = function () {
75
+ return this.expiresAt < new Date();
76
+ };
77
+ phoneVerificationSchema.methods.isMaxAttemptsReached = function () {
78
+ return this.attempts >= this.maxAttempts;
79
+ };
80
+ phoneVerificationSchema.methods.incrementAttempts = function () {
81
+ this.attempts += 1;
82
+ this.lastAttemptAt = new Date();
83
+ return this.save();
84
+ };
85
+ phoneVerificationSchema.methods.canResend = function (cooldownSeconds = 60) {
86
+ if (!this.lastSentAt)
87
+ return true;
88
+ const cooldownMs = cooldownSeconds * 1000;
89
+ return Date.now() - this.lastSentAt.getTime() > cooldownMs;
90
+ };
91
+ exports.default = phoneVerificationSchema;
package/dist/User.d.ts CHANGED
@@ -1,236 +1,93 @@
1
1
  import mongoose from "mongoose";
2
+ /**
3
+ * User Schema (Refactored)
4
+ * Core identity and authentication only
5
+ * Related data moved to separate collections:
6
+ * - HostProfile
7
+ * - PaymentDetails
8
+ * - VerificationDocument
9
+ * - EmailVerification
10
+ * - PhoneVerification
11
+ */
2
12
  declare const userSchema: mongoose.Schema<any, mongoose.Model<any, any, any, any, any, any>, {}, {}, {}, {}, {
3
13
  timestamps: true;
14
+ toJSON: {
15
+ virtuals: true;
16
+ };
17
+ toObject: {
18
+ virtuals: true;
19
+ };
4
20
  }, {
5
21
  email: string;
6
22
  role: "user" | "host" | "admin";
7
- provider: "google" | "local";
23
+ provider: "facebook" | "google" | "local";
8
24
  firstName: string;
9
25
  lastName: string;
10
26
  emailVerified: boolean;
11
27
  phoneVerified: boolean;
28
+ isSuspended: boolean;
12
29
  nidVerified: boolean;
13
- verification?: {
14
- status: "pending" | "rejected" | "unverified" | "verified";
15
- documents: mongoose.Types.DocumentArray<{
16
- type: "other" | "nid" | "trade_license" | "tax_certificate";
17
- url: string;
18
- filename: string;
19
- uploadedAt: NativeDate;
20
- }, mongoose.Types.Subdocument<mongoose.mongo.BSON.ObjectId, any, {
21
- type: "other" | "nid" | "trade_license" | "tax_certificate";
22
- url: string;
23
- filename: string;
24
- uploadedAt: NativeDate;
25
- }> & {
26
- type: "other" | "nid" | "trade_license" | "tax_certificate";
27
- url: string;
28
- filename: string;
29
- uploadedAt: NativeDate;
30
- }>;
31
- rejectionReason?: string | null | undefined;
32
- reviewedBy?: mongoose.Types.ObjectId | null | undefined;
33
- reviewedAt?: NativeDate | null | undefined;
34
- submittedAt?: NativeDate | null | undefined;
35
- } | null | undefined;
36
- moderation?: {
37
- isSuspended: boolean;
38
- isVerified: boolean;
39
- suspendedAt?: NativeDate | null | undefined;
40
- suspensionReason?: string | null | undefined;
41
- verifiedAt?: NativeDate | null | undefined;
42
- } | null | undefined;
30
+ suspendedAt?: NativeDate | null | undefined;
31
+ suspensionReason?: string | null | undefined;
32
+ phoneNumber?: string | null | undefined;
43
33
  password?: string | null | undefined;
34
+ googleId?: string | null | undefined;
35
+ refreshToken?: string | null | undefined;
36
+ suspendedBy?: mongoose.Types.ObjectId | null | undefined;
44
37
  organization?: string | null | undefined;
45
- emailVerificationToken?: string | null | undefined;
46
- emailVerificationExpires?: NativeDate | null | undefined;
47
- phoneNumber?: string | null | undefined;
48
- phoneVerificationToken?: string | null | undefined;
49
- phoneVerificationExpires?: NativeDate | null | undefined;
50
38
  nidNumber?: string | null | undefined;
51
- paymentDetails?: {
52
- method: "bkash" | "bank_transfer";
53
- verified: boolean;
54
- accountNumber?: string | null | undefined;
55
- accountName?: string | null | undefined;
56
- bankName?: string | null | undefined;
57
- branchName?: string | null | undefined;
58
- routingNumber?: string | null | undefined;
59
- verifiedAt?: NativeDate | null | undefined;
60
- bkashNumber?: string | null | undefined;
61
- } | null | undefined;
62
- refreshToken?: string | null | undefined;
63
- googleId?: string | null | undefined;
64
- hostProfile?: {
65
- contactPerson?: {
66
- name?: string | null | undefined;
67
- designation?: string | null | undefined;
68
- phone?: string | null | undefined;
69
- email?: string | null | undefined;
70
- } | null | undefined;
71
- role?: "event_organizer" | "venue_owner" | "authorized_rep" | "artist" | null | undefined;
72
- organizationName?: string | null | undefined;
73
- } | null | undefined;
74
- profileCompleteness?: {
75
- hasContactInfo: boolean;
76
- hasPaymentDetails: boolean;
77
- hasVerificationDocs: boolean;
78
- isComplete: boolean;
79
- } | null | undefined;
39
+ lastLoginAt?: NativeDate | null | undefined;
40
+ lastLoginIP?: string | null | undefined;
80
41
  } & mongoose.DefaultTimestampProps, mongoose.Document<unknown, {}, mongoose.FlatRecord<{
81
42
  email: string;
82
43
  role: "user" | "host" | "admin";
83
- provider: "google" | "local";
44
+ provider: "facebook" | "google" | "local";
84
45
  firstName: string;
85
46
  lastName: string;
86
47
  emailVerified: boolean;
87
48
  phoneVerified: boolean;
49
+ isSuspended: boolean;
88
50
  nidVerified: boolean;
89
- verification?: {
90
- status: "pending" | "rejected" | "unverified" | "verified";
91
- documents: mongoose.Types.DocumentArray<{
92
- type: "other" | "nid" | "trade_license" | "tax_certificate";
93
- url: string;
94
- filename: string;
95
- uploadedAt: NativeDate;
96
- }, mongoose.Types.Subdocument<mongoose.mongo.BSON.ObjectId, any, {
97
- type: "other" | "nid" | "trade_license" | "tax_certificate";
98
- url: string;
99
- filename: string;
100
- uploadedAt: NativeDate;
101
- }> & {
102
- type: "other" | "nid" | "trade_license" | "tax_certificate";
103
- url: string;
104
- filename: string;
105
- uploadedAt: NativeDate;
106
- }>;
107
- rejectionReason?: string | null | undefined;
108
- reviewedBy?: mongoose.Types.ObjectId | null | undefined;
109
- reviewedAt?: NativeDate | null | undefined;
110
- submittedAt?: NativeDate | null | undefined;
111
- } | null | undefined;
112
- moderation?: {
113
- isSuspended: boolean;
114
- isVerified: boolean;
115
- suspendedAt?: NativeDate | null | undefined;
116
- suspensionReason?: string | null | undefined;
117
- verifiedAt?: NativeDate | null | undefined;
118
- } | null | undefined;
51
+ suspendedAt?: NativeDate | null | undefined;
52
+ suspensionReason?: string | null | undefined;
53
+ phoneNumber?: string | null | undefined;
119
54
  password?: string | null | undefined;
55
+ googleId?: string | null | undefined;
56
+ refreshToken?: string | null | undefined;
57
+ suspendedBy?: mongoose.Types.ObjectId | null | undefined;
120
58
  organization?: string | null | undefined;
121
- emailVerificationToken?: string | null | undefined;
122
- emailVerificationExpires?: NativeDate | null | undefined;
123
- phoneNumber?: string | null | undefined;
124
- phoneVerificationToken?: string | null | undefined;
125
- phoneVerificationExpires?: NativeDate | null | undefined;
126
59
  nidNumber?: string | null | undefined;
127
- paymentDetails?: {
128
- method: "bkash" | "bank_transfer";
129
- verified: boolean;
130
- accountNumber?: string | null | undefined;
131
- accountName?: string | null | undefined;
132
- bankName?: string | null | undefined;
133
- branchName?: string | null | undefined;
134
- routingNumber?: string | null | undefined;
135
- verifiedAt?: NativeDate | null | undefined;
136
- bkashNumber?: string | null | undefined;
137
- } | null | undefined;
138
- refreshToken?: string | null | undefined;
139
- googleId?: string | null | undefined;
140
- hostProfile?: {
141
- contactPerson?: {
142
- name?: string | null | undefined;
143
- designation?: string | null | undefined;
144
- phone?: string | null | undefined;
145
- email?: string | null | undefined;
146
- } | null | undefined;
147
- role?: "event_organizer" | "venue_owner" | "authorized_rep" | "artist" | null | undefined;
148
- organizationName?: string | null | undefined;
149
- } | null | undefined;
150
- profileCompleteness?: {
151
- hasContactInfo: boolean;
152
- hasPaymentDetails: boolean;
153
- hasVerificationDocs: boolean;
154
- isComplete: boolean;
155
- } | null | undefined;
60
+ lastLoginAt?: NativeDate | null | undefined;
61
+ lastLoginIP?: string | null | undefined;
156
62
  } & mongoose.DefaultTimestampProps>, {}, mongoose.ResolveSchemaOptions<{
157
63
  timestamps: true;
64
+ toJSON: {
65
+ virtuals: true;
66
+ };
67
+ toObject: {
68
+ virtuals: true;
69
+ };
158
70
  }>> & mongoose.FlatRecord<{
159
71
  email: string;
160
72
  role: "user" | "host" | "admin";
161
- provider: "google" | "local";
73
+ provider: "facebook" | "google" | "local";
162
74
  firstName: string;
163
75
  lastName: string;
164
76
  emailVerified: boolean;
165
77
  phoneVerified: boolean;
78
+ isSuspended: boolean;
166
79
  nidVerified: boolean;
167
- verification?: {
168
- status: "pending" | "rejected" | "unverified" | "verified";
169
- documents: mongoose.Types.DocumentArray<{
170
- type: "other" | "nid" | "trade_license" | "tax_certificate";
171
- url: string;
172
- filename: string;
173
- uploadedAt: NativeDate;
174
- }, mongoose.Types.Subdocument<mongoose.mongo.BSON.ObjectId, any, {
175
- type: "other" | "nid" | "trade_license" | "tax_certificate";
176
- url: string;
177
- filename: string;
178
- uploadedAt: NativeDate;
179
- }> & {
180
- type: "other" | "nid" | "trade_license" | "tax_certificate";
181
- url: string;
182
- filename: string;
183
- uploadedAt: NativeDate;
184
- }>;
185
- rejectionReason?: string | null | undefined;
186
- reviewedBy?: mongoose.Types.ObjectId | null | undefined;
187
- reviewedAt?: NativeDate | null | undefined;
188
- submittedAt?: NativeDate | null | undefined;
189
- } | null | undefined;
190
- moderation?: {
191
- isSuspended: boolean;
192
- isVerified: boolean;
193
- suspendedAt?: NativeDate | null | undefined;
194
- suspensionReason?: string | null | undefined;
195
- verifiedAt?: NativeDate | null | undefined;
196
- } | null | undefined;
80
+ suspendedAt?: NativeDate | null | undefined;
81
+ suspensionReason?: string | null | undefined;
82
+ phoneNumber?: string | null | undefined;
197
83
  password?: string | null | undefined;
84
+ googleId?: string | null | undefined;
85
+ refreshToken?: string | null | undefined;
86
+ suspendedBy?: mongoose.Types.ObjectId | null | undefined;
198
87
  organization?: string | null | undefined;
199
- emailVerificationToken?: string | null | undefined;
200
- emailVerificationExpires?: NativeDate | null | undefined;
201
- phoneNumber?: string | null | undefined;
202
- phoneVerificationToken?: string | null | undefined;
203
- phoneVerificationExpires?: NativeDate | null | undefined;
204
88
  nidNumber?: string | null | undefined;
205
- paymentDetails?: {
206
- method: "bkash" | "bank_transfer";
207
- verified: boolean;
208
- accountNumber?: string | null | undefined;
209
- accountName?: string | null | undefined;
210
- bankName?: string | null | undefined;
211
- branchName?: string | null | undefined;
212
- routingNumber?: string | null | undefined;
213
- verifiedAt?: NativeDate | null | undefined;
214
- bkashNumber?: string | null | undefined;
215
- } | null | undefined;
216
- refreshToken?: string | null | undefined;
217
- googleId?: string | null | undefined;
218
- hostProfile?: {
219
- contactPerson?: {
220
- name?: string | null | undefined;
221
- designation?: string | null | undefined;
222
- phone?: string | null | undefined;
223
- email?: string | null | undefined;
224
- } | null | undefined;
225
- role?: "event_organizer" | "venue_owner" | "authorized_rep" | "artist" | null | undefined;
226
- organizationName?: string | null | undefined;
227
- } | null | undefined;
228
- profileCompleteness?: {
229
- hasContactInfo: boolean;
230
- hasPaymentDetails: boolean;
231
- hasVerificationDocs: boolean;
232
- isComplete: boolean;
233
- } | null | undefined;
89
+ lastLoginAt?: NativeDate | null | undefined;
90
+ lastLoginIP?: string | null | undefined;
234
91
  } & mongoose.DefaultTimestampProps> & {
235
92
  _id: mongoose.Types.ObjectId;
236
93
  } & {