@myrjfa/state 1.0.7 → 1.1.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.
Files changed (43) hide show
  1. package/dist/index.d.ts +9 -4
  2. package/dist/index.d.ts.map +1 -1
  3. package/dist/index.js +9 -4
  4. package/dist/lib/QueryProvider.d.ts +1 -1
  5. package/dist/lib/QueryProvider.d.ts.map +1 -1
  6. package/dist/lib/actions/actions.d.ts +141 -0
  7. package/dist/lib/actions/actions.d.ts.map +1 -0
  8. package/dist/lib/actions/actions.js +307 -0
  9. package/dist/lib/actions/auth.d.ts +150 -0
  10. package/dist/lib/actions/auth.d.ts.map +1 -0
  11. package/dist/lib/actions/auth.js +125 -0
  12. package/dist/lib/actions/chat.d.ts +48 -0
  13. package/dist/lib/actions/chat.d.ts.map +1 -0
  14. package/dist/lib/actions/chat.js +303 -0
  15. package/dist/lib/actions/fetcher.d.ts +9 -0
  16. package/dist/lib/actions/fetcher.d.ts.map +1 -0
  17. package/dist/lib/actions/fetcher.js +84 -0
  18. package/dist/lib/actions/severActions.d.ts +3 -0
  19. package/dist/lib/actions/severActions.d.ts.map +1 -0
  20. package/dist/lib/actions/severActions.js +19 -0
  21. package/dist/lib/actions/socket.d.ts +7 -0
  22. package/dist/lib/actions/socket.d.ts.map +1 -0
  23. package/dist/lib/actions/socket.js +22 -0
  24. package/dist/lib/actions.d.ts +3 -3
  25. package/dist/lib/actions.d.ts.map +1 -1
  26. package/dist/lib/actions.js +2 -2
  27. package/dist/lib/authSessionManager.js +1 -1
  28. package/dist/lib/context/ChatContext.d.ts +25 -0
  29. package/dist/lib/context/ChatContext.d.ts.map +1 -0
  30. package/dist/lib/context/ChatContext.js +228 -0
  31. package/dist/lib/hooks/useChatSocket.d.ts +6 -0
  32. package/dist/lib/hooks/useChatSocket.d.ts.map +1 -0
  33. package/dist/lib/hooks/useChatSocket.js +35 -0
  34. package/dist/lib/models/chat.d.ts +122 -0
  35. package/dist/lib/models/chat.d.ts.map +1 -0
  36. package/dist/lib/models/chat.js +1 -0
  37. package/dist/lib/models/props.d.ts.map +1 -1
  38. package/dist/lib/models/props.js +1 -0
  39. package/dist/lib/socket.d.ts +7 -0
  40. package/dist/lib/socket.d.ts.map +1 -0
  41. package/dist/lib/socket.js +22 -0
  42. package/dist/lib/userAtom.js +2 -2
  43. package/package.json +4 -2
package/dist/index.d.ts CHANGED
@@ -1,13 +1,18 @@
1
1
  export * from './lib/utils';
2
- export * from './lib/auth';
2
+ export * from './lib/actions/auth';
3
3
  export * from './lib/authSessionManager';
4
4
  export * from './lib/userAtom';
5
- export * from './lib/fetcher';
6
- export * from './lib/actions';
7
- export * from './lib/severActions';
5
+ export * from './lib/actions/fetcher';
6
+ export * from './lib/actions/actions';
7
+ export * from './lib/actions/severActions';
8
8
  export * from './lib/hooks/use-mobile';
9
9
  export * from './lib/models/user';
10
10
  export * from './lib/models/notfications';
11
11
  export * from './lib/models/review';
12
12
  export * from './lib/models/props';
13
+ export * from './lib/actions/chat';
14
+ export * from './lib/actions/socket';
15
+ export * from './lib/hooks/useChatSocket';
16
+ export * from './lib/models/chat';
17
+ export * from './lib/context/ChatContext';
13
18
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,0BAA0B,CAAC;AACzC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AAEnC,cAAc,wBAAwB,CAAC;AAEvC,cAAc,mBAAmB,CAAC;AAClC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,oBAAoB,CAAC;AACnC,cAAc,0BAA0B,CAAC;AACzC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,4BAA4B,CAAC;AAE3C,cAAc,wBAAwB,CAAC;AAEvC,cAAc,mBAAmB,CAAC;AAClC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AAEnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC;AACrC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,mBAAmB,CAAC;AAClC,cAAc,2BAA2B,CAAC"}
package/dist/index.js CHANGED
@@ -1,12 +1,17 @@
1
1
  export * from './lib/utils';
2
- export * from './lib/auth';
2
+ export * from './lib/actions/auth';
3
3
  export * from './lib/authSessionManager';
4
4
  export * from './lib/userAtom';
5
- export * from './lib/fetcher';
6
- export * from './lib/actions';
7
- export * from './lib/severActions';
5
+ export * from './lib/actions/fetcher';
6
+ export * from './lib/actions/actions';
7
+ export * from './lib/actions/severActions';
8
8
  export * from './lib/hooks/use-mobile';
9
9
  export * from './lib/models/user';
10
10
  export * from './lib/models/notfications';
11
11
  export * from './lib/models/review';
12
12
  export * from './lib/models/props';
13
+ export * from './lib/actions/chat';
14
+ export * from './lib/actions/socket';
15
+ export * from './lib/hooks/useChatSocket';
16
+ export * from './lib/models/chat';
17
+ export * from './lib/context/ChatContext';
@@ -1,4 +1,4 @@
1
1
  export default function QueryProvider({ children }: {
2
- children: React.ReactNode;
2
+ children: any;
3
3
  }): import("react/jsx-runtime").JSX.Element;
4
4
  //# sourceMappingURL=QueryProvider.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"QueryProvider.d.ts","sourceRoot":"","sources":["../../src/lib/QueryProvider.tsx"],"names":[],"mappings":"AAMA,MAAM,CAAC,OAAO,UAAU,aAAa,CAAC,EAAE,QAAQ,EAAE,EAAE;IAAE,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;CAAE,2CAShF"}
1
+ {"version":3,"file":"QueryProvider.d.ts","sourceRoot":"","sources":["../../src/lib/QueryProvider.tsx"],"names":[],"mappings":"AAMA,MAAM,CAAC,OAAO,UAAU,aAAa,CAAC,EAAE,QAAQ,EAAE,EAAE;IAAE,QAAQ,EAAE,GAAG,CAAA;CAAE,2CASpE"}
@@ -0,0 +1,141 @@
1
+ import { Review, reviewTargetType, reviewType } from "../models/review";
2
+ import { tileType } from "../models/tile";
3
+ import { User } from "../models/user";
4
+ export declare function getCurrentUser(): Promise<User | null>;
5
+ export declare function userDetails(query: string, role: "user" | "host" | "admin"): Promise<{
6
+ success: boolean;
7
+ user: User | null;
8
+ message?: string;
9
+ status?: string;
10
+ error?: string;
11
+ }>;
12
+ export declare function subscribeToNewsLetter(email: string): Promise<{
13
+ success: boolean;
14
+ message?: string;
15
+ error?: string;
16
+ }>;
17
+ export declare function toggleUserWishlist(slug: string, tileType: tileType): Promise<{
18
+ success: boolean;
19
+ message?: string;
20
+ error?: string;
21
+ wishlist: string[];
22
+ }>;
23
+ export declare function subscribeToCareersPage(email: string): Promise<{
24
+ success: boolean;
25
+ message?: string;
26
+ error?: string;
27
+ }>;
28
+ export declare function contactUs(email: string, name: string, subject: string, message: string): Promise<{
29
+ success: boolean;
30
+ message?: string;
31
+ error?: string;
32
+ }>;
33
+ export declare function saveUserResume(file: File): Promise<{
34
+ success: boolean;
35
+ message?: string;
36
+ error?: string;
37
+ user: User | null;
38
+ }>;
39
+ export declare function getUserContact(username: string, role: string): Promise<{
40
+ success: boolean;
41
+ message?: string;
42
+ error?: string;
43
+ details: {
44
+ name: string;
45
+ email: string;
46
+ phoneNumber: string;
47
+ } | null;
48
+ }>;
49
+ export declare function getReviewsById(id: string, type: reviewTargetType): Promise<{
50
+ success: boolean;
51
+ reviews: Review[];
52
+ message?: string;
53
+ error?: string;
54
+ }>;
55
+ export declare function getRatingById(id: string[], type: reviewTargetType): Promise<{
56
+ success: boolean;
57
+ message?: string;
58
+ error?: string;
59
+ ratings: {
60
+ slug: string;
61
+ rating: number;
62
+ ratingCount: number;
63
+ reviewCount: number;
64
+ }[];
65
+ }>;
66
+ export declare function addReview(id: string, type: reviewTargetType, formData: reviewType): Promise<{
67
+ success: boolean;
68
+ review: Review | null;
69
+ message?: string;
70
+ error?: string;
71
+ }>;
72
+ export declare function editReview(id: string, formData: reviewType): Promise<{
73
+ success: boolean;
74
+ review: Review | null;
75
+ message?: string;
76
+ error?: string;
77
+ }>;
78
+ export declare function deleteReview(id: string): Promise<{
79
+ success: boolean;
80
+ message?: string;
81
+ error?: string;
82
+ }>;
83
+ export declare function getAllNotifications(): Promise<{
84
+ success: boolean;
85
+ message: string;
86
+ notifs: {
87
+ message: string;
88
+ _id: string;
89
+ userId: string;
90
+ timestamp: Date;
91
+ read: boolean;
92
+ url?: string | undefined;
93
+ }[];
94
+ unreadCount: number;
95
+ error?: undefined;
96
+ } | {
97
+ success: boolean;
98
+ error: any;
99
+ notifs: never[];
100
+ unreadCount: number;
101
+ message?: undefined;
102
+ }>;
103
+ export declare function getNotifications(limit: number): Promise<{
104
+ success: boolean;
105
+ message: string;
106
+ notifs: {
107
+ message: string;
108
+ _id: string;
109
+ userId: string;
110
+ timestamp: Date;
111
+ read: boolean;
112
+ url?: string | undefined;
113
+ }[];
114
+ unreadCount: number;
115
+ error?: undefined;
116
+ } | {
117
+ success: boolean;
118
+ error: any;
119
+ notifs: never[];
120
+ unreadCount: number;
121
+ message?: undefined;
122
+ }>;
123
+ export declare function toggleNotification(id: string, read: boolean): Promise<{
124
+ success: boolean;
125
+ message: string;
126
+ error?: undefined;
127
+ } | {
128
+ success: boolean;
129
+ error: any;
130
+ message?: undefined;
131
+ }>;
132
+ export declare function toggleAllNotification(read: boolean): Promise<{
133
+ success: boolean;
134
+ message: string;
135
+ error?: undefined;
136
+ } | {
137
+ success: boolean;
138
+ error: any;
139
+ message?: undefined;
140
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,qBAAqB,CAAC,IAAI,EAAE,OAAO;;;;;;;;GAexD"}
@@ -0,0 +1,307 @@
1
+ import { del, get, patch, post } from "./fetcher";
2
+ // host
3
+ // user/host
4
+ export async function getCurrentUser() {
5
+ try {
6
+ const endpoint = `/users/me`;
7
+ const data = await get(endpoint);
8
+ // console.log(data.message);
9
+ return data?.data;
10
+ }
11
+ catch (error) {
12
+ console.error('Failed to fetch user details: ', error);
13
+ return null;
14
+ }
15
+ }
16
+ export async function userDetails(query, role) {
17
+ try {
18
+ if (role == "admin")
19
+ role = "user";
20
+ const endpoint = `/${role}s/other-${role}/${query}`;
21
+ const data = await get(endpoint);
22
+ return {
23
+ success: true,
24
+ user: data?.data,
25
+ message: data.message
26
+ };
27
+ }
28
+ catch (error) {
29
+ console.error('Failed to fetch user details: ', error);
30
+ return { success: false, user: null, status: error.status, error: error.message };
31
+ }
32
+ }
33
+ export async function subscribeToNewsLetter(email) {
34
+ try {
35
+ const endpoint = `/subscription/create`;
36
+ const data = await post(endpoint, { email: email });
37
+ return { success: true, message: data.message };
38
+ }
39
+ catch (error) {
40
+ console.error('Error subscribing to newsletter: ', error);
41
+ return {
42
+ success: false,
43
+ error: error.message,
44
+ };
45
+ }
46
+ }
47
+ export async function toggleUserWishlist(slug, tileType) {
48
+ try {
49
+ const endpoint = `/users/fav/${tileType}/toggle`;
50
+ const data = await post(endpoint, { id: slug });
51
+ return { success: true, message: data.message, wishlist: data.data };
52
+ }
53
+ catch (error) {
54
+ console.error(`Failed to add ${tileType} to wishlist: `, error);
55
+ return {
56
+ success: false,
57
+ error: error.message,
58
+ wishlist: []
59
+ };
60
+ }
61
+ }
62
+ // subscribe
63
+ export async function subscribeToCareersPage(email) {
64
+ try {
65
+ const endpoint = `/subscription/create-job`;
66
+ const data = await post(endpoint, { email: email });
67
+ return { success: true, message: data.message };
68
+ }
69
+ catch (error) {
70
+ console.error('Error subscribing to newsletter: ', error);
71
+ return {
72
+ success: false,
73
+ error: error.message,
74
+ };
75
+ }
76
+ }
77
+ export async function contactUs(email, name, subject, message) {
78
+ try {
79
+ const endpoint = `/contactUs`;
80
+ const data = await post(endpoint, { email: email, name: name, subject: subject, message: message });
81
+ return { success: true, message: data.message };
82
+ }
83
+ catch (error) {
84
+ console.error('Error contacting trippeaze: ', error);
85
+ return {
86
+ success: false,
87
+ error: error.message,
88
+ };
89
+ }
90
+ }
91
+ // resume
92
+ export async function saveUserResume(file) {
93
+ try {
94
+ const endpoint = `/users/resume-update`;
95
+ const formData = new FormData();
96
+ formData.append('resume', file);
97
+ const data = await patch(endpoint, formData);
98
+ return {
99
+ success: true,
100
+ message: data.message,
101
+ user: data.data,
102
+ };
103
+ }
104
+ catch (error) {
105
+ return { success: false, error: error.message, user: null };
106
+ }
107
+ }
108
+ export async function getUserContact(username, role) {
109
+ try {
110
+ const endpoint = `/${role}s/getUserContact/${username}`;
111
+ const data = await get(endpoint);
112
+ return {
113
+ success: true,
114
+ message: data.message,
115
+ details: data.data,
116
+ };
117
+ }
118
+ catch (error) {
119
+ return {
120
+ success: false,
121
+ error: error.message,
122
+ details: null,
123
+ };
124
+ }
125
+ }
126
+ // rating and reviews
127
+ export async function getReviewsById(id, type) {
128
+ try {
129
+ const endpoint = `/reviews/entity/${id}/${type}`;
130
+ const data = await get(endpoint);
131
+ // const data = { data: sampleReviews, message: "success" };
132
+ return {
133
+ success: true,
134
+ reviews: data.data,
135
+ message: data.message,
136
+ };
137
+ }
138
+ catch (error) {
139
+ console.error('Failed to get reviews: ', error);
140
+ return {
141
+ success: true,
142
+ reviews: [],
143
+ error: error.message,
144
+ };
145
+ }
146
+ }
147
+ export async function getRatingById(id, type) {
148
+ try {
149
+ const endpoint = `/reviews/entity/${id}`;
150
+ const data = await get(endpoint);
151
+ // const data = {
152
+ // data:
153
+ // [{
154
+ // slug: id[0] ?? "",
155
+ // rating: truncateDecimal(sampleReviews.reduce((acc, review) => acc + review.rating, 0) / sampleReviews.length, 1),
156
+ // ratingCount: sampleReviews.length,
157
+ // reviewCount: 100,
158
+ // }],
159
+ // message: "success"
160
+ // }
161
+ return {
162
+ success: true,
163
+ ratings: data.data,
164
+ message: data.message,
165
+ };
166
+ }
167
+ catch (error) {
168
+ console.error('Failed to get reviews: ', error);
169
+ return {
170
+ success: true,
171
+ ratings: [],
172
+ error: error.message,
173
+ };
174
+ }
175
+ }
176
+ export async function addReview(id, type, formData) {
177
+ try {
178
+ const endpoint = `/reviews/`;
179
+ const data = await post(endpoint, { reviewee: id, revieweeType: type, rating: formData.rating, comment: formData.comment });
180
+ return {
181
+ success: true,
182
+ review: data.data,
183
+ message: data.message,
184
+ };
185
+ }
186
+ catch (error) {
187
+ console.error('Failed to get reviews: ', error);
188
+ return {
189
+ success: false,
190
+ review: null,
191
+ error: error.message,
192
+ };
193
+ }
194
+ }
195
+ export async function editReview(id, formData) {
196
+ try {
197
+ const endpoint = `/reviews/${id}`;
198
+ const data = await patch(endpoint, { rating: formData.rating, comment: formData.comment });
199
+ return {
200
+ success: true,
201
+ review: data.data,
202
+ message: data.message,
203
+ };
204
+ }
205
+ catch (error) {
206
+ console.error('Failed to get reviews: ', error);
207
+ return {
208
+ success: false,
209
+ review: null,
210
+ error: error.message,
211
+ };
212
+ }
213
+ }
214
+ export async function deleteReview(id) {
215
+ try {
216
+ const endpoint = `/reviews/${id}`;
217
+ const data = await del(endpoint);
218
+ return {
219
+ success: true,
220
+ message: data.message,
221
+ };
222
+ }
223
+ catch (error) {
224
+ console.error('Failed to get reviews: ', error);
225
+ return {
226
+ success: false,
227
+ error: error.message,
228
+ };
229
+ }
230
+ }
231
+ // notifications
232
+ export async function getAllNotifications() {
233
+ try {
234
+ const endpoint = `/notification?all=true`;
235
+ const data = await get(endpoint);
236
+ return {
237
+ success: true,
238
+ message: data.message,
239
+ notifs: data.data.notifications,
240
+ unreadCount: data.data.unreadCount,
241
+ };
242
+ }
243
+ catch (error) {
244
+ console.error('Failed to fetch notifications: ', error);
245
+ return {
246
+ success: false,
247
+ error: error.message,
248
+ notifs: [],
249
+ unreadCount: 0,
250
+ };
251
+ }
252
+ }
253
+ export async function getNotifications(limit) {
254
+ try {
255
+ const endpoint = `/notification?limit=${limit}`;
256
+ const data = await get(endpoint);
257
+ return {
258
+ success: true,
259
+ message: data.message,
260
+ notifs: data.data.notifications,
261
+ unreadCount: data.data.unreadCount,
262
+ };
263
+ }
264
+ catch (error) {
265
+ console.error('Failed to fetch notifications: ', error);
266
+ return {
267
+ success: false,
268
+ error: error.message,
269
+ notifs: [],
270
+ unreadCount: 0,
271
+ };
272
+ }
273
+ }
274
+ export async function toggleNotification(id, read) {
275
+ try {
276
+ const endpoint = `/notfication/${id}`;
277
+ const data = await patch(endpoint, { isRead: read });
278
+ return {
279
+ success: true,
280
+ message: data.message,
281
+ };
282
+ }
283
+ catch (error) {
284
+ console.error('Failed to toggle notfication: ', error);
285
+ return {
286
+ success: false,
287
+ error: error.message,
288
+ };
289
+ }
290
+ }
291
+ export async function toggleAllNotification(read) {
292
+ try {
293
+ const endpoint = `/notfication/update/all`;
294
+ const data = await patch(endpoint, { isRead: read });
295
+ return {
296
+ success: true,
297
+ message: data.message,
298
+ };
299
+ }
300
+ catch (error) {
301
+ console.error('Failed to toggle all notfications: ', error);
302
+ return {
303
+ success: false,
304
+ error: error.message,
305
+ };
306
+ }
307
+ }
@@ -0,0 +1,150 @@
1
+ export declare function signIn(formData: {
2
+ email: string;
3
+ password: string;
4
+ role: string;
5
+ }): Promise<{
6
+ user: {
7
+ username: string;
8
+ firstName: string;
9
+ lastName: string;
10
+ email: string;
11
+ password: string;
12
+ phoneNumber: string;
13
+ countryCode: string;
14
+ country: string;
15
+ gender: "male" | "female" | "other";
16
+ rating: number;
17
+ ratingCount: number;
18
+ reviewCount: number;
19
+ joinedDate: Date;
20
+ isActive: boolean;
21
+ lastActive: Date;
22
+ verifiedEmail: boolean;
23
+ verifiedMobile: boolean;
24
+ role: "host" | "user" | "admin" | "hr" | "sales";
25
+ location?: string | undefined;
26
+ pinCode?: string | undefined;
27
+ dob?: Date | undefined;
28
+ profilePic?: string | undefined;
29
+ blogsCount?: number | undefined;
30
+ userBio?: string | undefined;
31
+ userIdCard?: string | undefined;
32
+ watchHistory?: string[] | undefined;
33
+ accessToken?: string | undefined;
34
+ refreshToken?: string | undefined;
35
+ verifiedIdCard?: boolean | undefined;
36
+ socialLinks?: Record<string, string> | undefined;
37
+ userResume?: string | undefined;
38
+ skills?: {
39
+ skill: string;
40
+ skillExpertise: number;
41
+ }[] | undefined;
42
+ wishlist?: string[] | undefined;
43
+ favBlogs?: string[] | undefined;
44
+ favPackages?: string[] | undefined;
45
+ id?: string | undefined;
46
+ selfie?: string | undefined;
47
+ selfieAction?: string | undefined;
48
+ jobCount?: number | undefined;
49
+ travelPackageCount?: number | undefined;
50
+ gstNumber?: string | undefined;
51
+ panCard?: string | undefined;
52
+ verifiedBusiness?: "true" | "false" | "inProgress" | undefined;
53
+ };
54
+ message: string;
55
+ success?: undefined;
56
+ status?: undefined;
57
+ error?: undefined;
58
+ } | {
59
+ success: boolean;
60
+ status: any;
61
+ error: any;
62
+ user?: undefined;
63
+ message?: undefined;
64
+ }>;
65
+ export declare function logoutUser(role: string): Promise<{
66
+ success: boolean;
67
+ message?: string;
68
+ error?: string;
69
+ }>;
70
+ export declare function verifyEmailOtp(email: string, otp: string, role: "user" | "host"): Promise<{
71
+ user: {
72
+ username: string;
73
+ firstName: string;
74
+ lastName: string;
75
+ email: string;
76
+ password: string;
77
+ phoneNumber: string;
78
+ countryCode: string;
79
+ country: string;
80
+ gender: "male" | "female" | "other";
81
+ rating: number;
82
+ ratingCount: number;
83
+ reviewCount: number;
84
+ joinedDate: Date;
85
+ isActive: boolean;
86
+ lastActive: Date;
87
+ verifiedEmail: boolean;
88
+ verifiedMobile: boolean;
89
+ role: "host" | "user" | "admin" | "hr" | "sales";
90
+ location?: string | undefined;
91
+ pinCode?: string | undefined;
92
+ dob?: Date | undefined;
93
+ profilePic?: string | undefined;
94
+ blogsCount?: number | undefined;
95
+ userBio?: string | undefined;
96
+ userIdCard?: string | undefined;
97
+ watchHistory?: string[] | undefined;
98
+ accessToken?: string | undefined;
99
+ refreshToken?: string | undefined;
100
+ verifiedIdCard?: boolean | undefined;
101
+ socialLinks?: Record<string, string> | undefined;
102
+ userResume?: string | undefined;
103
+ skills?: {
104
+ skill: string;
105
+ skillExpertise: number;
106
+ }[] | undefined;
107
+ wishlist?: string[] | undefined;
108
+ favBlogs?: string[] | undefined;
109
+ favPackages?: string[] | undefined;
110
+ id?: string | undefined;
111
+ selfie?: string | undefined;
112
+ selfieAction?: string | undefined;
113
+ jobCount?: number | undefined;
114
+ travelPackageCount?: number | undefined;
115
+ gstNumber?: string | undefined;
116
+ panCard?: string | undefined;
117
+ verifiedBusiness?: "true" | "false" | "inProgress" | undefined;
118
+ };
119
+ message: string;
120
+ success?: undefined;
121
+ status?: undefined;
122
+ error?: undefined;
123
+ } | {
124
+ success: boolean;
125
+ status: any;
126
+ error: any;
127
+ user?: undefined;
128
+ message?: undefined;
129
+ }>;
130
+ export declare function sendPasswordResetEmail(email: string, role: string): Promise<{
131
+ success: boolean;
132
+ message?: string;
133
+ error?: string;
134
+ }>;
135
+ export declare function changePassword(password: string, oldPassword: string, role: string): Promise<{
136
+ success: boolean;
137
+ message?: string;
138
+ error?: string;
139
+ }>;
140
+ export declare function resetPassword(password: string, token: string, role: string): Promise<{
141
+ success: boolean;
142
+ message?: string;
143
+ error?: string;
144
+ }>;
145
+ export declare function validateSession(): Promise<{
146
+ success: boolean;
147
+ message?: string;
148
+ error?: string;
149
+ }>;
150
+ //# sourceMappingURL=auth.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../../src/lib/actions/auth.ts"],"names":[],"mappings":"AAGA,wBAAsB,MAAM,CAAC,QAAQ,EAAE;IACnC,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;CAChB;;;;;;;;;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