@mac777/project-pinecone-models 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Bkash.d.ts +17 -0
- package/dist/Bkash.js +13 -0
- package/dist/Event.d.ts +790 -0
- package/dist/Event.js +239 -0
- package/dist/Media.d.ts +58 -0
- package/dist/Media.js +34 -0
- package/dist/Order.d.ts +172 -0
- package/dist/Order.js +184 -0
- package/dist/Payment.d.ts +61 -0
- package/dist/Payment.js +56 -0
- package/dist/Ticket.d.ts +73 -0
- package/dist/Ticket.js +90 -0
- package/dist/User.d.ts +41 -0
- package/dist/User.js +50 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +21 -0
- package/package.json +22 -0
package/dist/Event.js
ADDED
|
@@ -0,0 +1,239 @@
|
|
|
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 mediaSchema = new mongoose_1.default.Schema({
|
|
8
|
+
coverImage: {
|
|
9
|
+
url: String,
|
|
10
|
+
thumbnailUrl: String,
|
|
11
|
+
alt: String,
|
|
12
|
+
},
|
|
13
|
+
gallery: [{
|
|
14
|
+
url: String,
|
|
15
|
+
caption: String,
|
|
16
|
+
order: Number,
|
|
17
|
+
}],
|
|
18
|
+
}, { _id: false });
|
|
19
|
+
const addressSchema = new mongoose_1.default.Schema({
|
|
20
|
+
street: String,
|
|
21
|
+
city: { type: String, required: true },
|
|
22
|
+
state: String,
|
|
23
|
+
postalCode: String,
|
|
24
|
+
country: { type: String, required: true },
|
|
25
|
+
}, { _id: false });
|
|
26
|
+
const venueSchema = new mongoose_1.default.Schema({
|
|
27
|
+
name: { type: String, required: true },
|
|
28
|
+
address: addressSchema,
|
|
29
|
+
coordinates: {
|
|
30
|
+
type: {
|
|
31
|
+
type: String,
|
|
32
|
+
enum: ['Point'],
|
|
33
|
+
default: 'Point'
|
|
34
|
+
},
|
|
35
|
+
coordinates: [Number] // [lng, lat]
|
|
36
|
+
},
|
|
37
|
+
capacity: { type: Number, required: true, min: 10, max: 100000 },
|
|
38
|
+
type: { type: String, enum: ['indoor', 'outdoor', 'hybrid'] },
|
|
39
|
+
parking: Boolean,
|
|
40
|
+
publicTransit: String,
|
|
41
|
+
}, { _id: false });
|
|
42
|
+
const contactPersonSchema = new mongoose_1.default.Schema({
|
|
43
|
+
name: { type: String, required: true },
|
|
44
|
+
phone: { type: String, required: true },
|
|
45
|
+
email: { type: String, required: true },
|
|
46
|
+
designation: String,
|
|
47
|
+
}, { _id: false });
|
|
48
|
+
const organizerSchema = new mongoose_1.default.Schema({
|
|
49
|
+
role: { type: String, enum: ['event_organizer', 'venue_owner', 'authorized_rep', 'artist'] },
|
|
50
|
+
companyName: String,
|
|
51
|
+
contactPerson: contactPersonSchema,
|
|
52
|
+
}, { _id: false });
|
|
53
|
+
const documentSchema = new mongoose_1.default.Schema({
|
|
54
|
+
type: { type: String, enum: ['venue_booking', 'permit', 'insurance', 'license', 'portfolio', 'other'] },
|
|
55
|
+
url: String,
|
|
56
|
+
filename: String,
|
|
57
|
+
objectKey: String,
|
|
58
|
+
uploadedAt: Date,
|
|
59
|
+
status: { type: String, enum: ['pending', 'approved', 'rejected'] },
|
|
60
|
+
rejectionReason: String,
|
|
61
|
+
}, { _id: false });
|
|
62
|
+
const verificationSchema = new mongoose_1.default.Schema({
|
|
63
|
+
status: { type: String, enum: ['unverified', 'pending', 'verified', 'rejected', 'needs_info'], default: 'unverified' },
|
|
64
|
+
documents: [documentSchema],
|
|
65
|
+
additionalInfo: String,
|
|
66
|
+
adminNotes: String,
|
|
67
|
+
reviewedBy: mongoose_1.default.Schema.Types.ObjectId,
|
|
68
|
+
reviewedAt: Date,
|
|
69
|
+
rejectionReason: String,
|
|
70
|
+
requestedInfo: String,
|
|
71
|
+
}, { _id: false });
|
|
72
|
+
const priceSchema = new mongoose_1.default.Schema({
|
|
73
|
+
amount: { type: Number, required: true },
|
|
74
|
+
currency: { type: String, default: 'USD' },
|
|
75
|
+
}, { _id: false });
|
|
76
|
+
const salesWindowSchema = new mongoose_1.default.Schema({
|
|
77
|
+
startDate: Date,
|
|
78
|
+
endDate: Date,
|
|
79
|
+
}, { _id: false });
|
|
80
|
+
const limitsSchema = new mongoose_1.default.Schema({
|
|
81
|
+
minPerOrder: { type: Number, default: 1 },
|
|
82
|
+
maxPerOrder: { type: Number, default: 10 },
|
|
83
|
+
}, { _id: false });
|
|
84
|
+
const ticketSchema = new mongoose_1.default.Schema({
|
|
85
|
+
name: { type: String, required: true },
|
|
86
|
+
description: String,
|
|
87
|
+
price: priceSchema,
|
|
88
|
+
quantity: { type: Number, required: true },
|
|
89
|
+
sold: { type: Number, default: 0 },
|
|
90
|
+
remaining: { type: Number, default: function () { return this.quantity - this.sold; } },
|
|
91
|
+
salesWindow: salesWindowSchema,
|
|
92
|
+
limits: limitsSchema,
|
|
93
|
+
visibility: { type: String, enum: ['public', 'hidden', 'invite_only'], default: 'public' },
|
|
94
|
+
reserved: { type: Number, default: 0 },
|
|
95
|
+
status: { type: String, enum: ['active', 'sold_out', 'inactive'], default: 'active' },
|
|
96
|
+
benefits: [String],
|
|
97
|
+
tier: { type: String, enum: ['early_bird', 'regular', 'vip'] },
|
|
98
|
+
});
|
|
99
|
+
const scheduleSchema = new mongoose_1.default.Schema({
|
|
100
|
+
startDate: { type: Date, required: true },
|
|
101
|
+
endDate: { type: Date, required: true },
|
|
102
|
+
timezone: String,
|
|
103
|
+
isMultiDay: Boolean,
|
|
104
|
+
doors: String,
|
|
105
|
+
}, { _id: false });
|
|
106
|
+
const metricsSchema = new mongoose_1.default.Schema({
|
|
107
|
+
views: { type: Number, default: 0 },
|
|
108
|
+
ticketsSold: { type: Number, default: 0 },
|
|
109
|
+
revenue: { type: Number, default: 0 },
|
|
110
|
+
checkIns: { type: Number, default: 0 },
|
|
111
|
+
averageRating: Number,
|
|
112
|
+
reviewCount: { type: Number, default: 0 },
|
|
113
|
+
}, { _id: false });
|
|
114
|
+
const pricingSchema = new mongoose_1.default.Schema({
|
|
115
|
+
platformFee: { type: Number, default: 5 },
|
|
116
|
+
paymentProcessingFee: Number,
|
|
117
|
+
currency: String,
|
|
118
|
+
}, { _id: false });
|
|
119
|
+
const payoutSchema = new mongoose_1.default.Schema({
|
|
120
|
+
status: { type: String, enum: ['pending', 'scheduled', 'completed'] },
|
|
121
|
+
amount: Number,
|
|
122
|
+
scheduledDate: Date,
|
|
123
|
+
paidAt: Date,
|
|
124
|
+
stripePayoutId: String,
|
|
125
|
+
}, { _id: false });
|
|
126
|
+
const cancellationSchema = new mongoose_1.default.Schema({
|
|
127
|
+
allowed: { type: Boolean, default: true },
|
|
128
|
+
refundPercentage: { type: Number, default: 100 },
|
|
129
|
+
deadlineHours: Number,
|
|
130
|
+
}, { _id: false });
|
|
131
|
+
const policiesSchema = new mongoose_1.default.Schema({
|
|
132
|
+
cancellation: cancellationSchema,
|
|
133
|
+
transferable: { type: Boolean, default: false },
|
|
134
|
+
}, { _id: false });
|
|
135
|
+
const flagSchema = new mongoose_1.default.Schema({
|
|
136
|
+
reportedBy: mongoose_1.default.Schema.Types.ObjectId,
|
|
137
|
+
reason: String,
|
|
138
|
+
description: String,
|
|
139
|
+
createdAt: { type: Date, default: Date.now },
|
|
140
|
+
status: { type: String, enum: ['pending', 'resolved', 'dismissed'], default: 'pending' },
|
|
141
|
+
}, { _id: false });
|
|
142
|
+
const moderationSchema = new mongoose_1.default.Schema({
|
|
143
|
+
isFlagged: { type: Boolean, default: false },
|
|
144
|
+
flags: [flagSchema],
|
|
145
|
+
suspendedUntil: Date,
|
|
146
|
+
banReason: String,
|
|
147
|
+
}, { _id: false });
|
|
148
|
+
const seoSchema = new mongoose_1.default.Schema({
|
|
149
|
+
metaTitle: String,
|
|
150
|
+
metaDescription: String,
|
|
151
|
+
keywords: [String],
|
|
152
|
+
ogImage: String,
|
|
153
|
+
}, { _id: false });
|
|
154
|
+
const featuresSchema = new mongoose_1.default.Schema({
|
|
155
|
+
isFeatured: { type: Boolean, default: false },
|
|
156
|
+
isPremium: { type: Boolean, default: false },
|
|
157
|
+
badges: [String],
|
|
158
|
+
}, { _id: false });
|
|
159
|
+
const historySchema = new mongoose_1.default.Schema({
|
|
160
|
+
action: String,
|
|
161
|
+
performedBy: mongoose_1.default.Schema.Types.ObjectId,
|
|
162
|
+
timestamp: { type: Date, default: Date.now },
|
|
163
|
+
changes: mongoose_1.default.Schema.Types.Mixed,
|
|
164
|
+
}, { _id: false });
|
|
165
|
+
const eventSchema = new mongoose_1.default.Schema({
|
|
166
|
+
hostId: { type: mongoose_1.default.Schema.Types.ObjectId, required: true },
|
|
167
|
+
slug: String,
|
|
168
|
+
// STEP 1: BASICS
|
|
169
|
+
title: { type: String, required: true, minlength: 10, maxlength: 100 },
|
|
170
|
+
type: { type: String, enum: ['concert', 'sports', 'conference', 'festival', 'theater', 'comedy', 'networking', 'workshop', 'other'], required: true },
|
|
171
|
+
categories: [{ type: String }],
|
|
172
|
+
tagline: { type: String, maxlength: 150 },
|
|
173
|
+
// STEP 2: DETAILS
|
|
174
|
+
description: { type: String, minlength: 50, maxlength: 5000 },
|
|
175
|
+
highlights: [{ type: String }],
|
|
176
|
+
languages: [String],
|
|
177
|
+
ageRestriction: { type: String, enum: ['all_ages', '18+', '21+'] },
|
|
178
|
+
dressCode: String,
|
|
179
|
+
media: mediaSchema,
|
|
180
|
+
// STEP 3: DATE, TIME & LOCATION
|
|
181
|
+
schedule: scheduleSchema,
|
|
182
|
+
venue: venueSchema,
|
|
183
|
+
// STEP 4: VERIFICATION
|
|
184
|
+
organizer: organizerSchema,
|
|
185
|
+
verification: verificationSchema,
|
|
186
|
+
// STEP 5: TICKETS
|
|
187
|
+
tickets: [ticketSchema],
|
|
188
|
+
termsAccepted: { type: Boolean, default: false },
|
|
189
|
+
legalPermissionAccepted: { type: Boolean, default: false },
|
|
190
|
+
platformTermsAccepted: { type: Boolean, default: false },
|
|
191
|
+
// STATUS & WORKFLOW
|
|
192
|
+
status: { type: String, enum: ['draft', 'pending_approval', 'approved', 'rejected', 'published', 'live', 'ended', 'cancelled'], default: 'draft' },
|
|
193
|
+
rejectionReason: String,
|
|
194
|
+
visibility: { type: String, enum: ['public', 'private', 'unlisted'], default: 'public' },
|
|
195
|
+
publishedAt: Date,
|
|
196
|
+
// METRICS
|
|
197
|
+
metrics: metricsSchema,
|
|
198
|
+
// BUSINESS
|
|
199
|
+
pricing: pricingSchema,
|
|
200
|
+
payout: payoutSchema,
|
|
201
|
+
// POLICIES
|
|
202
|
+
policies: policiesSchema,
|
|
203
|
+
// MODERATION
|
|
204
|
+
moderation: moderationSchema,
|
|
205
|
+
// SEO
|
|
206
|
+
seo: seoSchema,
|
|
207
|
+
// FEATURES
|
|
208
|
+
features: featuresSchema,
|
|
209
|
+
// AUDIT
|
|
210
|
+
createdAt: { type: Date, default: Date.now },
|
|
211
|
+
updatedAt: { type: Date, default: Date.now },
|
|
212
|
+
submittedAt: Date,
|
|
213
|
+
history: [historySchema],
|
|
214
|
+
deletedAt: Date,
|
|
215
|
+
});
|
|
216
|
+
// Indexes
|
|
217
|
+
eventSchema.index({ slug: 1 });
|
|
218
|
+
eventSchema.index({ 'venue.coordinates': '2dsphere' });
|
|
219
|
+
eventSchema.index({ status: 1, visibility: 1 });
|
|
220
|
+
eventSchema.index({ hostId: 1 });
|
|
221
|
+
eventSchema.index({ 'schedule.startDate': 1 });
|
|
222
|
+
eventSchema.index({ type: 1 });
|
|
223
|
+
eventSchema.index({ categories: 1 });
|
|
224
|
+
// Validation: sum(tickets.quantity) <= venue.capacity
|
|
225
|
+
eventSchema.pre('save', function (next) {
|
|
226
|
+
if (this.tickets && this.tickets.length > 0 && this.venue) {
|
|
227
|
+
const totalCapacity = this.tickets.reduce((sum, ticket) => sum + ticket.quantity, 0);
|
|
228
|
+
if (totalCapacity > this.venue.capacity) {
|
|
229
|
+
return next(new Error('Total ticket quantity exceeds venue capacity'));
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
next();
|
|
233
|
+
});
|
|
234
|
+
// Update updatedAt on save
|
|
235
|
+
eventSchema.pre('save', function (next) {
|
|
236
|
+
this.updatedAt = new Date();
|
|
237
|
+
next();
|
|
238
|
+
});
|
|
239
|
+
exports.default = eventSchema;
|
package/dist/Media.d.ts
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import mongoose from 'mongoose';
|
|
2
|
+
declare const mediaSchema: mongoose.Schema<any, mongoose.Model<any, any, any, any, any, any>, {}, {}, {}, {}, mongoose.DefaultSchemaOptions, {
|
|
3
|
+
type: "event_cover" | "event_gallery" | "verification_doc";
|
|
4
|
+
filename: string;
|
|
5
|
+
uploadedAt: NativeDate;
|
|
6
|
+
status: "temp" | "permanent" | "deleted";
|
|
7
|
+
userId: mongoose.Types.ObjectId;
|
|
8
|
+
provider: "imagekit" | "backblaze";
|
|
9
|
+
mimeType: string;
|
|
10
|
+
url?: string | null | undefined;
|
|
11
|
+
thumbnailUrl?: string | null | undefined;
|
|
12
|
+
objectKey?: string | null | undefined;
|
|
13
|
+
deletedAt?: NativeDate | null | undefined;
|
|
14
|
+
fileId?: string | null | undefined;
|
|
15
|
+
bucketName?: string | null | undefined;
|
|
16
|
+
movedToPermanentAt?: NativeDate | null | undefined;
|
|
17
|
+
expiresAt?: NativeDate | null | undefined;
|
|
18
|
+
size?: number | null | undefined;
|
|
19
|
+
}, mongoose.Document<unknown, {}, mongoose.FlatRecord<{
|
|
20
|
+
type: "event_cover" | "event_gallery" | "verification_doc";
|
|
21
|
+
filename: string;
|
|
22
|
+
uploadedAt: NativeDate;
|
|
23
|
+
status: "temp" | "permanent" | "deleted";
|
|
24
|
+
userId: mongoose.Types.ObjectId;
|
|
25
|
+
provider: "imagekit" | "backblaze";
|
|
26
|
+
mimeType: string;
|
|
27
|
+
url?: string | null | undefined;
|
|
28
|
+
thumbnailUrl?: string | null | undefined;
|
|
29
|
+
objectKey?: string | null | undefined;
|
|
30
|
+
deletedAt?: NativeDate | null | undefined;
|
|
31
|
+
fileId?: string | null | undefined;
|
|
32
|
+
bucketName?: string | null | undefined;
|
|
33
|
+
movedToPermanentAt?: NativeDate | null | undefined;
|
|
34
|
+
expiresAt?: NativeDate | null | undefined;
|
|
35
|
+
size?: number | null | undefined;
|
|
36
|
+
}>, {}, mongoose.ResolveSchemaOptions<mongoose.DefaultSchemaOptions>> & mongoose.FlatRecord<{
|
|
37
|
+
type: "event_cover" | "event_gallery" | "verification_doc";
|
|
38
|
+
filename: string;
|
|
39
|
+
uploadedAt: NativeDate;
|
|
40
|
+
status: "temp" | "permanent" | "deleted";
|
|
41
|
+
userId: mongoose.Types.ObjectId;
|
|
42
|
+
provider: "imagekit" | "backblaze";
|
|
43
|
+
mimeType: string;
|
|
44
|
+
url?: string | null | undefined;
|
|
45
|
+
thumbnailUrl?: string | null | undefined;
|
|
46
|
+
objectKey?: string | null | undefined;
|
|
47
|
+
deletedAt?: NativeDate | null | undefined;
|
|
48
|
+
fileId?: string | null | undefined;
|
|
49
|
+
bucketName?: string | null | undefined;
|
|
50
|
+
movedToPermanentAt?: NativeDate | null | undefined;
|
|
51
|
+
expiresAt?: NativeDate | null | undefined;
|
|
52
|
+
size?: number | null | undefined;
|
|
53
|
+
}> & {
|
|
54
|
+
_id: mongoose.Types.ObjectId;
|
|
55
|
+
} & {
|
|
56
|
+
__v: number;
|
|
57
|
+
}>;
|
|
58
|
+
export default mediaSchema;
|
package/dist/Media.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
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 mediaSchema = new mongoose_1.default.Schema({
|
|
8
|
+
userId: { type: mongoose_1.default.Schema.Types.ObjectId, required: true },
|
|
9
|
+
type: { type: String, enum: ['event_cover', 'event_gallery', 'verification_doc'], required: true },
|
|
10
|
+
provider: { type: String, enum: ['imagekit', 'backblaze'], required: true },
|
|
11
|
+
status: { type: String, enum: ['temp', 'permanent', 'deleted'], required: true },
|
|
12
|
+
// ImageKit specific
|
|
13
|
+
fileId: String,
|
|
14
|
+
url: String,
|
|
15
|
+
thumbnailUrl: String,
|
|
16
|
+
// Backblaze specific
|
|
17
|
+
bucketName: String,
|
|
18
|
+
objectKey: String,
|
|
19
|
+
// Metadata
|
|
20
|
+
filename: { type: String, required: true },
|
|
21
|
+
mimeType: { type: String, required: true },
|
|
22
|
+
size: { type: Number, required: false },
|
|
23
|
+
// Lifecycle
|
|
24
|
+
uploadedAt: { type: Date, default: Date.now },
|
|
25
|
+
movedToPermanentAt: Date,
|
|
26
|
+
expiresAt: Date, // For temp files
|
|
27
|
+
deletedAt: Date,
|
|
28
|
+
});
|
|
29
|
+
// Indexes
|
|
30
|
+
mediaSchema.index({ userId: 1 });
|
|
31
|
+
mediaSchema.index({ status: 1 });
|
|
32
|
+
mediaSchema.index({ expiresAt: 1 });
|
|
33
|
+
mediaSchema.index({ uploadedAt: 1 });
|
|
34
|
+
exports.default = mediaSchema;
|
package/dist/Order.d.ts
ADDED
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import mongoose from 'mongoose';
|
|
2
|
+
declare const orderSchema: mongoose.Schema<any, mongoose.Model<any, any, any, any, any, any>, {}, {}, {}, {}, mongoose.DefaultSchemaOptions, {
|
|
3
|
+
createdAt: NativeDate;
|
|
4
|
+
status: "pending" | "cancelled" | "confirmed" | "refunded";
|
|
5
|
+
tickets: mongoose.Types.DocumentArray<{
|
|
6
|
+
quantity: number;
|
|
7
|
+
ticketVariantId: mongoose.Types.ObjectId;
|
|
8
|
+
variantName: string;
|
|
9
|
+
pricePerTicket: number;
|
|
10
|
+
subtotal: number;
|
|
11
|
+
}, mongoose.Types.Subdocument<mongoose.mongo.BSON.ObjectId, any, {
|
|
12
|
+
quantity: number;
|
|
13
|
+
ticketVariantId: mongoose.Types.ObjectId;
|
|
14
|
+
variantName: string;
|
|
15
|
+
pricePerTicket: number;
|
|
16
|
+
subtotal: number;
|
|
17
|
+
}> & {
|
|
18
|
+
quantity: number;
|
|
19
|
+
ticketVariantId: mongoose.Types.ObjectId;
|
|
20
|
+
variantName: string;
|
|
21
|
+
pricePerTicket: number;
|
|
22
|
+
subtotal: number;
|
|
23
|
+
}>;
|
|
24
|
+
expiresAt: NativeDate;
|
|
25
|
+
userId: mongoose.Types.ObjectId;
|
|
26
|
+
orderNumber: string;
|
|
27
|
+
eventId: mongoose.Types.ObjectId;
|
|
28
|
+
requiresManualReview: boolean;
|
|
29
|
+
manualReviewReason: string;
|
|
30
|
+
paymentMethod: "card" | "bkash" | "bank_transfer";
|
|
31
|
+
paymentStatus: "pending" | "succeeded" | "failed";
|
|
32
|
+
ticketIds: mongoose.Types.ObjectId[];
|
|
33
|
+
buyerEmail: string;
|
|
34
|
+
paidAt?: NativeDate | null | undefined;
|
|
35
|
+
pricing?: {
|
|
36
|
+
currency: string;
|
|
37
|
+
platformFee: number;
|
|
38
|
+
subtotal: number;
|
|
39
|
+
paymentFee: number;
|
|
40
|
+
total: number;
|
|
41
|
+
hostPayout: number;
|
|
42
|
+
} | null | undefined;
|
|
43
|
+
refundedAt?: NativeDate | null | undefined;
|
|
44
|
+
confirmedAt?: NativeDate | null | undefined;
|
|
45
|
+
cancelledAt?: NativeDate | null | undefined;
|
|
46
|
+
reminderSentAt?: NativeDate | null | undefined;
|
|
47
|
+
buyerPhone?: string | null | undefined;
|
|
48
|
+
ipAddress?: string | null | undefined;
|
|
49
|
+
userAgent?: string | null | undefined;
|
|
50
|
+
refund?: {
|
|
51
|
+
amount: number;
|
|
52
|
+
reason: "event_cancelled" | "user_request" | "fraud";
|
|
53
|
+
refundedAt: NativeDate;
|
|
54
|
+
stripeRefundId?: string | null | undefined;
|
|
55
|
+
} | null | undefined;
|
|
56
|
+
paymentId?: string | null | undefined;
|
|
57
|
+
}, mongoose.Document<unknown, {}, mongoose.FlatRecord<{
|
|
58
|
+
createdAt: NativeDate;
|
|
59
|
+
status: "pending" | "cancelled" | "confirmed" | "refunded";
|
|
60
|
+
tickets: mongoose.Types.DocumentArray<{
|
|
61
|
+
quantity: number;
|
|
62
|
+
ticketVariantId: mongoose.Types.ObjectId;
|
|
63
|
+
variantName: string;
|
|
64
|
+
pricePerTicket: number;
|
|
65
|
+
subtotal: number;
|
|
66
|
+
}, mongoose.Types.Subdocument<mongoose.mongo.BSON.ObjectId, any, {
|
|
67
|
+
quantity: number;
|
|
68
|
+
ticketVariantId: mongoose.Types.ObjectId;
|
|
69
|
+
variantName: string;
|
|
70
|
+
pricePerTicket: number;
|
|
71
|
+
subtotal: number;
|
|
72
|
+
}> & {
|
|
73
|
+
quantity: number;
|
|
74
|
+
ticketVariantId: mongoose.Types.ObjectId;
|
|
75
|
+
variantName: string;
|
|
76
|
+
pricePerTicket: number;
|
|
77
|
+
subtotal: number;
|
|
78
|
+
}>;
|
|
79
|
+
expiresAt: NativeDate;
|
|
80
|
+
userId: mongoose.Types.ObjectId;
|
|
81
|
+
orderNumber: string;
|
|
82
|
+
eventId: mongoose.Types.ObjectId;
|
|
83
|
+
requiresManualReview: boolean;
|
|
84
|
+
manualReviewReason: string;
|
|
85
|
+
paymentMethod: "card" | "bkash" | "bank_transfer";
|
|
86
|
+
paymentStatus: "pending" | "succeeded" | "failed";
|
|
87
|
+
ticketIds: mongoose.Types.ObjectId[];
|
|
88
|
+
buyerEmail: string;
|
|
89
|
+
paidAt?: NativeDate | null | undefined;
|
|
90
|
+
pricing?: {
|
|
91
|
+
currency: string;
|
|
92
|
+
platformFee: number;
|
|
93
|
+
subtotal: number;
|
|
94
|
+
paymentFee: number;
|
|
95
|
+
total: number;
|
|
96
|
+
hostPayout: number;
|
|
97
|
+
} | null | undefined;
|
|
98
|
+
refundedAt?: NativeDate | null | undefined;
|
|
99
|
+
confirmedAt?: NativeDate | null | undefined;
|
|
100
|
+
cancelledAt?: NativeDate | null | undefined;
|
|
101
|
+
reminderSentAt?: NativeDate | null | undefined;
|
|
102
|
+
buyerPhone?: string | null | undefined;
|
|
103
|
+
ipAddress?: string | null | undefined;
|
|
104
|
+
userAgent?: string | null | undefined;
|
|
105
|
+
refund?: {
|
|
106
|
+
amount: number;
|
|
107
|
+
reason: "event_cancelled" | "user_request" | "fraud";
|
|
108
|
+
refundedAt: NativeDate;
|
|
109
|
+
stripeRefundId?: string | null | undefined;
|
|
110
|
+
} | null | undefined;
|
|
111
|
+
paymentId?: string | null | undefined;
|
|
112
|
+
}>, {}, mongoose.ResolveSchemaOptions<mongoose.DefaultSchemaOptions>> & mongoose.FlatRecord<{
|
|
113
|
+
createdAt: NativeDate;
|
|
114
|
+
status: "pending" | "cancelled" | "confirmed" | "refunded";
|
|
115
|
+
tickets: mongoose.Types.DocumentArray<{
|
|
116
|
+
quantity: number;
|
|
117
|
+
ticketVariantId: mongoose.Types.ObjectId;
|
|
118
|
+
variantName: string;
|
|
119
|
+
pricePerTicket: number;
|
|
120
|
+
subtotal: number;
|
|
121
|
+
}, mongoose.Types.Subdocument<mongoose.mongo.BSON.ObjectId, any, {
|
|
122
|
+
quantity: number;
|
|
123
|
+
ticketVariantId: mongoose.Types.ObjectId;
|
|
124
|
+
variantName: string;
|
|
125
|
+
pricePerTicket: number;
|
|
126
|
+
subtotal: number;
|
|
127
|
+
}> & {
|
|
128
|
+
quantity: number;
|
|
129
|
+
ticketVariantId: mongoose.Types.ObjectId;
|
|
130
|
+
variantName: string;
|
|
131
|
+
pricePerTicket: number;
|
|
132
|
+
subtotal: number;
|
|
133
|
+
}>;
|
|
134
|
+
expiresAt: NativeDate;
|
|
135
|
+
userId: mongoose.Types.ObjectId;
|
|
136
|
+
orderNumber: string;
|
|
137
|
+
eventId: mongoose.Types.ObjectId;
|
|
138
|
+
requiresManualReview: boolean;
|
|
139
|
+
manualReviewReason: string;
|
|
140
|
+
paymentMethod: "card" | "bkash" | "bank_transfer";
|
|
141
|
+
paymentStatus: "pending" | "succeeded" | "failed";
|
|
142
|
+
ticketIds: mongoose.Types.ObjectId[];
|
|
143
|
+
buyerEmail: string;
|
|
144
|
+
paidAt?: NativeDate | null | undefined;
|
|
145
|
+
pricing?: {
|
|
146
|
+
currency: string;
|
|
147
|
+
platformFee: number;
|
|
148
|
+
subtotal: number;
|
|
149
|
+
paymentFee: number;
|
|
150
|
+
total: number;
|
|
151
|
+
hostPayout: number;
|
|
152
|
+
} | null | undefined;
|
|
153
|
+
refundedAt?: NativeDate | null | undefined;
|
|
154
|
+
confirmedAt?: NativeDate | null | undefined;
|
|
155
|
+
cancelledAt?: NativeDate | null | undefined;
|
|
156
|
+
reminderSentAt?: NativeDate | null | undefined;
|
|
157
|
+
buyerPhone?: string | null | undefined;
|
|
158
|
+
ipAddress?: string | null | undefined;
|
|
159
|
+
userAgent?: string | null | undefined;
|
|
160
|
+
refund?: {
|
|
161
|
+
amount: number;
|
|
162
|
+
reason: "event_cancelled" | "user_request" | "fraud";
|
|
163
|
+
refundedAt: NativeDate;
|
|
164
|
+
stripeRefundId?: string | null | undefined;
|
|
165
|
+
} | null | undefined;
|
|
166
|
+
paymentId?: string | null | undefined;
|
|
167
|
+
}> & {
|
|
168
|
+
_id: mongoose.Types.ObjectId;
|
|
169
|
+
} & {
|
|
170
|
+
__v: number;
|
|
171
|
+
}>;
|
|
172
|
+
export default orderSchema;
|
package/dist/Order.js
ADDED
|
@@ -0,0 +1,184 @@
|
|
|
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
|
+
// Order Ticket Schema
|
|
8
|
+
const orderTicketSchema = new mongoose_1.default.Schema({
|
|
9
|
+
ticketVariantId: {
|
|
10
|
+
type: mongoose_1.default.Schema.Types.ObjectId,
|
|
11
|
+
required: true
|
|
12
|
+
},
|
|
13
|
+
variantName: {
|
|
14
|
+
type: String,
|
|
15
|
+
required: true
|
|
16
|
+
},
|
|
17
|
+
quantity: {
|
|
18
|
+
type: Number,
|
|
19
|
+
required: true,
|
|
20
|
+
min: 1
|
|
21
|
+
},
|
|
22
|
+
pricePerTicket: {
|
|
23
|
+
type: Number,
|
|
24
|
+
required: true,
|
|
25
|
+
min: 0
|
|
26
|
+
},
|
|
27
|
+
subtotal: {
|
|
28
|
+
type: Number,
|
|
29
|
+
required: true,
|
|
30
|
+
min: 0
|
|
31
|
+
}
|
|
32
|
+
}, { _id: false });
|
|
33
|
+
// Pricing Schema
|
|
34
|
+
const pricingSchema = new mongoose_1.default.Schema({
|
|
35
|
+
subtotal: {
|
|
36
|
+
type: Number,
|
|
37
|
+
required: true,
|
|
38
|
+
min: 0
|
|
39
|
+
},
|
|
40
|
+
platformFee: {
|
|
41
|
+
type: Number,
|
|
42
|
+
required: true,
|
|
43
|
+
min: 0
|
|
44
|
+
},
|
|
45
|
+
paymentFee: {
|
|
46
|
+
type: Number,
|
|
47
|
+
required: true,
|
|
48
|
+
min: 0
|
|
49
|
+
},
|
|
50
|
+
total: {
|
|
51
|
+
type: Number,
|
|
52
|
+
required: true,
|
|
53
|
+
min: 0
|
|
54
|
+
},
|
|
55
|
+
currency: {
|
|
56
|
+
type: String,
|
|
57
|
+
required: true,
|
|
58
|
+
default: 'BDT'
|
|
59
|
+
},
|
|
60
|
+
hostPayout: {
|
|
61
|
+
type: Number,
|
|
62
|
+
required: true,
|
|
63
|
+
min: 0
|
|
64
|
+
}
|
|
65
|
+
}, { _id: false });
|
|
66
|
+
// Refund Schema
|
|
67
|
+
const refundSchema = new mongoose_1.default.Schema({
|
|
68
|
+
reason: {
|
|
69
|
+
type: String,
|
|
70
|
+
required: true,
|
|
71
|
+
enum: ['event_cancelled', 'user_request', 'fraud']
|
|
72
|
+
},
|
|
73
|
+
amount: {
|
|
74
|
+
type: Number,
|
|
75
|
+
required: true,
|
|
76
|
+
min: 0
|
|
77
|
+
},
|
|
78
|
+
refundedAt: {
|
|
79
|
+
type: Date,
|
|
80
|
+
default: Date.now
|
|
81
|
+
},
|
|
82
|
+
stripeRefundId: String
|
|
83
|
+
}, { _id: false });
|
|
84
|
+
// Main Order Schema
|
|
85
|
+
const orderSchema = new mongoose_1.default.Schema({
|
|
86
|
+
orderNumber: {
|
|
87
|
+
type: String,
|
|
88
|
+
required: true,
|
|
89
|
+
unique: true,
|
|
90
|
+
},
|
|
91
|
+
// WHO
|
|
92
|
+
userId: {
|
|
93
|
+
type: mongoose_1.default.Schema.Types.ObjectId,
|
|
94
|
+
required: true,
|
|
95
|
+
},
|
|
96
|
+
// WHAT
|
|
97
|
+
eventId: {
|
|
98
|
+
type: mongoose_1.default.Schema.Types.ObjectId,
|
|
99
|
+
required: true,
|
|
100
|
+
},
|
|
101
|
+
paymentId: {
|
|
102
|
+
type: String,
|
|
103
|
+
required: false,
|
|
104
|
+
},
|
|
105
|
+
tickets: [orderTicketSchema],
|
|
106
|
+
// MONEY
|
|
107
|
+
pricing: pricingSchema,
|
|
108
|
+
// STATUS
|
|
109
|
+
status: {
|
|
110
|
+
type: String,
|
|
111
|
+
required: true,
|
|
112
|
+
enum: ['pending', 'confirmed', 'cancelled', 'refunded'],
|
|
113
|
+
default: 'pending'
|
|
114
|
+
},
|
|
115
|
+
requiresManualReview: {
|
|
116
|
+
type: Boolean,
|
|
117
|
+
default: false
|
|
118
|
+
},
|
|
119
|
+
manualReviewReason: {
|
|
120
|
+
type: String,
|
|
121
|
+
default: null
|
|
122
|
+
},
|
|
123
|
+
paymentMethod: {
|
|
124
|
+
type: String,
|
|
125
|
+
required: true,
|
|
126
|
+
enum: ['card', 'bkash', 'bank_transfer']
|
|
127
|
+
},
|
|
128
|
+
paymentStatus: {
|
|
129
|
+
type: String,
|
|
130
|
+
required: true,
|
|
131
|
+
enum: ['pending', 'succeeded', 'failed'],
|
|
132
|
+
default: 'pending'
|
|
133
|
+
},
|
|
134
|
+
paidAt: Date,
|
|
135
|
+
// TICKETS ISSUED
|
|
136
|
+
ticketIds: [{
|
|
137
|
+
type: mongoose_1.default.Schema.Types.ObjectId,
|
|
138
|
+
ref: 'Ticket'
|
|
139
|
+
}],
|
|
140
|
+
// LIFECYCLE
|
|
141
|
+
createdAt: {
|
|
142
|
+
type: Date,
|
|
143
|
+
default: Date.now,
|
|
144
|
+
index: true
|
|
145
|
+
},
|
|
146
|
+
expiresAt: {
|
|
147
|
+
type: Date,
|
|
148
|
+
required: true
|
|
149
|
+
},
|
|
150
|
+
confirmedAt: Date,
|
|
151
|
+
cancelledAt: Date,
|
|
152
|
+
refundedAt: Date,
|
|
153
|
+
reminderSentAt: Date,
|
|
154
|
+
// CONTACT
|
|
155
|
+
buyerEmail: {
|
|
156
|
+
type: String,
|
|
157
|
+
required: true
|
|
158
|
+
},
|
|
159
|
+
buyerPhone: String,
|
|
160
|
+
// AUDIT
|
|
161
|
+
ipAddress: String,
|
|
162
|
+
userAgent: String,
|
|
163
|
+
// REFUND (if applicable)
|
|
164
|
+
refund: refundSchema
|
|
165
|
+
});
|
|
166
|
+
// Indexes for performance
|
|
167
|
+
orderSchema.index({ userId: 1, createdAt: -1 });
|
|
168
|
+
orderSchema.index({ eventId: 1, status: 1 });
|
|
169
|
+
orderSchema.index({ status: 1, expiresAt: 1 });
|
|
170
|
+
// Auto-generate order number
|
|
171
|
+
orderSchema.pre('save', function (next) {
|
|
172
|
+
if (this.isNew && !this.orderNumber) {
|
|
173
|
+
const timestamp = Date.now().toString().slice(-6);
|
|
174
|
+
const random = Math.random().toString(36).substring(2, 8).toUpperCase();
|
|
175
|
+
this.orderNumber = `ORD-${timestamp}-${random}`;
|
|
176
|
+
}
|
|
177
|
+
next();
|
|
178
|
+
});
|
|
179
|
+
// Update updatedAt on save
|
|
180
|
+
orderSchema.pre('save', function (next) {
|
|
181
|
+
// Note: We don't have updatedAt field, but could add if needed
|
|
182
|
+
next();
|
|
183
|
+
});
|
|
184
|
+
exports.default = orderSchema;
|