@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/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;
@@ -0,0 +1,38 @@
1
+ import mongoose from 'mongoose';
2
+ export interface IReview {
3
+ eventId: mongoose.Types.ObjectId;
4
+ userId: mongoose.Types.ObjectId;
5
+ ticketId: mongoose.Types.ObjectId;
6
+ rating: number;
7
+ title: string;
8
+ comment: string;
9
+ reviewContext: {
10
+ hasCheckedIn: boolean;
11
+ checkInTime?: Date;
12
+ ticketTier: string;
13
+ ticketType: string;
14
+ };
15
+ status: 'pending' | 'approved' | 'hidden' | 'flagged';
16
+ isVisible: boolean;
17
+ moderationNotes?: string;
18
+ submittedAt: Date;
19
+ moderatedAt?: Date;
20
+ moderatorId?: mongoose.Types.ObjectId;
21
+ helpfulVotes: number;
22
+ reportedCount: number;
23
+ reports: Array<{
24
+ userId: mongoose.Types.ObjectId;
25
+ reason: string;
26
+ reportedAt: Date;
27
+ }>;
28
+ }
29
+ declare const reviewSchema: mongoose.Schema<IReview, mongoose.Model<IReview, any, any, any, mongoose.Document<unknown, any, IReview, any, {}> & IReview & {
30
+ _id: mongoose.Types.ObjectId;
31
+ } & {
32
+ __v: number;
33
+ }, any>, {}, {}, {}, {}, mongoose.DefaultSchemaOptions, IReview, mongoose.Document<unknown, {}, mongoose.FlatRecord<IReview>, {}, mongoose.ResolveSchemaOptions<mongoose.DefaultSchemaOptions>> & mongoose.FlatRecord<IReview> & {
34
+ _id: mongoose.Types.ObjectId;
35
+ } & {
36
+ __v: number;
37
+ }>;
38
+ export default reviewSchema;
package/dist/Review.js ADDED
@@ -0,0 +1,200 @@
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
+ const reviewSchema = new mongoose_1.default.Schema({
8
+ eventId: {
9
+ type: mongoose_1.default.Schema.Types.ObjectId,
10
+ ref: 'Event',
11
+ required: true,
12
+ index: true
13
+ },
14
+ userId: {
15
+ type: mongoose_1.default.Schema.Types.ObjectId,
16
+ ref: 'User',
17
+ required: true,
18
+ index: true
19
+ },
20
+ ticketId: {
21
+ type: mongoose_1.default.Schema.Types.ObjectId,
22
+ ref: 'Ticket',
23
+ required: true,
24
+ index: true
25
+ },
26
+ // Review Content
27
+ rating: {
28
+ type: Number,
29
+ required: true,
30
+ min: 1,
31
+ max: 5,
32
+ validate: {
33
+ validator: Number.isInteger,
34
+ message: 'Rating must be a whole number'
35
+ }
36
+ },
37
+ title: {
38
+ type: String,
39
+ required: true,
40
+ trim: true,
41
+ maxlength: 100
42
+ },
43
+ comment: {
44
+ type: String,
45
+ required: true,
46
+ trim: true,
47
+ maxlength: 1000
48
+ },
49
+ // Context Metadata
50
+ reviewContext: {
51
+ hasCheckedIn: {
52
+ type: Boolean,
53
+ required: true
54
+ },
55
+ checkInTime: Date,
56
+ ticketTier: {
57
+ type: String,
58
+ required: true
59
+ },
60
+ ticketType: {
61
+ type: String,
62
+ required: true
63
+ }
64
+ },
65
+ // Status & Moderation
66
+ status: {
67
+ type: String,
68
+ enum: ['pending', 'approved', 'hidden', 'flagged'],
69
+ default: 'pending',
70
+ index: true
71
+ },
72
+ isVisible: {
73
+ type: Boolean,
74
+ default: true
75
+ },
76
+ moderationNotes: {
77
+ type: String,
78
+ trim: true,
79
+ maxlength: 500
80
+ },
81
+ // Timestamps
82
+ submittedAt: {
83
+ type: Date,
84
+ default: Date.now,
85
+ index: true
86
+ },
87
+ moderatedAt: Date,
88
+ moderatorId: {
89
+ type: mongoose_1.default.Schema.Types.ObjectId,
90
+ ref: 'User'
91
+ },
92
+ // Community Features
93
+ helpfulVotes: {
94
+ type: Number,
95
+ default: 0,
96
+ min: 0
97
+ },
98
+ reportedCount: {
99
+ type: Number,
100
+ default: 0,
101
+ min: 0
102
+ },
103
+ reports: [{
104
+ userId: {
105
+ type: mongoose_1.default.Schema.Types.ObjectId,
106
+ ref: 'User',
107
+ required: true
108
+ },
109
+ reason: {
110
+ type: String,
111
+ required: true,
112
+ enum: ['spam', 'abusive', 'fake', 'irrelevant', 'other']
113
+ },
114
+ reportedAt: {
115
+ type: Date,
116
+ default: Date.now
117
+ }
118
+ }]
119
+ });
120
+ // Compound indexes for efficient queries
121
+ reviewSchema.index({ eventId: 1, status: 1, isVisible: 1 });
122
+ reviewSchema.index({ userId: 1, eventId: 1 }, { unique: true }); // One review per user per event
123
+ reviewSchema.index({ submittedAt: -1 });
124
+ reviewSchema.index({ 'reviewContext.hasCheckedIn': 1 });
125
+ // Virtual for review type classification
126
+ reviewSchema.virtual('reviewType').get(function () {
127
+ return this.reviewContext.hasCheckedIn ? 'attended' : 'entry_access';
128
+ });
129
+ // Method to mark as helpful
130
+ reviewSchema.methods.markHelpful = function () {
131
+ this.helpfulVotes += 1;
132
+ return this.save();
133
+ };
134
+ // Method to report review
135
+ reviewSchema.methods.report = function (userId, reason) {
136
+ // Check if user already reported
137
+ const existingReport = this.reports.find((report) => report.userId.toString() === userId);
138
+ if (!existingReport) {
139
+ this.reports.push({
140
+ userId: new mongoose_1.default.Types.ObjectId(userId),
141
+ reason,
142
+ reportedAt: new Date()
143
+ });
144
+ this.reportedCount += 1;
145
+ // Auto-flag if too many reports
146
+ if (this.reportedCount >= 3) {
147
+ this.status = 'flagged';
148
+ }
149
+ }
150
+ return this.save();
151
+ };
152
+ // Method for admin moderation
153
+ reviewSchema.methods.moderate = function (moderatorId, action, notes) {
154
+ this.moderatorId = new mongoose_1.default.Types.ObjectId(moderatorId);
155
+ this.moderatedAt = new Date();
156
+ switch (action) {
157
+ case 'approve':
158
+ this.status = 'approved';
159
+ this.isVisible = true;
160
+ break;
161
+ case 'hide':
162
+ this.status = 'hidden';
163
+ this.isVisible = false;
164
+ break;
165
+ case 'flag':
166
+ this.status = 'flagged';
167
+ this.isVisible = false;
168
+ break;
169
+ }
170
+ if (notes) {
171
+ this.moderationNotes = notes;
172
+ }
173
+ return this.save();
174
+ };
175
+ // Static method to calculate weighted rating for an event
176
+ reviewSchema.statics.calculateWeightedRating = async function (eventId) {
177
+ const reviews = await this.find({
178
+ eventId: new mongoose_1.default.Types.ObjectId(eventId),
179
+ status: 'approved',
180
+ isVisible: true
181
+ });
182
+ if (reviews.length === 0)
183
+ return 0;
184
+ let totalWeightedRating = 0;
185
+ let totalWeight = 0;
186
+ reviews.forEach((review) => {
187
+ const weight = review.reviewContext.hasCheckedIn ? 1.0 : 0.6;
188
+ totalWeightedRating += review.rating * weight;
189
+ totalWeight += weight;
190
+ });
191
+ return totalWeight > 0 ? totalWeightedRating / totalWeight : 0;
192
+ };
193
+ // Pre-save middleware to set default status
194
+ reviewSchema.pre('save', function (next) {
195
+ if (this.isNew && !this.status) {
196
+ this.status = 'pending';
197
+ }
198
+ next();
199
+ });
200
+ exports.default = reviewSchema;
package/dist/Ticket.d.ts CHANGED
@@ -6,11 +6,11 @@ declare const ticketSchema: mongoose.Schema<any, mongoose.Model<any, any, any, a
6
6
  eventId: mongoose.Types.ObjectId;
7
7
  ticketVariantId: mongoose.Types.ObjectId;
8
8
  orderId: mongoose.Types.ObjectId;
9
+ ticketType: string;
9
10
  ticketNumber: string;
10
11
  eventTitle: string;
11
12
  eventDate: NativeDate;
12
13
  eventVenue: string;
13
- ticketType: string;
14
14
  qrCode: string;
15
15
  qrCodeUrl: string;
16
16
  checkInStatus: "not_checked_in" | "checked_in";
@@ -28,11 +28,11 @@ declare const ticketSchema: mongoose.Schema<any, mongoose.Model<any, any, any, a
28
28
  eventId: mongoose.Types.ObjectId;
29
29
  ticketVariantId: mongoose.Types.ObjectId;
30
30
  orderId: mongoose.Types.ObjectId;
31
+ ticketType: string;
31
32
  ticketNumber: string;
32
33
  eventTitle: string;
33
34
  eventDate: NativeDate;
34
35
  eventVenue: string;
35
- ticketType: string;
36
36
  qrCode: string;
37
37
  qrCodeUrl: string;
38
38
  checkInStatus: "not_checked_in" | "checked_in";
@@ -50,11 +50,11 @@ declare const ticketSchema: mongoose.Schema<any, mongoose.Model<any, any, any, a
50
50
  eventId: mongoose.Types.ObjectId;
51
51
  ticketVariantId: mongoose.Types.ObjectId;
52
52
  orderId: mongoose.Types.ObjectId;
53
+ ticketType: string;
53
54
  ticketNumber: string;
54
55
  eventTitle: string;
55
56
  eventDate: NativeDate;
56
57
  eventVenue: string;
57
- ticketType: string;
58
58
  qrCode: string;
59
59
  qrCodeUrl: string;
60
60
  checkInStatus: "not_checked_in" | "checked_in";