flykup_model_production 1.0.15 → 1.0.17

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.
Files changed (43) hide show
  1. package/.gitattributes +2 -0
  2. package/.github/workflows/publish.yml +31 -0
  3. package/auth.js +14 -14
  4. package/config.js +1 -1
  5. package/db_connection.js +23 -23
  6. package/index.js +140 -140
  7. package/models/AadhaarVerification.js +131 -131
  8. package/models/AdminEmail.model.js +38 -38
  9. package/models/BankVerification.js +92 -92
  10. package/models/GSTVerification.js +89 -89
  11. package/models/LiveStreamInteraction.model.js +101 -101
  12. package/models/ProductInteraction.model.js +108 -108
  13. package/models/Review.model.js +121 -121
  14. package/models/SearchAnalytics.js +23 -23
  15. package/models/ShoppableInteraction.model.js +106 -106
  16. package/models/Wishlist.model.js +29 -29
  17. package/models/admin.model.js +42 -42
  18. package/models/appUpdate.model.js +19 -19
  19. package/models/assets.model.js +32 -32
  20. package/models/blockedRegion.models.js +27 -27
  21. package/models/chat.model.js +511 -511
  22. package/models/coHostInvitation.model.js +60 -60
  23. package/models/follow.model.js +38 -38
  24. package/models/loginlogs.model.js +26 -26
  25. package/models/notification.model.js +130 -129
  26. package/models/order.modal.js +385 -381
  27. package/models/orderPayment.model.js +219 -105
  28. package/models/productListing.model.js +322 -318
  29. package/models/profileInteractions.model.js +44 -44
  30. package/models/registerShow.model.js +29 -29
  31. package/models/sellerDraft.model.js +27 -27
  32. package/models/seller_settlements_2025-11-18 (1).csv +4 -0
  33. package/models/seller_settlements_2025-11-18.csv +4 -0
  34. package/models/shipper.model.js +126 -126
  35. package/models/shoppableVideo.model.js +237 -237
  36. package/models/shoppableVideoComment.model.js +57 -57
  37. package/models/shoppableVideoLike.model.js +29 -29
  38. package/models/shoppableVideoSave.model.js +27 -27
  39. package/models/shows.model.js +603 -570
  40. package/models/stock.model.js +105 -105
  41. package/models/ticket.model.js +115 -115
  42. package/models/user.model.js +7 -0
  43. package/package.json +18 -18
package/.gitattributes ADDED
@@ -0,0 +1,2 @@
1
+ # Auto detect text files and perform LF normalization
2
+ * text=auto
@@ -0,0 +1,31 @@
1
+ name: Publish to npm
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - main
7
+
8
+ jobs:
9
+ release:
10
+ runs-on: ubuntu-latest
11
+
12
+ steps:
13
+ - uses: actions/checkout@v3
14
+
15
+ - name: Set node
16
+ uses: actions/setup-node@v3
17
+ with:
18
+ node-version: "18"
19
+ registry-url: "https://registry.npmjs.org/"
20
+
21
+ - name: Install dependencies
22
+ run: npm install
23
+
24
+ - name: Build project
25
+ run: npm run build || echo "No build step"
26
+
27
+ - name: Publish to npm
28
+ run: npm publish --access public
29
+ env:
30
+ NODE_AUTH_TOKEN: ${{ secrets.NODE_AUTH_TOKEN }}
31
+
package/auth.js CHANGED
@@ -1,14 +1,14 @@
1
- import { VALID_TOKENS } from "./config.js";
2
-
3
- // console.log('VALID_TOKENS', VALID_TOKENS)
4
-
5
-
6
- export function verifyAccessToken(token) {
7
- if (!token) {
8
- throw new Error('❌ Unauthorized: Missing token for shared models');
9
- }
10
- if (!VALID_TOKENS.includes(token)) {
11
- throw new Error('❌ Unauthorized: Invalid token for shared models');
12
- }
13
- console.log('✅ Token validated for shared models');
14
- }
1
+ import { VALID_TOKENS } from "./config.js";
2
+
3
+ // console.log('VALID_TOKENS', VALID_TOKENS)
4
+
5
+
6
+ export function verifyAccessToken(token) {
7
+ if (!token) {
8
+ throw new Error('❌ Unauthorized: Missing token for shared models');
9
+ }
10
+ if (!VALID_TOKENS.includes(token)) {
11
+ throw new Error('❌ Unauthorized: Invalid token for shared models');
12
+ }
13
+ console.log('✅ Token validated for shared models');
14
+ }
package/config.js CHANGED
@@ -1 +1 @@
1
- export const VALID_TOKENS = ['Flykup_backend','Flykup_bga','Flykup_tapntake','Flykup_erp','Flykup_control_backend','Flykup_livestream','Flykup_shoppablevideos','Flykup_webinar','Flykup_creatordock','Flykup_socialpulse'];
1
+ export const VALID_TOKENS = ['Flykup_backend','Flykup_bga','Flykup_tapntake','Flykup_erp','Flykup_control_backend','Flykup_livestream','Flykup_shoppablevideos','Flykup_webinar','Flykup_creatordock','Flykup_socialpulse'];
package/db_connection.js CHANGED
@@ -1,23 +1,23 @@
1
- import mongoose from 'mongoose';
2
-
3
- let isConnected = false;
4
-
5
- export async function connectToDB(uri) {
6
- if (isConnected) return;
7
-
8
- if (!uri) {
9
- throw new Error('❌ No MongoDB URI provided to connectToDB');
10
- }
11
-
12
- try {
13
- await mongoose.connect(uri, {
14
- maxPoolSize: 10,
15
-
16
- });
17
- isConnected = true;
18
- console.log(`✅ Shared-models DB connected`);
19
- } catch (err) {
20
- console.error('❌ DB connection failed:', err);
21
- throw err;
22
- }
23
- }
1
+ import mongoose from 'mongoose';
2
+
3
+ let isConnected = false;
4
+
5
+ export async function connectToDB(uri) {
6
+ if (isConnected) return;
7
+
8
+ if (!uri) {
9
+ throw new Error('❌ No MongoDB URI provided to connectToDB');
10
+ }
11
+
12
+ try {
13
+ await mongoose.connect(uri, {
14
+ maxPoolSize: 10,
15
+
16
+ });
17
+ isConnected = true;
18
+ console.log(`✅ Shared-models DB connected`);
19
+ } catch (err) {
20
+ console.error('❌ DB connection failed:', err);
21
+ throw err;
22
+ }
23
+ }
package/index.js CHANGED
@@ -1,140 +1,140 @@
1
- import { verifyAccessToken } from './auth.js';
2
- import { connectToDB } from './db_connection.js';
3
-
4
-
5
- import Admin from './models/admin.model.js';
6
- import BlockedRegion from './models/blockedRegion.models.js';
7
- import Category from './models/category.model.js';
8
- import CoHostInvitation from './models/coHostInvitation.model.js';
9
- import Follow from './models/follow.model.js';
10
- import LoginLogs from './models/loginlogs.model.js';
11
- import Notification from './models/notification.model.js';
12
- import ProductListing from './models/productListing.model.js';
13
- import Seller from './models/seller.model.js';
14
- import Settings from './models/settings.model.js';
15
- import Shipper from './models/shipper.model.js';
16
- import ShoppableVideo from './models/shoppableVideo.model.js';
17
- import ShoppableVideoComment from './models/shoppableVideoComment.model.js';
18
- import ShoppableVideoLike from './models/shoppableVideoLike.model.js';
19
- import ShoppableVideoSave from './models/shoppableVideoSave.model.js';
20
- import Shows from './models/shows.model.js';
21
- import Stock from './models/stock.model.js';
22
- import User from './models/user.model.js';
23
- import ProductInteraction from './models/ProductInteraction.model.js';
24
- import Wishlist from './models/Wishlist.model.js';
25
- import { ChatBlock, ChatMessage, ChatRoom, ChatRoomMember } from './models/chat.model.js';
26
- import Order from './models/order.modal.js';
27
- import LiveStreamInteraction from './models/LiveStreamInteraction.model.js';
28
- import ProfileInteraction from './models/profileInteractions.model.js';
29
- import RegisterShow from './models/registerShow.model.js';
30
- import { Review, ReviewType } from './models/Review.model.js';
31
- import ShoppableVideoInteraction from './models/ShoppableInteraction.model.js';
32
- import SellerDraft from './models/sellerDraft.model.js';
33
- import AadhaarVerification from './models/AadhaarVerification.js';
34
- import BankVerification from './models/BankVerification.js';
35
- import GSTVerification from './models/GSTVerification.js';
36
- import OrderPayment from './models/orderPayment.model.js';
37
- let initialized = false;
38
-
39
- export async function initializeSharedModels({ token, dbUri }) {
40
- verifyAccessToken(token);
41
-
42
- if (!dbUri) {
43
- throw new Error('❌ MONGO_URI must be provided by the backend');
44
- }
45
-
46
- await connectToDB(dbUri);
47
- initialized = true;
48
- }
49
-
50
- function ensureInitialized() {
51
- if (!initialized) {
52
- throw new Error('❌ Shared models not initialized. Call initializeSharedModels() first.');
53
- }
54
- }
55
-
56
- function createModelProxy(model) {
57
- return new Proxy(model, {
58
- get(target, prop) {
59
- ensureInitialized();
60
- return target[prop];
61
- }
62
- });
63
- }
64
-
65
-
66
- export const AdminModel = createModelProxy(Admin);
67
- export const BlockedRegionModel = createModelProxy(BlockedRegion);
68
- export const CategoryModel = createModelProxy(Category);
69
- export const CoHostInvitationModel = createModelProxy(CoHostInvitation);
70
- export const FollowModel = createModelProxy(Follow);
71
- export const LoginLogsModel = createModelProxy(LoginLogs);
72
- export const NotificationModel = createModelProxy(Notification);
73
- export const ProductListingModel = createModelProxy(ProductListing);
74
- export const SellerModel = createModelProxy(Seller);
75
- export const SettingsModel = createModelProxy(Settings);
76
- export const ShipperModel = createModelProxy(Shipper);
77
- export const ShoppableVideoModel = createModelProxy(ShoppableVideo);
78
- export const ShoppableVideoCommentModel = createModelProxy(ShoppableVideoComment);
79
- export const ShoppableVideoLikeModel = createModelProxy(ShoppableVideoLike);
80
- export const ShoppableVideoSaveModel = createModelProxy(ShoppableVideoSave);
81
- export const ShowsModel = createModelProxy(Shows);
82
- export const StockModel = createModelProxy(Stock);
83
- export const UserModel = createModelProxy(User);
84
- export const ProductInteractionModel = createModelProxy(ProductInteraction);
85
- export const WishlistModel = createModelProxy(Wishlist);
86
- export const ChatBlockModel = createModelProxy(ChatBlock);
87
- export const ChatMessageModel = createModelProxy(ChatMessage);
88
- export const ChatRoomModel = createModelProxy(ChatRoom);
89
- export const ChatRoomMemberModel = createModelProxy(ChatRoomMember);
90
- export const OrderModel = createModelProxy(Order);
91
- export const LiveStreamInteractionModel = createModelProxy(LiveStreamInteraction);
92
- export const ProfileInteractionModel = createModelProxy(ProfileInteraction);
93
- export const RegisterShowModel = createModelProxy(RegisterShow);
94
- export const ReviewTypeModel = createModelProxy(ReviewType);
95
- export const ReviewModel = createModelProxy(Review);
96
- export const ShoppableVideoInteractionModel = createModelProxy(ShoppableVideoInteraction);
97
- export const SellerDraftModel = createModelProxy(SellerDraft);
98
- export const AadhaarVerificationModel = createModelProxy(AadhaarVerification);
99
- export const BankVerificationModel = createModelProxy(BankVerification);
100
- export const GSTVerificationModel = createModelProxy(GSTVerification);
101
- export const OrderPaymentModel = createModelProxy(OrderPayment)
102
-
103
- export {
104
- AdminModel as Admin,
105
- BlockedRegionModel as BlockedRegion,
106
- CategoryModel as Category,
107
- CoHostInvitationModel as CoHostInvitation,
108
- FollowModel as Follow,
109
- LoginLogsModel as LoginLogs,
110
- NotificationModel as Notification,
111
- ProductListingModel as ProductListing,
112
- SellerModel as Seller,
113
- SettingsModel as Settings,
114
- ShipperModel as Shipper,
115
- ShoppableVideoModel as ShoppableVideo,
116
- ShoppableVideoCommentModel as ShoppableVideoComment,
117
- ShoppableVideoLikeModel as ShoppableVideoLike,
118
- ShoppableVideoSaveModel as ShoppableVideoSave,
119
- ShowsModel as Shows,
120
- StockModel as Stock,
121
- UserModel as User,
122
- ProductInteractionModel as ProductInteraction,
123
- WishlistModel as Wishlist,
124
- ChatBlockModel as ChatBlock,
125
- ChatRoomModel as ChatRoom,
126
- ChatMessageModel as ChatMessage,
127
- ChatRoomMemberModel as ChatRoomMember,
128
- OrderModel as Order,
129
- LiveStreamInteractionModel as LiveStreamInteraction,
130
- ProfileInteractionModel as ProfileInteraction,
131
- RegisterShowModel as RegisterShow,
132
- ReviewModel as Review,
133
- ReviewTypeModel as ReviewType,
134
- ShoppableVideoInteractionModel as ShoppableVideoInteraction,
135
- SellerDraftModel as SellerDraft,
136
- AadhaarVerificationModel as AadhaarVerification,
137
- BankVerificationModel as BankVerification,
138
- GSTVerificationModel as GSTVerification,
139
- OrderPaymentModel as OrderPayment
140
- };
1
+ import { verifyAccessToken } from './auth.js';
2
+ import { connectToDB } from './db_connection.js';
3
+
4
+
5
+ import Admin from './models/admin.model.js';
6
+ import BlockedRegion from './models/blockedRegion.models.js';
7
+ import Category from './models/category.model.js';
8
+ import CoHostInvitation from './models/coHostInvitation.model.js';
9
+ import Follow from './models/follow.model.js';
10
+ import LoginLogs from './models/loginlogs.model.js';
11
+ import Notification from './models/notification.model.js';
12
+ import ProductListing from './models/productListing.model.js';
13
+ import Seller from './models/seller.model.js';
14
+ import Settings from './models/settings.model.js';
15
+ import Shipper from './models/shipper.model.js';
16
+ import ShoppableVideo from './models/shoppableVideo.model.js';
17
+ import ShoppableVideoComment from './models/shoppableVideoComment.model.js';
18
+ import ShoppableVideoLike from './models/shoppableVideoLike.model.js';
19
+ import ShoppableVideoSave from './models/shoppableVideoSave.model.js';
20
+ import Shows from './models/shows.model.js';
21
+ import Stock from './models/stock.model.js';
22
+ import User from './models/user.model.js';
23
+ import ProductInteraction from './models/ProductInteraction.model.js';
24
+ import Wishlist from './models/Wishlist.model.js';
25
+ import { ChatBlock, ChatMessage, ChatRoom, ChatRoomMember } from './models/chat.model.js';
26
+ import Order from './models/order.modal.js';
27
+ import LiveStreamInteraction from './models/LiveStreamInteraction.model.js';
28
+ import ProfileInteraction from './models/profileInteractions.model.js';
29
+ import RegisterShow from './models/registerShow.model.js';
30
+ import { Review, ReviewType } from './models/Review.model.js';
31
+ import ShoppableVideoInteraction from './models/ShoppableInteraction.model.js';
32
+ import SellerDraft from './models/sellerDraft.model.js';
33
+ import AadhaarVerification from './models/AadhaarVerification.js';
34
+ import BankVerification from './models/BankVerification.js';
35
+ import GSTVerification from './models/GSTVerification.js';
36
+ import OrderPayment from './models/orderPayment.model.js';
37
+ let initialized = false;
38
+
39
+ export async function initializeSharedModels({ token, dbUri }) {
40
+ verifyAccessToken(token);
41
+
42
+ if (!dbUri) {
43
+ throw new Error('❌ MONGO_URI must be provided by the backend');
44
+ }
45
+
46
+ await connectToDB(dbUri);
47
+ initialized = true;
48
+ }
49
+
50
+ function ensureInitialized() {
51
+ if (!initialized) {
52
+ throw new Error('❌ Shared models not initialized. Call initializeSharedModels() first.');
53
+ }
54
+ }
55
+
56
+ function createModelProxy(model) {
57
+ return new Proxy(model, {
58
+ get(target, prop) {
59
+ ensureInitialized();
60
+ return target[prop];
61
+ }
62
+ });
63
+ }
64
+
65
+
66
+ export const AdminModel = createModelProxy(Admin);
67
+ export const BlockedRegionModel = createModelProxy(BlockedRegion);
68
+ export const CategoryModel = createModelProxy(Category);
69
+ export const CoHostInvitationModel = createModelProxy(CoHostInvitation);
70
+ export const FollowModel = createModelProxy(Follow);
71
+ export const LoginLogsModel = createModelProxy(LoginLogs);
72
+ export const NotificationModel = createModelProxy(Notification);
73
+ export const ProductListingModel = createModelProxy(ProductListing);
74
+ export const SellerModel = createModelProxy(Seller);
75
+ export const SettingsModel = createModelProxy(Settings);
76
+ export const ShipperModel = createModelProxy(Shipper);
77
+ export const ShoppableVideoModel = createModelProxy(ShoppableVideo);
78
+ export const ShoppableVideoCommentModel = createModelProxy(ShoppableVideoComment);
79
+ export const ShoppableVideoLikeModel = createModelProxy(ShoppableVideoLike);
80
+ export const ShoppableVideoSaveModel = createModelProxy(ShoppableVideoSave);
81
+ export const ShowsModel = createModelProxy(Shows);
82
+ export const StockModel = createModelProxy(Stock);
83
+ export const UserModel = createModelProxy(User);
84
+ export const ProductInteractionModel = createModelProxy(ProductInteraction);
85
+ export const WishlistModel = createModelProxy(Wishlist);
86
+ export const ChatBlockModel = createModelProxy(ChatBlock);
87
+ export const ChatMessageModel = createModelProxy(ChatMessage);
88
+ export const ChatRoomModel = createModelProxy(ChatRoom);
89
+ export const ChatRoomMemberModel = createModelProxy(ChatRoomMember);
90
+ export const OrderModel = createModelProxy(Order);
91
+ export const LiveStreamInteractionModel = createModelProxy(LiveStreamInteraction);
92
+ export const ProfileInteractionModel = createModelProxy(ProfileInteraction);
93
+ export const RegisterShowModel = createModelProxy(RegisterShow);
94
+ export const ReviewTypeModel = createModelProxy(ReviewType);
95
+ export const ReviewModel = createModelProxy(Review);
96
+ export const ShoppableVideoInteractionModel = createModelProxy(ShoppableVideoInteraction);
97
+ export const SellerDraftModel = createModelProxy(SellerDraft);
98
+ export const AadhaarVerificationModel = createModelProxy(AadhaarVerification);
99
+ export const BankVerificationModel = createModelProxy(BankVerification);
100
+ export const GSTVerificationModel = createModelProxy(GSTVerification);
101
+ export const OrderPaymentModel = createModelProxy(OrderPayment)
102
+
103
+ export {
104
+ AdminModel as Admin,
105
+ BlockedRegionModel as BlockedRegion,
106
+ CategoryModel as Category,
107
+ CoHostInvitationModel as CoHostInvitation,
108
+ FollowModel as Follow,
109
+ LoginLogsModel as LoginLogs,
110
+ NotificationModel as Notification,
111
+ ProductListingModel as ProductListing,
112
+ SellerModel as Seller,
113
+ SettingsModel as Settings,
114
+ ShipperModel as Shipper,
115
+ ShoppableVideoModel as ShoppableVideo,
116
+ ShoppableVideoCommentModel as ShoppableVideoComment,
117
+ ShoppableVideoLikeModel as ShoppableVideoLike,
118
+ ShoppableVideoSaveModel as ShoppableVideoSave,
119
+ ShowsModel as Shows,
120
+ StockModel as Stock,
121
+ UserModel as User,
122
+ ProductInteractionModel as ProductInteraction,
123
+ WishlistModel as Wishlist,
124
+ ChatBlockModel as ChatBlock,
125
+ ChatRoomModel as ChatRoom,
126
+ ChatMessageModel as ChatMessage,
127
+ ChatRoomMemberModel as ChatRoomMember,
128
+ OrderModel as Order,
129
+ LiveStreamInteractionModel as LiveStreamInteraction,
130
+ ProfileInteractionModel as ProfileInteraction,
131
+ RegisterShowModel as RegisterShow,
132
+ ReviewModel as Review,
133
+ ReviewTypeModel as ReviewType,
134
+ ShoppableVideoInteractionModel as ShoppableVideoInteraction,
135
+ SellerDraftModel as SellerDraft,
136
+ AadhaarVerificationModel as AadhaarVerification,
137
+ BankVerificationModel as BankVerification,
138
+ GSTVerificationModel as GSTVerification,
139
+ OrderPaymentModel as OrderPayment
140
+ };
@@ -1,131 +1,131 @@
1
- // models/AadhaarVerification.js
2
- import mongoose from 'mongoose';
3
-
4
- const aadhaarVerificationSchema = new mongoose.Schema({
5
- // User reference - Required field
6
- userId: {
7
- type: mongoose.Schema.Types.ObjectId,
8
- ref: 'users',
9
- required: true,
10
- index: true
11
- },
12
-
13
- // Aadhaar number - Store when sending OTP
14
- aadhaarNumber: {
15
- type: String,
16
- required: true,
17
- index: true
18
- },
19
-
20
- // Core verification info
21
- verificationStatus: {
22
- type: String,
23
- required: true,
24
- enum: ['pending', 'verified', 'failed'],
25
- default: 'pending'
26
- },
27
-
28
- referenceId: {
29
- type: String,
30
- required: true,
31
- index: true
32
- },
33
-
34
- // Personal details - Store after OTP verification
35
- name: {
36
- type: String,
37
- default: null
38
- },
39
-
40
- gender: {
41
- type: String,
42
- default: null
43
- },
44
-
45
- dateOfBirth: {
46
- type: String,
47
- default: null
48
- },
49
-
50
- // Address information - Store after OTP verification
51
- address: {
52
- care_of: {
53
- type: String,
54
- default: null
55
- },
56
- building: {
57
- type: String,
58
- default: null
59
- },
60
- street: {
61
- type: String,
62
- default: null
63
- },
64
- locality: {
65
- type: String,
66
- default: null
67
- },
68
- vtc: {
69
- type: String,
70
- default: null
71
- },
72
- district: {
73
- type: String,
74
- default: null
75
- },
76
- state: {
77
- type: String,
78
- default: null
79
- },
80
- country: {
81
- type: String,
82
- default: null
83
- },
84
- pincode: {
85
- type: String,
86
- default: null
87
- }
88
- },
89
-
90
- // Photo link - Store after OTP verification
91
- photo: {
92
- type: String,
93
- default: null
94
- },
95
-
96
- // Request metadata - Store when sending OTP
97
- otpSentAt: {
98
- type: Date,
99
- default: null
100
- },
101
-
102
- // Verification metadata - Store after OTP verification
103
- verifiedAt: {
104
- type: Date,
105
- default: null
106
- },
107
-
108
- // Raw API response for debugging
109
- rawResponse: {
110
- type: mongoose.Schema.Types.Mixed,
111
- default: null
112
- }
113
- }, {
114
- timestamps: true, // Adds createdAt and updatedAt
115
- collection: 'aadhaar_verifications'
116
- });
117
-
118
- // Indexes for better performance
119
- aadhaarVerificationSchema.index({ userId: 1 });
120
- aadhaarVerificationSchema.index({ referenceId: 1 });
121
- aadhaarVerificationSchema.index({ aadhaarNumber: 1 });
122
- aadhaarVerificationSchema.index({ verificationStatus: 1 });
123
- aadhaarVerificationSchema.index({ createdAt: -1 });
124
-
125
- // Compound indexes for user-specific queries
126
- aadhaarVerificationSchema.index({ userId: 1, verificationStatus: 1 });
127
- aadhaarVerificationSchema.index({ userId: 1, aadhaarNumber: 1 });
128
-
129
- const AadhaarVerification = mongoose.models.AadhaarVerification || mongoose.model("AadhaarVerification", aadhaarVerificationSchema);
130
-
131
- export default AadhaarVerification;
1
+ // models/AadhaarVerification.js
2
+ import mongoose from 'mongoose';
3
+
4
+ const aadhaarVerificationSchema = new mongoose.Schema({
5
+ // User reference - Required field
6
+ userId: {
7
+ type: mongoose.Schema.Types.ObjectId,
8
+ ref: 'users',
9
+ required: true,
10
+ index: true
11
+ },
12
+
13
+ // Aadhaar number - Store when sending OTP
14
+ aadhaarNumber: {
15
+ type: String,
16
+ required: true,
17
+ index: true
18
+ },
19
+
20
+ // Core verification info
21
+ verificationStatus: {
22
+ type: String,
23
+ required: true,
24
+ enum: ['pending', 'verified', 'failed'],
25
+ default: 'pending'
26
+ },
27
+
28
+ referenceId: {
29
+ type: String,
30
+ required: true,
31
+ index: true
32
+ },
33
+
34
+ // Personal details - Store after OTP verification
35
+ name: {
36
+ type: String,
37
+ default: null
38
+ },
39
+
40
+ gender: {
41
+ type: String,
42
+ default: null
43
+ },
44
+
45
+ dateOfBirth: {
46
+ type: String,
47
+ default: null
48
+ },
49
+
50
+ // Address information - Store after OTP verification
51
+ address: {
52
+ care_of: {
53
+ type: String,
54
+ default: null
55
+ },
56
+ building: {
57
+ type: String,
58
+ default: null
59
+ },
60
+ street: {
61
+ type: String,
62
+ default: null
63
+ },
64
+ locality: {
65
+ type: String,
66
+ default: null
67
+ },
68
+ vtc: {
69
+ type: String,
70
+ default: null
71
+ },
72
+ district: {
73
+ type: String,
74
+ default: null
75
+ },
76
+ state: {
77
+ type: String,
78
+ default: null
79
+ },
80
+ country: {
81
+ type: String,
82
+ default: null
83
+ },
84
+ pincode: {
85
+ type: String,
86
+ default: null
87
+ }
88
+ },
89
+
90
+ // Photo link - Store after OTP verification
91
+ photo: {
92
+ type: String,
93
+ default: null
94
+ },
95
+
96
+ // Request metadata - Store when sending OTP
97
+ otpSentAt: {
98
+ type: Date,
99
+ default: null
100
+ },
101
+
102
+ // Verification metadata - Store after OTP verification
103
+ verifiedAt: {
104
+ type: Date,
105
+ default: null
106
+ },
107
+
108
+ // Raw API response for debugging
109
+ rawResponse: {
110
+ type: mongoose.Schema.Types.Mixed,
111
+ default: null
112
+ }
113
+ }, {
114
+ timestamps: true, // Adds createdAt and updatedAt
115
+ collection: 'aadhaar_verifications'
116
+ });
117
+
118
+ // Indexes for better performance
119
+ aadhaarVerificationSchema.index({ userId: 1 });
120
+ aadhaarVerificationSchema.index({ referenceId: 1 });
121
+ aadhaarVerificationSchema.index({ aadhaarNumber: 1 });
122
+ aadhaarVerificationSchema.index({ verificationStatus: 1 });
123
+ aadhaarVerificationSchema.index({ createdAt: -1 });
124
+
125
+ // Compound indexes for user-specific queries
126
+ aadhaarVerificationSchema.index({ userId: 1, verificationStatus: 1 });
127
+ aadhaarVerificationSchema.index({ userId: 1, aadhaarNumber: 1 });
128
+
129
+ const AadhaarVerification = mongoose.models.AadhaarVerification || mongoose.model("AadhaarVerification", aadhaarVerificationSchema);
130
+
131
+ export default AadhaarVerification;