@mac777/project-pinecone-schema 1.0.0 → 1.0.2
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/events/events.schema.d.ts +55 -0
- package/dist/events/utils/ticket.schema.d.ts +3 -0
- package/dist/events/utils/ticket.schema.js +1 -0
- package/package.json +2 -5
- package/src/auth/auth.constants.ts +9 -0
- package/src/auth/auth.schema.ts +65 -0
- package/src/auth/auth.type.ts +42 -0
- package/src/auth/index.ts +3 -0
- package/src/auth/utils/password.schema.ts +18 -0
- package/src/events/events.constants.ts +182 -0
- package/src/events/events.schema.ts +158 -0
- package/src/events/events.type.ts +59 -0
- package/src/events/events.utils.schema.ts +5 -0
- package/{dist/events/events.d.ts → src/events/index.ts} +4 -3
- package/src/events/utils/admin.schema.ts +77 -0
- package/src/events/utils/age.restriction.schema.ts +3 -0
- package/src/events/utils/document.schema.ts +8 -0
- package/src/events/utils/event.type.schema.ts +3 -0
- package/src/events/utils/media.schema.ts +36 -0
- package/src/events/utils/organizer.schema.ts +14 -0
- package/src/events/utils/schedule.schema.ts +10 -0
- package/src/events/utils/ticket.schema.ts +33 -0
- package/src/events/utils/venue.schema.ts +22 -0
- package/src/index.ts +5 -0
- package/src/media/index.ts +2 -0
- package/src/media/media.schema.ts +37 -0
- package/src/media/media.type.ts +18 -0
- package/src/media/utils/backblaze.schema.ts +8 -0
- package/src/media/utils/imagekit.schema.ts +20 -0
- package/src/orders/index.ts +6 -0
- package/src/orders/orders.schema.ts +106 -0
- package/src/orders/orders.type.ts +85 -0
- package/src/orders/payments.schema.ts +81 -0
- package/src/orders/payments.type.ts +87 -0
- package/src/orders/ticket.schema.ts +78 -0
- package/src/orders/ticket.type.ts +103 -0
- package/tsconfig.json +13 -0
- package/dist/auth.d.ts +0 -1
- package/dist/auth.js +0 -18
- package/dist/events/admin.schema.d.ts +0 -208
- package/dist/events/admin.schema.js +0 -70
- package/dist/events/age.restriction.schema.d.ts +0 -2
- package/dist/events/age.restriction.schema.js +0 -5
- package/dist/events/document.schema.d.ts +0 -17
- package/dist/events/document.schema.js +0 -10
- package/dist/events/event.schema.d.ts +0 -0
- package/dist/events/event.schema.js +0 -1
- package/dist/events/event.type.schema.d.ts +0 -2
- package/dist/events/event.type.schema.js +0 -5
- package/dist/events/events.constant.d.ts +0 -9
- package/dist/events/events.constant.js +0 -12
- package/dist/events/events.js +0 -19
- package/dist/events/media.schema.d.ts +0 -77
- package/dist/events/media.schema.js +0 -36
- package/dist/events/organizer.schema.d.ts +0 -55
- package/dist/events/organizer.schema.js +0 -15
- package/dist/events/schedule.schema.d.ts +0 -20
- package/dist/events/schedule.schema.js +0 -11
- package/dist/events/step.schema.d.ts +0 -0
- package/dist/events/step.schema.js +0 -1
- package/dist/events/ticket.schema.d.ts +0 -113
- package/dist/events/ticket.schema.js +0 -29
- package/dist/events/utils.schema.d.ts +0 -6
- package/dist/events/utils.schema.js +0 -22
- package/dist/events/venue.schema.d.ts +0 -75
- package/dist/events/venue.schema.js +0 -22
- package/dist/events.constant.d.ts +0 -9
- package/dist/events.constant.js +0 -12
- package/dist/events.constants.d.ts +0 -9
- package/dist/events.constants.js +0 -12
- package/dist/events.d.ts +0 -39
- package/dist/events.js +0 -2
- package/dist/events.schema.d.ts +0 -229
- package/dist/events.schema.js +0 -95
- package/dist/events.type.d.ts +0 -42
- package/dist/events.type.js +0 -2
- package/dist/events.utils.schema.d.ts +0 -6
- package/dist/events.utils.schema.js +0 -22
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { backblazeUploadUrlSchema } from './utils/backblaze.schema';
|
|
3
|
+
import { imageKitAuthSchema, imageKitFinalizeSchema, imageKitTrackSchema } from './utils/imagekit.schema';
|
|
4
|
+
|
|
5
|
+
// =============================================================================
|
|
6
|
+
// MEDIA SCHEMAS
|
|
7
|
+
// =============================================================================
|
|
8
|
+
|
|
9
|
+
// Re-export utility schemas for convenience
|
|
10
|
+
export { backblazeUploadUrlSchema } from './utils/backblaze.schema';
|
|
11
|
+
export { imageKitAuthSchema, imageKitFinalizeSchema, imageKitTrackSchema } from './utils/imagekit.schema';
|
|
12
|
+
|
|
13
|
+
// Common media types enum
|
|
14
|
+
export const mediaTypeSchema = z.enum(['event_cover', 'event_gallery', 'verification_doc']);
|
|
15
|
+
|
|
16
|
+
// File upload response schema
|
|
17
|
+
export const fileUploadResponseSchema = z.object({
|
|
18
|
+
url: z.string(),
|
|
19
|
+
key: z.string(),
|
|
20
|
+
bucket: z.string(),
|
|
21
|
+
fileName: z.string(),
|
|
22
|
+
fileType: z.string(),
|
|
23
|
+
size: z.number(),
|
|
24
|
+
uploadedAt: z.date(),
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
// Document schema (used in events)
|
|
28
|
+
export const documentSchema = z.object({
|
|
29
|
+
id: z.string().optional(),
|
|
30
|
+
name: z.string({ required_error: 'Document name is required' }),
|
|
31
|
+
url: z.string({ required_error: 'Document URL is required' }),
|
|
32
|
+
type: mediaTypeSchema,
|
|
33
|
+
size: z.number({ required_error: 'Document size is required' }),
|
|
34
|
+
mimeType: z.string({ required_error: 'Document MIME type is required' }),
|
|
35
|
+
uploadedAt: z.date().optional(),
|
|
36
|
+
objectKey: z.string().optional(), // For S3/Backblaze reference
|
|
37
|
+
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { mediaTypeSchema, fileUploadResponseSchema } from './media.schema';
|
|
3
|
+
|
|
4
|
+
// =============================================================================
|
|
5
|
+
// TYPE EXPORTS
|
|
6
|
+
// =============================================================================
|
|
7
|
+
|
|
8
|
+
// Media types
|
|
9
|
+
export type MediaType = z.infer<typeof mediaTypeSchema>;
|
|
10
|
+
export type FileUploadResponse = z.infer<typeof fileUploadResponseSchema>;
|
|
11
|
+
|
|
12
|
+
// Backblaze types
|
|
13
|
+
export type BackblazeUploadUrlInput = z.infer<typeof import('./utils/backblaze.schema').backblazeUploadUrlSchema>;
|
|
14
|
+
|
|
15
|
+
// ImageKit types
|
|
16
|
+
export type ImageKitAuthInput = z.infer<typeof import('./utils/imagekit.schema').imageKitAuthSchema>;
|
|
17
|
+
export type ImageKitFinalizeInput = z.infer<typeof import('./utils/imagekit.schema').imageKitFinalizeSchema>;
|
|
18
|
+
export type ImageKitTrackInput = z.infer<typeof import('./utils/imagekit.schema').imageKitTrackSchema>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
// Schema for Backblaze upload URL endpoint
|
|
4
|
+
export const backblazeUploadUrlSchema = z.object({
|
|
5
|
+
filename: z.string({ required_error: 'File name is required' }),
|
|
6
|
+
fileType: z.string({ required_error: 'File type is required' }),
|
|
7
|
+
documentType: z.enum(['event_cover', 'event_gallery', 'verification_doc']).default('verification_doc'),
|
|
8
|
+
});
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
// Schema for ImageKit auth endpoint - GET request, no body needed
|
|
4
|
+
export const imageKitAuthSchema = z.object({});
|
|
5
|
+
|
|
6
|
+
// Schema for ImageKit finalize endpoint
|
|
7
|
+
export const imageKitFinalizeSchema = z.object({
|
|
8
|
+
fileId: z.string({ required_error: 'File ID is required' }),
|
|
9
|
+
fromFolder: z.string({ required_error: 'From folder is required' }),
|
|
10
|
+
toFolder: z.string({ required_error: 'To folder is required' }),
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
// Schema for ImageKit track endpoint
|
|
14
|
+
export const imageKitTrackSchema = z.object({
|
|
15
|
+
fileId: z.string({ required_error: 'File ID is required' }),
|
|
16
|
+
url: z.string({ required_error: 'URL is required' }),
|
|
17
|
+
filename: z.string({ required_error: 'Filename is required' }),
|
|
18
|
+
type: z.enum(['event_cover', 'event_gallery', 'verification_doc']),
|
|
19
|
+
status: z.enum(['temp', 'permanent', 'deleted']).default('temp'),
|
|
20
|
+
});
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
// Order ticket schema (embedded in order)
|
|
4
|
+
export const orderTicketSchema = z.object({
|
|
5
|
+
ticketVariantId: z.string(),
|
|
6
|
+
variantName: z.string(),
|
|
7
|
+
quantity: z.number().min(1),
|
|
8
|
+
pricePerTicket: z.number().min(0),
|
|
9
|
+
subtotal: z.number().min(0)
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
// Pricing schema (embedded in order)
|
|
13
|
+
export const orderPricingSchema = z.object({
|
|
14
|
+
subtotal: z.number().min(0),
|
|
15
|
+
platformFee: z.number().min(0),
|
|
16
|
+
paymentFee: z.number().min(0),
|
|
17
|
+
total: z.number().min(0),
|
|
18
|
+
currency: z.string().default('BDT'),
|
|
19
|
+
hostPayout: z.number().min(0)
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
// Refund schema (embedded in order)
|
|
23
|
+
export const refundSchema = z.object({
|
|
24
|
+
reason: z.enum(['event_cancelled', 'user_request', 'fraud']),
|
|
25
|
+
amount: z.number().min(0),
|
|
26
|
+
refundedAt: z.date().default(() => new Date()),
|
|
27
|
+
stripeRefundId: z.string().optional()
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
// Main order schema
|
|
31
|
+
export const orderSchema = z.object({
|
|
32
|
+
_id: z.string().optional(), // MongoDB ObjectId
|
|
33
|
+
orderNumber: z.string().regex(/^ORD-\d{6}-[A-Z0-9]{6}$/), // ORD-123456-ABC123
|
|
34
|
+
|
|
35
|
+
// WHO
|
|
36
|
+
userId: z.string(), // Buyer
|
|
37
|
+
|
|
38
|
+
// WHAT
|
|
39
|
+
eventId: z.string(), // Which event
|
|
40
|
+
|
|
41
|
+
tickets: z.array(orderTicketSchema).min(1),
|
|
42
|
+
|
|
43
|
+
// MONEY
|
|
44
|
+
pricing: orderPricingSchema,
|
|
45
|
+
|
|
46
|
+
// STATUS
|
|
47
|
+
status: z.enum(['pending', 'confirmed', 'cancelled', 'refunded']).default('pending'),
|
|
48
|
+
|
|
49
|
+
// PAYMENT
|
|
50
|
+
paymentMethod: z.enum(['card', 'bkash', 'bank_transfer']),
|
|
51
|
+
paymentStatus: z.enum(['pending', 'succeeded', 'failed']).default('pending'),
|
|
52
|
+
paidAt: z.date().optional(),
|
|
53
|
+
|
|
54
|
+
// TICKETS ISSUED
|
|
55
|
+
ticketIds: z.array(z.string()).default([]),
|
|
56
|
+
|
|
57
|
+
// LIFECYCLE
|
|
58
|
+
createdAt: z.date().default(() => new Date()),
|
|
59
|
+
expiresAt: z.date(), // Must be set when creating
|
|
60
|
+
confirmedAt: z.date().optional(),
|
|
61
|
+
cancelledAt: z.date().optional(),
|
|
62
|
+
refundedAt: z.date().optional(),
|
|
63
|
+
|
|
64
|
+
// CONTACT
|
|
65
|
+
buyerEmail: z.string().email(),
|
|
66
|
+
buyerPhone: z.string().optional(),
|
|
67
|
+
|
|
68
|
+
// AUDIT
|
|
69
|
+
ipAddress: z.string().optional(),
|
|
70
|
+
userAgent: z.string().optional(),
|
|
71
|
+
|
|
72
|
+
// REFUND (if applicable)
|
|
73
|
+
refund: refundSchema.optional()
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
// API Request/Response schemas
|
|
77
|
+
export const createOrderSchema = z.object({
|
|
78
|
+
eventId: z.string(),
|
|
79
|
+
tickets: z.array(z.object({
|
|
80
|
+
ticketVariantId: z.string(),
|
|
81
|
+
variantName: z.string(),
|
|
82
|
+
quantity: z.number().min(1),
|
|
83
|
+
pricePerTicket: z.number().min(0)
|
|
84
|
+
})).min(1),
|
|
85
|
+
paymentMethod: z.enum(['card', 'bkash', 'bank_transfer']),
|
|
86
|
+
buyerEmail: z.string().email(),
|
|
87
|
+
buyerPhone: z.string().optional()
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
export const confirmOrderSchema = z.object({
|
|
91
|
+
ticketIds: z.array(z.string())
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
export const refundOrderSchema = z.object({
|
|
95
|
+
reason: z.enum(['event_cancelled', 'user_request', 'fraud']),
|
|
96
|
+
amount: z.number().min(0)
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
export const updateOrderStatusSchema = z.object({
|
|
100
|
+
status: z.enum(['pending', 'confirmed', 'cancelled', 'refunded']),
|
|
101
|
+
adminNotes: z.string().optional()
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
// Response schemas
|
|
105
|
+
export const orderResponseSchema = orderSchema;
|
|
106
|
+
export const ordersListResponseSchema = z.array(orderResponseSchema);
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import {
|
|
3
|
+
orderSchema,
|
|
4
|
+
orderTicketSchema,
|
|
5
|
+
orderPricingSchema,
|
|
6
|
+
refundSchema,
|
|
7
|
+
createOrderSchema,
|
|
8
|
+
confirmOrderSchema,
|
|
9
|
+
refundOrderSchema,
|
|
10
|
+
updateOrderStatusSchema,
|
|
11
|
+
orderResponseSchema,
|
|
12
|
+
ordersListResponseSchema
|
|
13
|
+
} from './orders.schema';
|
|
14
|
+
import { PaymentMethod } from './payments.type';
|
|
15
|
+
|
|
16
|
+
// =============================================================================
|
|
17
|
+
// TYPE EXPORTS
|
|
18
|
+
// =============================================================================
|
|
19
|
+
|
|
20
|
+
// Embedded schema types
|
|
21
|
+
export type OrderTicket = z.infer<typeof orderTicketSchema>;
|
|
22
|
+
export type OrderPricing = z.infer<typeof orderPricingSchema>;
|
|
23
|
+
export type Refund = z.infer<typeof refundSchema>;
|
|
24
|
+
|
|
25
|
+
// Main order types
|
|
26
|
+
export type Order = z.infer<typeof orderSchema>;
|
|
27
|
+
export type OrderStatus = Order['status'];
|
|
28
|
+
|
|
29
|
+
// API request/response types
|
|
30
|
+
export type CreateOrderRequest = z.infer<typeof createOrderSchema>;
|
|
31
|
+
export type ConfirmOrderRequest = z.infer<typeof confirmOrderSchema>;
|
|
32
|
+
export type RefundOrderRequest = z.infer<typeof refundOrderSchema>;
|
|
33
|
+
export type UpdateOrderStatusRequest = z.infer<typeof updateOrderStatusSchema>;
|
|
34
|
+
|
|
35
|
+
export type OrderResponse = z.infer<typeof orderResponseSchema>;
|
|
36
|
+
export type OrdersListResponse = z.infer<typeof ordersListResponseSchema>;
|
|
37
|
+
|
|
38
|
+
// Service method parameter types
|
|
39
|
+
export interface CreateOrderData {
|
|
40
|
+
userId: string;
|
|
41
|
+
eventId: string;
|
|
42
|
+
tickets: Array<{
|
|
43
|
+
ticketVariantId: string;
|
|
44
|
+
variantName: string;
|
|
45
|
+
quantity: number;
|
|
46
|
+
pricePerTicket: number;
|
|
47
|
+
}>;
|
|
48
|
+
paymentMethod: PaymentMethod;
|
|
49
|
+
buyerEmail: string;
|
|
50
|
+
buyerPhone?: string;
|
|
51
|
+
ipAddress?: string;
|
|
52
|
+
userAgent?: string;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// Service response types
|
|
56
|
+
export interface CreateOrderResponse {
|
|
57
|
+
orderId: string;
|
|
58
|
+
orderNumber: string;
|
|
59
|
+
paymentIntentId: string;
|
|
60
|
+
total: number;
|
|
61
|
+
expiresAt: Date;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// Utility types for frontend (populated responses)
|
|
65
|
+
export interface OrderWithEvent extends Omit<Order, 'eventId'> {
|
|
66
|
+
eventId: {
|
|
67
|
+
_id: string;
|
|
68
|
+
title: string;
|
|
69
|
+
schedule: {
|
|
70
|
+
venue: {
|
|
71
|
+
name: string;
|
|
72
|
+
};
|
|
73
|
+
startDate: string;
|
|
74
|
+
};
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export interface OrderWithTickets extends Omit<Order, 'ticketIds'> {
|
|
79
|
+
ticketIds: Array<{
|
|
80
|
+
_id: string;
|
|
81
|
+
ticketNumber: string;
|
|
82
|
+
qrCode: string;
|
|
83
|
+
status: 'active' | 'used' | 'cancelled';
|
|
84
|
+
}>;
|
|
85
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
// Payment status enum
|
|
4
|
+
export const paymentStatusSchema = z.enum(['pending', 'succeeded', 'failed', 'refunded']);
|
|
5
|
+
|
|
6
|
+
// Payment method enum
|
|
7
|
+
export const paymentMethodSchema = z.enum(['bkash', 'card']);
|
|
8
|
+
|
|
9
|
+
// Card brand enum
|
|
10
|
+
export const cardBrandSchema = z.enum(['visa', 'mastercard', 'amex', 'discover']);
|
|
11
|
+
|
|
12
|
+
// Failure codes enum
|
|
13
|
+
export const failureCodeSchema = z.enum([
|
|
14
|
+
'insufficient_funds',
|
|
15
|
+
'card_declined',
|
|
16
|
+
'expired_card',
|
|
17
|
+
'incorrect_cvc',
|
|
18
|
+
'processing_error',
|
|
19
|
+
'issuer_not_available',
|
|
20
|
+
'invalid_card_number'
|
|
21
|
+
]);
|
|
22
|
+
|
|
23
|
+
// Main payment schema
|
|
24
|
+
export const paymentSchema = z.object({
|
|
25
|
+
_id: z.string().optional(), // MongoDB ObjectId
|
|
26
|
+
|
|
27
|
+
// LINKS
|
|
28
|
+
orderId: z.string(), // Which order
|
|
29
|
+
userId: z.string(), // Who paid
|
|
30
|
+
|
|
31
|
+
// STRIPE
|
|
32
|
+
paymentId: z.string(), // Stripe PI
|
|
33
|
+
|
|
34
|
+
// MONEY
|
|
35
|
+
amount: z.number().min(0),
|
|
36
|
+
currency: z.string().default('BDT'),
|
|
37
|
+
|
|
38
|
+
// STATUS
|
|
39
|
+
status: paymentStatusSchema,
|
|
40
|
+
|
|
41
|
+
// METADATA
|
|
42
|
+
paymentMethod: paymentMethodSchema,
|
|
43
|
+
last4: z.string().optional(), // Card last 4 digits
|
|
44
|
+
brand: cardBrandSchema.optional(), // Card brand
|
|
45
|
+
|
|
46
|
+
// FAILURE (if failed)
|
|
47
|
+
failureCode: failureCodeSchema.optional(),
|
|
48
|
+
failureMessage: z.string().optional(),
|
|
49
|
+
|
|
50
|
+
// REFUND (if refunded)
|
|
51
|
+
refundId: z.string().optional(), // Stripe refund ID
|
|
52
|
+
refundAmount: z.number().min(0).optional(),
|
|
53
|
+
refundedAt: z.date().optional(),
|
|
54
|
+
|
|
55
|
+
// TIMESTAMPS
|
|
56
|
+
createdAt: z.date().default(() => new Date()),
|
|
57
|
+
succeededAt: z.date().optional(),
|
|
58
|
+
failedAt: z.date().optional(),
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
// API request/response schemas
|
|
62
|
+
export const createPaymentSchema = z.object({
|
|
63
|
+
orderId: z.string(),
|
|
64
|
+
amount: z.number().min(0),
|
|
65
|
+
paymentMethod: paymentMethodSchema,
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
export const updatePaymentStatusSchema = z.object({
|
|
69
|
+
status: paymentStatusSchema,
|
|
70
|
+
failureCode: failureCodeSchema.optional(),
|
|
71
|
+
failureMessage: z.string().optional(),
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
export const refundPaymentSchema = z.object({
|
|
75
|
+
refundAmount: z.number().min(0),
|
|
76
|
+
reason: z.string(),
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
// Response schemas
|
|
80
|
+
export const paymentResponseSchema = paymentSchema;
|
|
81
|
+
export const paymentsListResponseSchema = z.array(paymentResponseSchema);
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import {
|
|
3
|
+
paymentSchema,
|
|
4
|
+
paymentStatusSchema,
|
|
5
|
+
paymentMethodSchema,
|
|
6
|
+
cardBrandSchema,
|
|
7
|
+
failureCodeSchema,
|
|
8
|
+
createPaymentSchema,
|
|
9
|
+
updatePaymentStatusSchema,
|
|
10
|
+
refundPaymentSchema,
|
|
11
|
+
paymentResponseSchema,
|
|
12
|
+
paymentsListResponseSchema
|
|
13
|
+
} from './payments.schema';
|
|
14
|
+
|
|
15
|
+
// =============================================================================
|
|
16
|
+
// TYPE EXPORTS
|
|
17
|
+
// =============================================================================
|
|
18
|
+
|
|
19
|
+
// Enum types
|
|
20
|
+
export type PaymentStatus = z.infer<typeof paymentStatusSchema>;
|
|
21
|
+
export type PaymentMethod = z.infer<typeof paymentMethodSchema>;
|
|
22
|
+
export type CardBrand = z.infer<typeof cardBrandSchema>;
|
|
23
|
+
export type FailureCode = z.infer<typeof failureCodeSchema>;
|
|
24
|
+
|
|
25
|
+
// Main payment type
|
|
26
|
+
export type Payment = z.infer<typeof paymentSchema>;
|
|
27
|
+
|
|
28
|
+
// API request/response types
|
|
29
|
+
export type CreatePaymentRequest = z.infer<typeof createPaymentSchema>;
|
|
30
|
+
export type UpdatePaymentStatusRequest = z.infer<typeof updatePaymentStatusSchema>;
|
|
31
|
+
export type RefundPaymentRequest = z.infer<typeof refundPaymentSchema>;
|
|
32
|
+
|
|
33
|
+
export type PaymentResponse = z.infer<typeof paymentResponseSchema>;
|
|
34
|
+
export type PaymentsListResponse = z.infer<typeof paymentsListResponseSchema>;
|
|
35
|
+
|
|
36
|
+
// Service method parameter types
|
|
37
|
+
export interface CreatePaymentData {
|
|
38
|
+
orderId: string;
|
|
39
|
+
userId: string;
|
|
40
|
+
paymentId: string;
|
|
41
|
+
amount: number;
|
|
42
|
+
currency?: string;
|
|
43
|
+
paymentMethod: PaymentMethod;
|
|
44
|
+
last4?: string;
|
|
45
|
+
brand?: CardBrand;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export interface UpdatePaymentData {
|
|
49
|
+
paymentId: string;
|
|
50
|
+
status: PaymentStatus;
|
|
51
|
+
failureCode?: FailureCode;
|
|
52
|
+
failureMessage?: string;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export interface RefundPaymentData {
|
|
56
|
+
paymentId: string;
|
|
57
|
+
refundAmount: number;
|
|
58
|
+
refundId: string;
|
|
59
|
+
reason: string;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// Utility types for frontend
|
|
63
|
+
export interface PaymentWithOrder extends Omit<Payment, 'orderId'> {
|
|
64
|
+
orderId: {
|
|
65
|
+
_id: string;
|
|
66
|
+
orderNumber: string;
|
|
67
|
+
eventId: {
|
|
68
|
+
_id: string;
|
|
69
|
+
title: string;
|
|
70
|
+
schedule: {
|
|
71
|
+
startDate: string;
|
|
72
|
+
venue: {
|
|
73
|
+
name: string;
|
|
74
|
+
};
|
|
75
|
+
};
|
|
76
|
+
};
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export interface PaymentSummary {
|
|
81
|
+
totalPayments: number;
|
|
82
|
+
successfulPayments: number;
|
|
83
|
+
failedPayments: number;
|
|
84
|
+
refundedPayments: number;
|
|
85
|
+
totalAmount: number;
|
|
86
|
+
totalRefunded: number;
|
|
87
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
// Ticket status enum
|
|
4
|
+
export const ticketStatusSchema = z.enum(['valid', 'used', 'cancelled', 'refunded', 'transferred']);
|
|
5
|
+
|
|
6
|
+
// Check-in status enum
|
|
7
|
+
export const checkInStatusSchema = z.enum(['not_checked_in', 'checked_in']);
|
|
8
|
+
|
|
9
|
+
// Main ticket schema
|
|
10
|
+
export const ticketSchema = z.object({
|
|
11
|
+
_id: z.string().optional(), // MongoDB ObjectId
|
|
12
|
+
ticketNumber: z.string().regex(/^TKT-[A-Z0-9]{6}-[A-Z0-9]{4}-\d{2}$/), // TKT-EVT123-A3K9-01
|
|
13
|
+
|
|
14
|
+
// BELONGS TO
|
|
15
|
+
orderId: z.string(), // Parent order
|
|
16
|
+
eventId: z.string(), // Which event
|
|
17
|
+
userId: z.string(), // Owner
|
|
18
|
+
ticketVariantId: z.string(), // Which type (VIP, GA, etc)
|
|
19
|
+
|
|
20
|
+
// DETAILS (denormalized for speed)
|
|
21
|
+
eventTitle: z.string(),
|
|
22
|
+
eventDate: z.date(),
|
|
23
|
+
eventVenue: z.string(),
|
|
24
|
+
ticketType: z.string(), // "VIP Pass"
|
|
25
|
+
price: z.number().min(0),
|
|
26
|
+
|
|
27
|
+
// QR CODE
|
|
28
|
+
qrCode: z.string(), // SHA256 hash
|
|
29
|
+
qrCodeUrl: z.string(), // ImageKit/S3 URL
|
|
30
|
+
|
|
31
|
+
// STATUS
|
|
32
|
+
status: ticketStatusSchema,
|
|
33
|
+
|
|
34
|
+
// CHECK-IN
|
|
35
|
+
checkInStatus: checkInStatusSchema,
|
|
36
|
+
checkedInAt: z.date().optional(),
|
|
37
|
+
checkedInBy: z.string().optional(), // Staff user ID
|
|
38
|
+
|
|
39
|
+
// TRANSFER
|
|
40
|
+
transferredTo: z.string().optional(), // New owner user ID
|
|
41
|
+
transferredAt: z.date().optional(),
|
|
42
|
+
|
|
43
|
+
// LIFECYCLE
|
|
44
|
+
issuedAt: z.date().default(() => new Date()),
|
|
45
|
+
validUntil: z.date(), // Event end date
|
|
46
|
+
|
|
47
|
+
// SECURITY
|
|
48
|
+
secretHash: z.string(), // Internal validation hash
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
// API request/response schemas
|
|
52
|
+
export const createTicketSchema = z.object({
|
|
53
|
+
orderId: z.string(),
|
|
54
|
+
eventId: z.string(),
|
|
55
|
+
userId: z.string(),
|
|
56
|
+
ticketVariantId: z.string(),
|
|
57
|
+
eventTitle: z.string(),
|
|
58
|
+
eventDate: z.date(),
|
|
59
|
+
eventVenue: z.string(),
|
|
60
|
+
ticketType: z.string(),
|
|
61
|
+
price: z.number().min(0),
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
export const updateTicketStatusSchema = z.object({
|
|
65
|
+
status: ticketStatusSchema,
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
export const checkInTicketSchema = z.object({
|
|
69
|
+
staffUserId: z.string(),
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
export const transferTicketSchema = z.object({
|
|
73
|
+
newOwnerId: z.string(),
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
// Response schemas
|
|
77
|
+
export const ticketResponseSchema = ticketSchema;
|
|
78
|
+
export const ticketsListResponseSchema = z.array(ticketResponseSchema);
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import {
|
|
3
|
+
ticketSchema,
|
|
4
|
+
ticketStatusSchema,
|
|
5
|
+
checkInStatusSchema,
|
|
6
|
+
createTicketSchema,
|
|
7
|
+
updateTicketStatusSchema,
|
|
8
|
+
checkInTicketSchema,
|
|
9
|
+
transferTicketSchema,
|
|
10
|
+
ticketResponseSchema,
|
|
11
|
+
ticketsListResponseSchema
|
|
12
|
+
} from './ticket.schema';
|
|
13
|
+
|
|
14
|
+
// =============================================================================
|
|
15
|
+
// TYPE EXPORTS
|
|
16
|
+
// =============================================================================
|
|
17
|
+
|
|
18
|
+
// Enum types
|
|
19
|
+
export type TicketStatus = z.infer<typeof ticketStatusSchema>;
|
|
20
|
+
export type CheckInStatus = z.infer<typeof checkInStatusSchema>;
|
|
21
|
+
|
|
22
|
+
// Main ticket type
|
|
23
|
+
export type Ticket = z.infer<typeof ticketSchema>;
|
|
24
|
+
|
|
25
|
+
// API request/response types
|
|
26
|
+
export type CreateTicketRequest = z.infer<typeof createTicketSchema>;
|
|
27
|
+
export type UpdateTicketStatusRequest = z.infer<typeof updateTicketStatusSchema>;
|
|
28
|
+
export type CheckInTicketRequest = z.infer<typeof checkInTicketSchema>;
|
|
29
|
+
export type TransferTicketRequest = z.infer<typeof transferTicketSchema>;
|
|
30
|
+
|
|
31
|
+
export type TicketResponse = z.infer<typeof ticketResponseSchema>;
|
|
32
|
+
export type TicketsListResponse = z.infer<typeof ticketsListResponseSchema>;
|
|
33
|
+
|
|
34
|
+
// Service method parameter types
|
|
35
|
+
export interface CreateTicketData {
|
|
36
|
+
orderId: string;
|
|
37
|
+
eventId: string;
|
|
38
|
+
userId: string;
|
|
39
|
+
ticketVariantId: string;
|
|
40
|
+
eventTitle: string;
|
|
41
|
+
eventDate: Date;
|
|
42
|
+
eventVenue: string;
|
|
43
|
+
ticketType: string;
|
|
44
|
+
price: number;
|
|
45
|
+
quantity: number; // For creating multiple tickets
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export interface UpdateTicketData {
|
|
49
|
+
ticketId: string;
|
|
50
|
+
status: TicketStatus;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export interface CheckInTicketData {
|
|
54
|
+
ticketId: string;
|
|
55
|
+
staffUserId: string;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export interface TransferTicketData {
|
|
59
|
+
ticketId: string;
|
|
60
|
+
newOwnerId: string;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// Utility types for frontend
|
|
64
|
+
export interface TicketWithOrder extends Omit<Ticket, 'orderId'> {
|
|
65
|
+
orderId: {
|
|
66
|
+
_id: string;
|
|
67
|
+
orderNumber: string;
|
|
68
|
+
status: string;
|
|
69
|
+
createdAt: string;
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export interface TicketWithEvent extends Omit<Ticket, 'eventId'> {
|
|
74
|
+
eventId: {
|
|
75
|
+
_id: string;
|
|
76
|
+
title: string;
|
|
77
|
+
schedule: {
|
|
78
|
+
startDate: string;
|
|
79
|
+
venue: {
|
|
80
|
+
name: string;
|
|
81
|
+
};
|
|
82
|
+
};
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export interface TicketSummary {
|
|
87
|
+
totalTickets: number;
|
|
88
|
+
validTickets: number;
|
|
89
|
+
usedTickets: number;
|
|
90
|
+
checkedInTickets: number;
|
|
91
|
+
cancelledTickets: number;
|
|
92
|
+
refundedTickets: number;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// QR Code generation types
|
|
96
|
+
export interface QRCodeData {
|
|
97
|
+
ticketId: string;
|
|
98
|
+
ticketNumber: string;
|
|
99
|
+
eventTitle: string;
|
|
100
|
+
eventDate: string;
|
|
101
|
+
userId: string;
|
|
102
|
+
secretHash: string;
|
|
103
|
+
}
|
package/tsconfig.json
ADDED
package/dist/auth.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './auth/index';
|
package/dist/auth.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
// Re-export from the modular auth structure
|
|
18
|
-
__exportStar(require("./auth/index"), exports);
|