@mac777/project-pinecone-models 1.1.22 → 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/EmailVerification.d.ts +45 -0
- package/dist/EmailVerification.js +70 -0
- package/dist/Event.d.ts +9 -9
- package/dist/Event.js +40 -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/Review.d.ts +38 -0
- package/dist/Review.js +200 -0
- package/dist/Ticket.d.ts +3 -3
- 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 +7 -0
- package/dist/index.js +14 -1
- package/package.json +1 -1
- package/src/EmailVerification.ts +71 -0
- package/src/Event.ts +93 -3
- package/src/HostProfile.ts +145 -0
- package/src/PaymentDetails.ts +127 -0
- package/src/PhoneVerification.ts +93 -0
- package/src/Review.ts +268 -0
- package/src/User.ts +95 -201
- package/src/VerificationDocument.ts +117 -0
- package/src/index.ts +10 -1
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import mongoose from "mongoose";
|
|
2
|
+
/**
|
|
3
|
+
* Email Verification Schema
|
|
4
|
+
* Handles email verification tokens and tracking
|
|
5
|
+
*/
|
|
6
|
+
declare const emailVerificationSchema: mongoose.Schema<any, mongoose.Model<any, any, any, any, any, any>, {}, {}, {}, {}, {
|
|
7
|
+
timestamps: true;
|
|
8
|
+
}, {
|
|
9
|
+
userId: mongoose.Types.ObjectId;
|
|
10
|
+
expiresAt: NativeDate;
|
|
11
|
+
email: string;
|
|
12
|
+
token: string;
|
|
13
|
+
verified: boolean;
|
|
14
|
+
attempts: number;
|
|
15
|
+
verifiedAt?: NativeDate | null | undefined;
|
|
16
|
+
lastAttemptAt?: NativeDate | null | undefined;
|
|
17
|
+
sentFrom?: string | null | undefined;
|
|
18
|
+
} & mongoose.DefaultTimestampProps, mongoose.Document<unknown, {}, mongoose.FlatRecord<{
|
|
19
|
+
userId: mongoose.Types.ObjectId;
|
|
20
|
+
expiresAt: NativeDate;
|
|
21
|
+
email: string;
|
|
22
|
+
token: string;
|
|
23
|
+
verified: boolean;
|
|
24
|
+
attempts: number;
|
|
25
|
+
verifiedAt?: NativeDate | null | undefined;
|
|
26
|
+
lastAttemptAt?: NativeDate | null | undefined;
|
|
27
|
+
sentFrom?: string | null | undefined;
|
|
28
|
+
} & mongoose.DefaultTimestampProps>, {}, mongoose.ResolveSchemaOptions<{
|
|
29
|
+
timestamps: true;
|
|
30
|
+
}>> & mongoose.FlatRecord<{
|
|
31
|
+
userId: mongoose.Types.ObjectId;
|
|
32
|
+
expiresAt: NativeDate;
|
|
33
|
+
email: string;
|
|
34
|
+
token: string;
|
|
35
|
+
verified: boolean;
|
|
36
|
+
attempts: number;
|
|
37
|
+
verifiedAt?: NativeDate | null | undefined;
|
|
38
|
+
lastAttemptAt?: NativeDate | null | undefined;
|
|
39
|
+
sentFrom?: string | null | undefined;
|
|
40
|
+
} & mongoose.DefaultTimestampProps> & {
|
|
41
|
+
_id: mongoose.Types.ObjectId;
|
|
42
|
+
} & {
|
|
43
|
+
__v: number;
|
|
44
|
+
}>;
|
|
45
|
+
export default emailVerificationSchema;
|
|
@@ -0,0 +1,70 @@
|
|
|
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
|
+
* Email Verification Schema
|
|
9
|
+
* Handles email verification tokens and tracking
|
|
10
|
+
*/
|
|
11
|
+
const emailVerificationSchema = 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
|
+
email: {
|
|
19
|
+
type: String,
|
|
20
|
+
required: true,
|
|
21
|
+
lowercase: true,
|
|
22
|
+
trim: true
|
|
23
|
+
},
|
|
24
|
+
token: {
|
|
25
|
+
type: String,
|
|
26
|
+
required: true,
|
|
27
|
+
unique: true,
|
|
28
|
+
index: true
|
|
29
|
+
},
|
|
30
|
+
expiresAt: {
|
|
31
|
+
type: Date,
|
|
32
|
+
required: true,
|
|
33
|
+
index: true
|
|
34
|
+
},
|
|
35
|
+
verified: {
|
|
36
|
+
type: Boolean,
|
|
37
|
+
default: false
|
|
38
|
+
},
|
|
39
|
+
verifiedAt: {
|
|
40
|
+
type: Date
|
|
41
|
+
},
|
|
42
|
+
attempts: {
|
|
43
|
+
type: Number,
|
|
44
|
+
default: 0
|
|
45
|
+
},
|
|
46
|
+
lastAttemptAt: {
|
|
47
|
+
type: Date
|
|
48
|
+
},
|
|
49
|
+
// Metadata
|
|
50
|
+
sentFrom: {
|
|
51
|
+
type: String // IP address
|
|
52
|
+
}
|
|
53
|
+
}, {
|
|
54
|
+
timestamps: true
|
|
55
|
+
});
|
|
56
|
+
// Indexes
|
|
57
|
+
emailVerificationSchema.index({ userId: 1, verified: 1 });
|
|
58
|
+
emailVerificationSchema.index({ token: 1, verified: 1 });
|
|
59
|
+
// TTL Index: Auto-delete expired tokens after they expire
|
|
60
|
+
emailVerificationSchema.index({ expiresAt: 1 }, { expireAfterSeconds: 0 });
|
|
61
|
+
// Methods
|
|
62
|
+
emailVerificationSchema.methods.isExpired = function () {
|
|
63
|
+
return this.expiresAt < new Date();
|
|
64
|
+
};
|
|
65
|
+
emailVerificationSchema.methods.incrementAttempts = function () {
|
|
66
|
+
this.attempts += 1;
|
|
67
|
+
this.lastAttemptAt = new Date();
|
|
68
|
+
return this.save();
|
|
69
|
+
};
|
|
70
|
+
exports.default = emailVerificationSchema;
|
package/dist/Event.d.ts
CHANGED
|
@@ -123,7 +123,6 @@ declare const eventSchema: mongoose.Schema<any, mongoose.Model<any, any, any, an
|
|
|
123
123
|
}>;
|
|
124
124
|
description?: string | null | undefined;
|
|
125
125
|
rejectionReason?: string | null | undefined;
|
|
126
|
-
slug?: string | null | undefined;
|
|
127
126
|
dressCode?: string | null | undefined;
|
|
128
127
|
payoutSkipReason?: string | null | undefined;
|
|
129
128
|
media?: {
|
|
@@ -192,14 +191,14 @@ declare const eventSchema: mongoose.Schema<any, mongoose.Model<any, any, any, an
|
|
|
192
191
|
companyName?: string | null | undefined;
|
|
193
192
|
contactPerson?: {
|
|
194
193
|
name: string;
|
|
195
|
-
phone: string;
|
|
196
194
|
email: string;
|
|
195
|
+
phone: string;
|
|
197
196
|
designation?: string | null | undefined;
|
|
198
197
|
} | null | undefined;
|
|
199
198
|
role?: "event_organizer" | "venue_owner" | "authorized_rep" | "artist" | null | undefined;
|
|
200
199
|
} | null | undefined;
|
|
201
200
|
verification?: {
|
|
202
|
-
status: "
|
|
201
|
+
status: "verified" | "pending" | "rejected" | "unverified" | "needs_info";
|
|
203
202
|
documents: mongoose.Types.DocumentArray<{
|
|
204
203
|
status?: "pending" | "approved" | "rejected" | null | undefined;
|
|
205
204
|
type?: "venue_booking" | "permit" | "insurance" | "license" | "portfolio" | "additional_docs" | "other" | null | undefined;
|
|
@@ -306,6 +305,7 @@ declare const eventSchema: mongoose.Schema<any, mongoose.Model<any, any, any, an
|
|
|
306
305
|
} | null | undefined;
|
|
307
306
|
submittedAt?: NativeDate | null | undefined;
|
|
308
307
|
deletedAt?: NativeDate | null | undefined;
|
|
308
|
+
slug?: string | null | undefined;
|
|
309
309
|
tagline?: string | null | undefined;
|
|
310
310
|
ageRestriction?: "all_ages" | "18+" | "21+" | null | undefined;
|
|
311
311
|
}, mongoose.Document<unknown, {}, mongoose.FlatRecord<{
|
|
@@ -432,7 +432,6 @@ declare const eventSchema: mongoose.Schema<any, mongoose.Model<any, any, any, an
|
|
|
432
432
|
}>;
|
|
433
433
|
description?: string | null | undefined;
|
|
434
434
|
rejectionReason?: string | null | undefined;
|
|
435
|
-
slug?: string | null | undefined;
|
|
436
435
|
dressCode?: string | null | undefined;
|
|
437
436
|
payoutSkipReason?: string | null | undefined;
|
|
438
437
|
media?: {
|
|
@@ -501,14 +500,14 @@ declare const eventSchema: mongoose.Schema<any, mongoose.Model<any, any, any, an
|
|
|
501
500
|
companyName?: string | null | undefined;
|
|
502
501
|
contactPerson?: {
|
|
503
502
|
name: string;
|
|
504
|
-
phone: string;
|
|
505
503
|
email: string;
|
|
504
|
+
phone: string;
|
|
506
505
|
designation?: string | null | undefined;
|
|
507
506
|
} | null | undefined;
|
|
508
507
|
role?: "event_organizer" | "venue_owner" | "authorized_rep" | "artist" | null | undefined;
|
|
509
508
|
} | null | undefined;
|
|
510
509
|
verification?: {
|
|
511
|
-
status: "
|
|
510
|
+
status: "verified" | "pending" | "rejected" | "unverified" | "needs_info";
|
|
512
511
|
documents: mongoose.Types.DocumentArray<{
|
|
513
512
|
status?: "pending" | "approved" | "rejected" | null | undefined;
|
|
514
513
|
type?: "venue_booking" | "permit" | "insurance" | "license" | "portfolio" | "additional_docs" | "other" | null | undefined;
|
|
@@ -615,6 +614,7 @@ declare const eventSchema: mongoose.Schema<any, mongoose.Model<any, any, any, an
|
|
|
615
614
|
} | null | undefined;
|
|
616
615
|
submittedAt?: NativeDate | null | undefined;
|
|
617
616
|
deletedAt?: NativeDate | null | undefined;
|
|
617
|
+
slug?: string | null | undefined;
|
|
618
618
|
tagline?: string | null | undefined;
|
|
619
619
|
ageRestriction?: "all_ages" | "18+" | "21+" | null | undefined;
|
|
620
620
|
}>, {}, mongoose.ResolveSchemaOptions<mongoose.DefaultSchemaOptions>> & mongoose.FlatRecord<{
|
|
@@ -741,7 +741,6 @@ declare const eventSchema: mongoose.Schema<any, mongoose.Model<any, any, any, an
|
|
|
741
741
|
}>;
|
|
742
742
|
description?: string | null | undefined;
|
|
743
743
|
rejectionReason?: string | null | undefined;
|
|
744
|
-
slug?: string | null | undefined;
|
|
745
744
|
dressCode?: string | null | undefined;
|
|
746
745
|
payoutSkipReason?: string | null | undefined;
|
|
747
746
|
media?: {
|
|
@@ -810,14 +809,14 @@ declare const eventSchema: mongoose.Schema<any, mongoose.Model<any, any, any, an
|
|
|
810
809
|
companyName?: string | null | undefined;
|
|
811
810
|
contactPerson?: {
|
|
812
811
|
name: string;
|
|
813
|
-
phone: string;
|
|
814
812
|
email: string;
|
|
813
|
+
phone: string;
|
|
815
814
|
designation?: string | null | undefined;
|
|
816
815
|
} | null | undefined;
|
|
817
816
|
role?: "event_organizer" | "venue_owner" | "authorized_rep" | "artist" | null | undefined;
|
|
818
817
|
} | null | undefined;
|
|
819
818
|
verification?: {
|
|
820
|
-
status: "
|
|
819
|
+
status: "verified" | "pending" | "rejected" | "unverified" | "needs_info";
|
|
821
820
|
documents: mongoose.Types.DocumentArray<{
|
|
822
821
|
status?: "pending" | "approved" | "rejected" | null | undefined;
|
|
823
822
|
type?: "venue_booking" | "permit" | "insurance" | "license" | "portfolio" | "additional_docs" | "other" | null | undefined;
|
|
@@ -924,6 +923,7 @@ declare const eventSchema: mongoose.Schema<any, mongoose.Model<any, any, any, an
|
|
|
924
923
|
} | null | undefined;
|
|
925
924
|
submittedAt?: NativeDate | null | undefined;
|
|
926
925
|
deletedAt?: NativeDate | null | undefined;
|
|
926
|
+
slug?: string | null | undefined;
|
|
927
927
|
tagline?: string | null | undefined;
|
|
928
928
|
ageRestriction?: "all_ages" | "18+" | "21+" | null | undefined;
|
|
929
929
|
}> & {
|
package/dist/Event.js
CHANGED
|
@@ -193,7 +193,13 @@ const historySchema = new mongoose_1.default.Schema({
|
|
|
193
193
|
}, { _id: false });
|
|
194
194
|
const eventSchema = new mongoose_1.default.Schema({
|
|
195
195
|
hostId: { type: mongoose_1.default.Schema.Types.ObjectId, ref: 'User', required: true },
|
|
196
|
-
slug:
|
|
196
|
+
slug: {
|
|
197
|
+
type: String,
|
|
198
|
+
unique: true,
|
|
199
|
+
sparse: true, // Allow null values but ensure uniqueness when present
|
|
200
|
+
lowercase: true,
|
|
201
|
+
trim: true
|
|
202
|
+
},
|
|
197
203
|
// STEP 1: BASICS
|
|
198
204
|
title: { type: String, required: true, minlength: 10, maxlength: 100 },
|
|
199
205
|
type: { type: String, enum: ['concert', 'sports', 'conference', 'festival', 'theater', 'comedy', 'networking', 'workshop', 'other'], required: true },
|
|
@@ -276,8 +282,39 @@ eventSchema.pre('save', function (next) {
|
|
|
276
282
|
}
|
|
277
283
|
next();
|
|
278
284
|
});
|
|
279
|
-
//
|
|
280
|
-
eventSchema.pre('save', function (next) {
|
|
285
|
+
// Pre-save hook to generate slug
|
|
286
|
+
eventSchema.pre('save', async function (next) {
|
|
287
|
+
// Generate slug if title changed and no slug exists
|
|
288
|
+
if (this.isModified('title') && !this.slug) {
|
|
289
|
+
if (this.title) {
|
|
290
|
+
// Convert to lowercase, replace spaces with hyphens, remove special characters
|
|
291
|
+
let slug = this.title
|
|
292
|
+
.toLowerCase()
|
|
293
|
+
.replace(/[^\w\s-]/g, '') // Remove special characters except spaces and hyphens
|
|
294
|
+
.replace(/\s+/g, '-') // Replace spaces with hyphens
|
|
295
|
+
.replace(/-+/g, '-') // Replace multiple hyphens with single hyphen
|
|
296
|
+
.trim();
|
|
297
|
+
// Ensure slug is not empty and add random suffix if needed
|
|
298
|
+
if (!slug)
|
|
299
|
+
slug = 'event';
|
|
300
|
+
// Add timestamp suffix to ensure uniqueness
|
|
301
|
+
const timestamp = Date.now().toString(36);
|
|
302
|
+
slug = `${slug}-${timestamp}`;
|
|
303
|
+
this.slug = slug;
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
// Ensure slug uniqueness
|
|
307
|
+
if (this.slug) {
|
|
308
|
+
const existingEvent = await mongoose_1.default.models.Event.findOne({
|
|
309
|
+
slug: this.slug,
|
|
310
|
+
_id: { $ne: this._id }
|
|
311
|
+
});
|
|
312
|
+
if (existingEvent) {
|
|
313
|
+
// Add random suffix to make it unique
|
|
314
|
+
const randomSuffix = Math.random().toString(36).substring(2, 8);
|
|
315
|
+
this.slug = `${this.slug}-${randomSuffix}`;
|
|
316
|
+
}
|
|
317
|
+
}
|
|
281
318
|
this.updatedAt = new Date();
|
|
282
319
|
next();
|
|
283
320
|
});
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import mongoose from "mongoose";
|
|
2
|
+
/**
|
|
3
|
+
* Host Profile Schema
|
|
4
|
+
* Stores host-specific information separate from User
|
|
5
|
+
*/
|
|
6
|
+
declare const hostProfileSchema: mongoose.Schema<any, mongoose.Model<any, any, any, any, any, any>, {}, {}, {}, {}, {
|
|
7
|
+
timestamps: true;
|
|
8
|
+
toJSON: {
|
|
9
|
+
virtuals: true;
|
|
10
|
+
};
|
|
11
|
+
toObject: {
|
|
12
|
+
virtuals: true;
|
|
13
|
+
};
|
|
14
|
+
}, {
|
|
15
|
+
userId: mongoose.Types.ObjectId;
|
|
16
|
+
isVerified: boolean;
|
|
17
|
+
completenessScore: number;
|
|
18
|
+
verifiedAt?: NativeDate | null | undefined;
|
|
19
|
+
contactPerson?: {
|
|
20
|
+
name: string;
|
|
21
|
+
email: string;
|
|
22
|
+
phone: string;
|
|
23
|
+
designation?: string | null | undefined;
|
|
24
|
+
} | null | undefined;
|
|
25
|
+
organizationName?: string | null | undefined;
|
|
26
|
+
organizationType?: "event_organizer" | "venue_owner" | "authorized_rep" | "artist" | "promoter" | null | undefined;
|
|
27
|
+
tradeLicenseNumber?: string | null | undefined;
|
|
28
|
+
taxId?: string | null | undefined;
|
|
29
|
+
website?: string | null | undefined;
|
|
30
|
+
socialMedia?: {
|
|
31
|
+
facebook?: string | null | undefined;
|
|
32
|
+
instagram?: string | null | undefined;
|
|
33
|
+
twitter?: string | null | undefined;
|
|
34
|
+
linkedin?: string | null | undefined;
|
|
35
|
+
} | null | undefined;
|
|
36
|
+
lastUpdatedBy?: mongoose.Types.ObjectId | null | undefined;
|
|
37
|
+
} & mongoose.DefaultTimestampProps, mongoose.Document<unknown, {}, mongoose.FlatRecord<{
|
|
38
|
+
userId: mongoose.Types.ObjectId;
|
|
39
|
+
isVerified: boolean;
|
|
40
|
+
completenessScore: number;
|
|
41
|
+
verifiedAt?: NativeDate | null | undefined;
|
|
42
|
+
contactPerson?: {
|
|
43
|
+
name: string;
|
|
44
|
+
email: string;
|
|
45
|
+
phone: string;
|
|
46
|
+
designation?: string | null | undefined;
|
|
47
|
+
} | null | undefined;
|
|
48
|
+
organizationName?: string | null | undefined;
|
|
49
|
+
organizationType?: "event_organizer" | "venue_owner" | "authorized_rep" | "artist" | "promoter" | null | undefined;
|
|
50
|
+
tradeLicenseNumber?: string | null | undefined;
|
|
51
|
+
taxId?: string | null | undefined;
|
|
52
|
+
website?: string | null | undefined;
|
|
53
|
+
socialMedia?: {
|
|
54
|
+
facebook?: string | null | undefined;
|
|
55
|
+
instagram?: string | null | undefined;
|
|
56
|
+
twitter?: string | null | undefined;
|
|
57
|
+
linkedin?: string | null | undefined;
|
|
58
|
+
} | null | undefined;
|
|
59
|
+
lastUpdatedBy?: mongoose.Types.ObjectId | null | undefined;
|
|
60
|
+
} & mongoose.DefaultTimestampProps>, {}, mongoose.ResolveSchemaOptions<{
|
|
61
|
+
timestamps: true;
|
|
62
|
+
toJSON: {
|
|
63
|
+
virtuals: true;
|
|
64
|
+
};
|
|
65
|
+
toObject: {
|
|
66
|
+
virtuals: true;
|
|
67
|
+
};
|
|
68
|
+
}>> & mongoose.FlatRecord<{
|
|
69
|
+
userId: mongoose.Types.ObjectId;
|
|
70
|
+
isVerified: boolean;
|
|
71
|
+
completenessScore: number;
|
|
72
|
+
verifiedAt?: NativeDate | null | undefined;
|
|
73
|
+
contactPerson?: {
|
|
74
|
+
name: string;
|
|
75
|
+
email: string;
|
|
76
|
+
phone: string;
|
|
77
|
+
designation?: string | null | undefined;
|
|
78
|
+
} | null | undefined;
|
|
79
|
+
organizationName?: string | null | undefined;
|
|
80
|
+
organizationType?: "event_organizer" | "venue_owner" | "authorized_rep" | "artist" | "promoter" | null | undefined;
|
|
81
|
+
tradeLicenseNumber?: string | null | undefined;
|
|
82
|
+
taxId?: string | null | undefined;
|
|
83
|
+
website?: string | null | undefined;
|
|
84
|
+
socialMedia?: {
|
|
85
|
+
facebook?: string | null | undefined;
|
|
86
|
+
instagram?: string | null | undefined;
|
|
87
|
+
twitter?: string | null | undefined;
|
|
88
|
+
linkedin?: string | null | undefined;
|
|
89
|
+
} | null | undefined;
|
|
90
|
+
lastUpdatedBy?: mongoose.Types.ObjectId | null | undefined;
|
|
91
|
+
} & mongoose.DefaultTimestampProps> & {
|
|
92
|
+
_id: mongoose.Types.ObjectId;
|
|
93
|
+
} & {
|
|
94
|
+
__v: number;
|
|
95
|
+
}>;
|
|
96
|
+
export default hostProfileSchema;
|
|
@@ -0,0 +1,142 @@
|
|
|
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
|
+
* Host Profile Schema
|
|
9
|
+
* Stores host-specific information separate from User
|
|
10
|
+
*/
|
|
11
|
+
const hostProfileSchema = new mongoose_1.default.Schema({
|
|
12
|
+
userId: {
|
|
13
|
+
type: mongoose_1.default.Schema.Types.ObjectId,
|
|
14
|
+
ref: 'User',
|
|
15
|
+
required: true,
|
|
16
|
+
unique: true,
|
|
17
|
+
index: true
|
|
18
|
+
},
|
|
19
|
+
// Organization
|
|
20
|
+
organizationName: {
|
|
21
|
+
type: String,
|
|
22
|
+
trim: true
|
|
23
|
+
},
|
|
24
|
+
organizationType: {
|
|
25
|
+
type: String,
|
|
26
|
+
enum: ['event_organizer', 'venue_owner', 'authorized_rep', 'artist', 'promoter'],
|
|
27
|
+
index: true
|
|
28
|
+
},
|
|
29
|
+
// Contact Person
|
|
30
|
+
contactPerson: {
|
|
31
|
+
name: {
|
|
32
|
+
type: String,
|
|
33
|
+
required: true,
|
|
34
|
+
trim: true
|
|
35
|
+
},
|
|
36
|
+
email: {
|
|
37
|
+
type: String,
|
|
38
|
+
required: true,
|
|
39
|
+
lowercase: true,
|
|
40
|
+
trim: true
|
|
41
|
+
},
|
|
42
|
+
phone: {
|
|
43
|
+
type: String,
|
|
44
|
+
required: true,
|
|
45
|
+
trim: true
|
|
46
|
+
},
|
|
47
|
+
designation: {
|
|
48
|
+
type: String,
|
|
49
|
+
trim: true
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
// Business Info
|
|
53
|
+
tradeLicenseNumber: {
|
|
54
|
+
type: String,
|
|
55
|
+
trim: true
|
|
56
|
+
},
|
|
57
|
+
taxId: {
|
|
58
|
+
type: String,
|
|
59
|
+
trim: true
|
|
60
|
+
},
|
|
61
|
+
website: {
|
|
62
|
+
type: String,
|
|
63
|
+
trim: true
|
|
64
|
+
},
|
|
65
|
+
socialMedia: {
|
|
66
|
+
facebook: String,
|
|
67
|
+
instagram: String,
|
|
68
|
+
twitter: String,
|
|
69
|
+
linkedin: String
|
|
70
|
+
},
|
|
71
|
+
// Verification Status (denormalized for quick access)
|
|
72
|
+
isVerified: {
|
|
73
|
+
type: Boolean,
|
|
74
|
+
default: false,
|
|
75
|
+
index: true
|
|
76
|
+
},
|
|
77
|
+
verifiedAt: {
|
|
78
|
+
type: Date
|
|
79
|
+
},
|
|
80
|
+
// Profile Completeness (calculated field)
|
|
81
|
+
completenessScore: {
|
|
82
|
+
type: Number,
|
|
83
|
+
default: 0,
|
|
84
|
+
min: 0,
|
|
85
|
+
max: 100
|
|
86
|
+
},
|
|
87
|
+
// Metadata
|
|
88
|
+
lastUpdatedBy: {
|
|
89
|
+
type: mongoose_1.default.Schema.Types.ObjectId,
|
|
90
|
+
ref: 'User'
|
|
91
|
+
}
|
|
92
|
+
}, {
|
|
93
|
+
timestamps: true,
|
|
94
|
+
toJSON: { virtuals: true },
|
|
95
|
+
toObject: { virtuals: true }
|
|
96
|
+
});
|
|
97
|
+
// Indexes
|
|
98
|
+
hostProfileSchema.index({ userId: 1 });
|
|
99
|
+
hostProfileSchema.index({ isVerified: 1, createdAt: -1 });
|
|
100
|
+
hostProfileSchema.index({ organizationType: 1, isVerified: 1 });
|
|
101
|
+
// Virtual: Is Complete
|
|
102
|
+
hostProfileSchema.virtual('isComplete').get(function () {
|
|
103
|
+
return this.completenessScore >= 80;
|
|
104
|
+
});
|
|
105
|
+
// Pre-save hook: Calculate completeness score
|
|
106
|
+
hostProfileSchema.pre('save', function (next) {
|
|
107
|
+
let score = 0;
|
|
108
|
+
// Organization info (40 points)
|
|
109
|
+
if (this.organizationName)
|
|
110
|
+
score += 20;
|
|
111
|
+
if (this.organizationType)
|
|
112
|
+
score += 20;
|
|
113
|
+
// Contact person (30 points)
|
|
114
|
+
if (this.contactPerson?.name)
|
|
115
|
+
score += 10;
|
|
116
|
+
if (this.contactPerson?.email)
|
|
117
|
+
score += 10;
|
|
118
|
+
if (this.contactPerson?.phone)
|
|
119
|
+
score += 10;
|
|
120
|
+
// Business info (20 points)
|
|
121
|
+
if (this.tradeLicenseNumber)
|
|
122
|
+
score += 10;
|
|
123
|
+
if (this.taxId)
|
|
124
|
+
score += 10;
|
|
125
|
+
// Additional info (10 points)
|
|
126
|
+
if (this.website)
|
|
127
|
+
score += 5;
|
|
128
|
+
if (this.socialMedia?.facebook || this.socialMedia?.instagram)
|
|
129
|
+
score += 5;
|
|
130
|
+
this.completenessScore = score;
|
|
131
|
+
next();
|
|
132
|
+
});
|
|
133
|
+
// Methods
|
|
134
|
+
hostProfileSchema.methods.markAsVerified = function (verifiedBy) {
|
|
135
|
+
this.isVerified = true;
|
|
136
|
+
this.verifiedAt = new Date();
|
|
137
|
+
if (verifiedBy) {
|
|
138
|
+
this.lastUpdatedBy = verifiedBy;
|
|
139
|
+
}
|
|
140
|
+
return this.save();
|
|
141
|
+
};
|
|
142
|
+
exports.default = hostProfileSchema;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import mongoose from "mongoose";
|
|
2
|
+
/**
|
|
3
|
+
* Payment Details Schema
|
|
4
|
+
* Stores payment/payout information separate from User
|
|
5
|
+
*/
|
|
6
|
+
declare const paymentDetailsSchema: mongoose.Schema<any, mongoose.Model<any, any, any, any, any, any>, {}, {}, {}, {}, {
|
|
7
|
+
timestamps: true;
|
|
8
|
+
}, {
|
|
9
|
+
userId: mongoose.Types.ObjectId;
|
|
10
|
+
verified: boolean;
|
|
11
|
+
method: "bkash" | "bank_transfer" | "nagad" | "rocket";
|
|
12
|
+
verifiedAt?: NativeDate | null | undefined;
|
|
13
|
+
rejectionReason?: string | null | undefined;
|
|
14
|
+
lastUpdatedBy?: mongoose.Types.ObjectId | null | undefined;
|
|
15
|
+
mobileNumber?: string | null | undefined;
|
|
16
|
+
accountHolderName?: string | null | undefined;
|
|
17
|
+
bankName?: string | null | undefined;
|
|
18
|
+
accountNumber?: string | null | undefined;
|
|
19
|
+
branchName?: string | null | undefined;
|
|
20
|
+
routingNumber?: string | null | undefined;
|
|
21
|
+
swiftCode?: string | null | undefined;
|
|
22
|
+
verifiedBy?: mongoose.Types.ObjectId | null | undefined;
|
|
23
|
+
} & mongoose.DefaultTimestampProps, mongoose.Document<unknown, {}, mongoose.FlatRecord<{
|
|
24
|
+
userId: mongoose.Types.ObjectId;
|
|
25
|
+
verified: boolean;
|
|
26
|
+
method: "bkash" | "bank_transfer" | "nagad" | "rocket";
|
|
27
|
+
verifiedAt?: NativeDate | null | undefined;
|
|
28
|
+
rejectionReason?: string | null | undefined;
|
|
29
|
+
lastUpdatedBy?: mongoose.Types.ObjectId | null | undefined;
|
|
30
|
+
mobileNumber?: string | null | undefined;
|
|
31
|
+
accountHolderName?: string | null | undefined;
|
|
32
|
+
bankName?: string | null | undefined;
|
|
33
|
+
accountNumber?: string | null | undefined;
|
|
34
|
+
branchName?: string | null | undefined;
|
|
35
|
+
routingNumber?: string | null | undefined;
|
|
36
|
+
swiftCode?: string | null | undefined;
|
|
37
|
+
verifiedBy?: mongoose.Types.ObjectId | null | undefined;
|
|
38
|
+
} & mongoose.DefaultTimestampProps>, {}, mongoose.ResolveSchemaOptions<{
|
|
39
|
+
timestamps: true;
|
|
40
|
+
}>> & mongoose.FlatRecord<{
|
|
41
|
+
userId: mongoose.Types.ObjectId;
|
|
42
|
+
verified: boolean;
|
|
43
|
+
method: "bkash" | "bank_transfer" | "nagad" | "rocket";
|
|
44
|
+
verifiedAt?: NativeDate | null | undefined;
|
|
45
|
+
rejectionReason?: string | null | undefined;
|
|
46
|
+
lastUpdatedBy?: mongoose.Types.ObjectId | null | undefined;
|
|
47
|
+
mobileNumber?: string | null | undefined;
|
|
48
|
+
accountHolderName?: string | null | undefined;
|
|
49
|
+
bankName?: string | null | undefined;
|
|
50
|
+
accountNumber?: string | null | undefined;
|
|
51
|
+
branchName?: string | null | undefined;
|
|
52
|
+
routingNumber?: string | null | undefined;
|
|
53
|
+
swiftCode?: string | null | undefined;
|
|
54
|
+
verifiedBy?: mongoose.Types.ObjectId | null | undefined;
|
|
55
|
+
} & mongoose.DefaultTimestampProps> & {
|
|
56
|
+
_id: mongoose.Types.ObjectId;
|
|
57
|
+
} & {
|
|
58
|
+
__v: number;
|
|
59
|
+
}>;
|
|
60
|
+
export default paymentDetailsSchema;
|
|
@@ -0,0 +1,120 @@
|
|
|
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
|
+
* Payment Details Schema
|
|
9
|
+
* Stores payment/payout information separate from User
|
|
10
|
+
*/
|
|
11
|
+
const paymentDetailsSchema = new mongoose_1.default.Schema({
|
|
12
|
+
userId: {
|
|
13
|
+
type: mongoose_1.default.Schema.Types.ObjectId,
|
|
14
|
+
ref: 'User',
|
|
15
|
+
required: true,
|
|
16
|
+
unique: true,
|
|
17
|
+
index: true
|
|
18
|
+
},
|
|
19
|
+
// Payment Method
|
|
20
|
+
method: {
|
|
21
|
+
type: String,
|
|
22
|
+
enum: ['bkash', 'nagad', 'rocket', 'bank_transfer'],
|
|
23
|
+
required: true,
|
|
24
|
+
index: true
|
|
25
|
+
},
|
|
26
|
+
// Mobile Money (bKash, Nagad, Rocket)
|
|
27
|
+
mobileNumber: {
|
|
28
|
+
type: String,
|
|
29
|
+
trim: true
|
|
30
|
+
},
|
|
31
|
+
accountHolderName: {
|
|
32
|
+
type: String,
|
|
33
|
+
trim: true
|
|
34
|
+
},
|
|
35
|
+
// Bank Transfer
|
|
36
|
+
bankName: {
|
|
37
|
+
type: String,
|
|
38
|
+
trim: true
|
|
39
|
+
},
|
|
40
|
+
accountNumber: {
|
|
41
|
+
type: String,
|
|
42
|
+
trim: true
|
|
43
|
+
},
|
|
44
|
+
branchName: {
|
|
45
|
+
type: String,
|
|
46
|
+
trim: true
|
|
47
|
+
},
|
|
48
|
+
routingNumber: {
|
|
49
|
+
type: String,
|
|
50
|
+
trim: true
|
|
51
|
+
},
|
|
52
|
+
swiftCode: {
|
|
53
|
+
type: String,
|
|
54
|
+
trim: true
|
|
55
|
+
},
|
|
56
|
+
// Verification
|
|
57
|
+
verified: {
|
|
58
|
+
type: Boolean,
|
|
59
|
+
default: false,
|
|
60
|
+
index: true
|
|
61
|
+
},
|
|
62
|
+
verifiedAt: {
|
|
63
|
+
type: Date
|
|
64
|
+
},
|
|
65
|
+
verifiedBy: {
|
|
66
|
+
type: mongoose_1.default.Schema.Types.ObjectId,
|
|
67
|
+
ref: 'User'
|
|
68
|
+
},
|
|
69
|
+
rejectionReason: {
|
|
70
|
+
type: String
|
|
71
|
+
},
|
|
72
|
+
// Metadata
|
|
73
|
+
lastUpdatedBy: {
|
|
74
|
+
type: mongoose_1.default.Schema.Types.ObjectId,
|
|
75
|
+
ref: 'User'
|
|
76
|
+
}
|
|
77
|
+
}, {
|
|
78
|
+
timestamps: true
|
|
79
|
+
});
|
|
80
|
+
// Indexes
|
|
81
|
+
paymentDetailsSchema.index({ userId: 1 });
|
|
82
|
+
paymentDetailsSchema.index({ verified: 1, createdAt: -1 });
|
|
83
|
+
paymentDetailsSchema.index({ method: 1, verified: 1 });
|
|
84
|
+
// Pre-save validation: Ensure required fields based on method
|
|
85
|
+
paymentDetailsSchema.pre('save', function (next) {
|
|
86
|
+
if (this.method === 'bank_transfer') {
|
|
87
|
+
if (!this.bankName || !this.accountNumber || !this.accountHolderName) {
|
|
88
|
+
return next(new Error('Bank name, account number, and account holder name are required for bank transfer'));
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
// Mobile money methods
|
|
93
|
+
if (!this.mobileNumber || !this.accountHolderName) {
|
|
94
|
+
return next(new Error('Mobile number and account holder name are required for mobile money'));
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
next();
|
|
98
|
+
});
|
|
99
|
+
// Methods
|
|
100
|
+
paymentDetailsSchema.methods.markAsVerified = function (verifiedBy) {
|
|
101
|
+
this.verified = true;
|
|
102
|
+
this.verifiedAt = new Date();
|
|
103
|
+
this.verifiedBy = verifiedBy;
|
|
104
|
+
this.rejectionReason = undefined;
|
|
105
|
+
return this.save();
|
|
106
|
+
};
|
|
107
|
+
paymentDetailsSchema.methods.reject = function (reason, rejectedBy) {
|
|
108
|
+
this.verified = false;
|
|
109
|
+
this.verifiedAt = undefined;
|
|
110
|
+
this.rejectionReason = reason;
|
|
111
|
+
this.lastUpdatedBy = rejectedBy;
|
|
112
|
+
return this.save();
|
|
113
|
+
};
|
|
114
|
+
paymentDetailsSchema.methods.isMobileMoney = function () {
|
|
115
|
+
return ['bkash', 'nagad', 'rocket'].includes(this.method);
|
|
116
|
+
};
|
|
117
|
+
paymentDetailsSchema.methods.isBankTransfer = function () {
|
|
118
|
+
return this.method === 'bank_transfer';
|
|
119
|
+
};
|
|
120
|
+
exports.default = paymentDetailsSchema;
|