@myrjfa/state 2.0.1 → 2.1.1
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/LICENSE +201 -201
- package/README.md +3 -3
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/lib/actions/actions.d.ts +20 -1
- package/dist/lib/actions/actions.d.ts.map +1 -1
- package/dist/lib/actions/actions.js +50 -10
- package/dist/lib/actions/auth.d.ts +12 -2
- package/dist/lib/actions/auth.d.ts.map +1 -1
- package/dist/lib/actions/booking.d.ts +15 -0
- package/dist/lib/actions/booking.d.ts.map +1 -1
- package/dist/lib/actions/booking.js +15 -1
- package/dist/lib/actions/fetcher.d.ts +0 -3
- package/dist/lib/actions/fetcher.d.ts.map +1 -1
- package/dist/lib/actions/fetcher.js +65 -8
- package/dist/lib/actions/{severActions.d.ts → serverActions.d.ts} +1 -1
- package/dist/lib/actions/serverActions.d.ts.map +1 -0
- package/dist/lib/actions/{severActions.js → serverActions.js} +3 -0
- package/dist/lib/authSessionManager.d.ts.map +1 -1
- package/dist/lib/authSessionManager.js +14 -7
- package/dist/lib/context/ChatContext.d.ts +1 -1
- package/dist/lib/context/ChatContext.d.ts.map +1 -1
- package/dist/lib/hooks/use-mobile.js +1 -0
- package/dist/lib/hooks/useChatSocket.js +1 -0
- package/dist/lib/models/blog.d.ts +3 -2
- package/dist/lib/models/blog.d.ts.map +1 -1
- package/dist/lib/models/{notfications.d.ts → notifications.d.ts} +1 -1
- package/dist/lib/models/notifications.d.ts.map +1 -0
- package/dist/lib/models/opportunities/freelance.d.ts +48 -20
- package/dist/lib/models/opportunities/freelance.d.ts.map +1 -1
- package/dist/lib/models/opportunities/internship.d.ts +48 -20
- package/dist/lib/models/opportunities/internship.d.ts.map +1 -1
- package/dist/lib/models/opportunities/job.d.ts +58 -30
- package/dist/lib/models/opportunities/job.d.ts.map +1 -1
- package/dist/lib/models/opportunities/opportunity.d.ts +61 -33
- package/dist/lib/models/opportunities/opportunity.d.ts.map +1 -1
- package/dist/lib/models/opportunities/opportunity.js +1 -0
- package/dist/lib/models/opportunities/volunteerJob.d.ts +48 -20
- package/dist/lib/models/opportunities/volunteerJob.d.ts.map +1 -1
- package/dist/lib/models/package.d.ts +2 -2
- package/dist/lib/models/props.d.ts +21 -0
- package/dist/lib/models/props.d.ts.map +1 -1
- package/dist/lib/models/stay.d.ts +2 -2
- package/dist/lib/models/user.d.ts +19 -4
- package/dist/lib/models/user.d.ts.map +1 -1
- package/dist/lib/models/user.js +5 -0
- package/dist/lib/userAtom.d.ts +24 -4
- package/dist/lib/userAtom.d.ts.map +1 -1
- package/dist/lib/userAtom.js +13 -11
- package/dist/lib/utils/socialMediaUrl.d.ts +25 -0
- package/dist/lib/utils/socialMediaUrl.d.ts.map +1 -0
- package/dist/lib/utils/socialMediaUrl.js +97 -0
- package/dist/lib/utils.js +4 -4
- package/package.json +2 -1
- package/dist/lib/actions/severActions.d.ts.map +0 -1
- package/dist/lib/models/notfications.d.ts.map +0 -1
- /package/dist/lib/models/{notfications.js → notifications.js} +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
export declare const socialLinkTypes: [
|
|
2
|
+
export declare const socialLinkTypes: readonly ["instagram", "linkedin", "youtube", "googleBusiness"];
|
|
3
3
|
export declare const zroles: z.ZodEnum<["host", "user", "admin", "hr", "sales"]>;
|
|
4
4
|
export declare const UserSchema: z.ZodObject<{
|
|
5
5
|
username: z.ZodString;
|
|
@@ -31,7 +31,7 @@ export declare const UserSchema: z.ZodObject<{
|
|
|
31
31
|
verifiedMobile: z.ZodBoolean;
|
|
32
32
|
verifiedIdCard: z.ZodOptional<z.ZodBoolean>;
|
|
33
33
|
role: z.ZodEnum<["host", "user", "admin", "hr", "sales"]>;
|
|
34
|
-
socialLinks: z.ZodOptional<z.ZodRecord<z.ZodEnum<[
|
|
34
|
+
socialLinks: z.ZodOptional<z.ZodRecord<z.ZodEnum<["instagram", "linkedin", "youtube", "googleBusiness"]>, z.ZodString>>;
|
|
35
35
|
userResume: z.ZodOptional<z.ZodString>;
|
|
36
36
|
skills: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
37
37
|
skill: z.ZodString;
|
|
@@ -82,6 +82,11 @@ export declare const UserSchema: z.ZodObject<{
|
|
|
82
82
|
pinCode?: string | undefined;
|
|
83
83
|
registrationNumber?: string | undefined;
|
|
84
84
|
}>, "many">>;
|
|
85
|
+
businessDocument: z.ZodOptional<z.ZodString>;
|
|
86
|
+
businessIdType: z.ZodOptional<z.ZodEnum<["PAN", "GST", "Udyam", "PersonalPAN"]>>;
|
|
87
|
+
businessIdNumber: z.ZodOptional<z.ZodString>;
|
|
88
|
+
businessApiVerificationStatus: z.ZodOptional<z.ZodEnum<["pending", "verified", "failed"]>>;
|
|
89
|
+
businessVerificationDenialReason: z.ZodOptional<z.ZodString>;
|
|
85
90
|
}, "strict", z.ZodTypeAny, {
|
|
86
91
|
username: string;
|
|
87
92
|
firstName: string;
|
|
@@ -112,7 +117,7 @@ export declare const UserSchema: z.ZodObject<{
|
|
|
112
117
|
accessToken?: string | undefined;
|
|
113
118
|
refreshToken?: string | undefined;
|
|
114
119
|
verifiedIdCard?: boolean | undefined;
|
|
115
|
-
socialLinks?: Record<
|
|
120
|
+
socialLinks?: Partial<Record<"instagram" | "linkedin" | "youtube" | "googleBusiness", string>> | undefined;
|
|
116
121
|
userResume?: string | undefined;
|
|
117
122
|
skills?: {
|
|
118
123
|
skill: string;
|
|
@@ -139,6 +144,11 @@ export declare const UserSchema: z.ZodObject<{
|
|
|
139
144
|
pinCode?: string | undefined;
|
|
140
145
|
registrationNumber?: string | undefined;
|
|
141
146
|
}[] | undefined;
|
|
147
|
+
businessDocument?: string | undefined;
|
|
148
|
+
businessIdType?: "PAN" | "GST" | "Udyam" | "PersonalPAN" | undefined;
|
|
149
|
+
businessIdNumber?: string | undefined;
|
|
150
|
+
businessApiVerificationStatus?: "pending" | "verified" | "failed" | undefined;
|
|
151
|
+
businessVerificationDenialReason?: string | undefined;
|
|
142
152
|
}, {
|
|
143
153
|
username: string;
|
|
144
154
|
firstName: string;
|
|
@@ -169,7 +179,7 @@ export declare const UserSchema: z.ZodObject<{
|
|
|
169
179
|
accessToken?: string | undefined;
|
|
170
180
|
refreshToken?: string | undefined;
|
|
171
181
|
verifiedIdCard?: boolean | undefined;
|
|
172
|
-
socialLinks?: Record<
|
|
182
|
+
socialLinks?: Partial<Record<"instagram" | "linkedin" | "youtube" | "googleBusiness", string>> | undefined;
|
|
173
183
|
userResume?: string | undefined;
|
|
174
184
|
skills?: {
|
|
175
185
|
skill: string;
|
|
@@ -196,6 +206,11 @@ export declare const UserSchema: z.ZodObject<{
|
|
|
196
206
|
pinCode?: string | undefined;
|
|
197
207
|
registrationNumber?: string | undefined;
|
|
198
208
|
}[] | undefined;
|
|
209
|
+
businessDocument?: string | undefined;
|
|
210
|
+
businessIdType?: "PAN" | "GST" | "Udyam" | "PersonalPAN" | undefined;
|
|
211
|
+
businessIdNumber?: string | undefined;
|
|
212
|
+
businessApiVerificationStatus?: "pending" | "verified" | "failed" | undefined;
|
|
213
|
+
businessVerificationDenialReason?: string | undefined;
|
|
199
214
|
}>;
|
|
200
215
|
export type User = z.infer<typeof UserSchema>;
|
|
201
216
|
export declare const sampleUser: User;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user.d.ts","sourceRoot":"","sources":["../../../src/lib/models/user.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,eAAe,
|
|
1
|
+
{"version":3,"file":"user.d.ts","sourceRoot":"","sources":["../../../src/lib/models/user.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,eAAe,iEAAkE,CAAC;AAE/F,eAAO,MAAM,MAAM,qDAAmD,CAAC;AAEvE,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAsEZ,CAAC;AAEZ,MAAM,MAAM,IAAI,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,UAAU,CAAC,CAAC;AAE9C,eAAO,MAAM,UAAU,EAAE,IAmCxB,CAAC"}
|
package/dist/lib/models/user.js
CHANGED
|
@@ -61,6 +61,11 @@ export const UserSchema = z.object({
|
|
|
61
61
|
pinCode: z.string().optional(),
|
|
62
62
|
registrationNumber: z.string().optional(),
|
|
63
63
|
})).optional(),
|
|
64
|
+
businessDocument: z.string().optional(),
|
|
65
|
+
businessIdType: z.enum(["PAN", "GST", "Udyam", "PersonalPAN"]).optional(),
|
|
66
|
+
businessIdNumber: z.string().optional(),
|
|
67
|
+
businessApiVerificationStatus: z.enum(["pending", "verified", "failed"]).optional(),
|
|
68
|
+
businessVerificationDenialReason: z.string().optional(),
|
|
64
69
|
}).strict(); // 👈 .strict() blocks unknown fields
|
|
65
70
|
export const sampleUser = {
|
|
66
71
|
username: "wanderlust_volunteer",
|
package/dist/lib/userAtom.d.ts
CHANGED
|
@@ -31,7 +31,7 @@ export declare const userAtom: import("jotai").WritableAtom<{
|
|
|
31
31
|
accessToken?: string | undefined;
|
|
32
32
|
refreshToken?: string | undefined;
|
|
33
33
|
verifiedIdCard?: boolean | undefined;
|
|
34
|
-
socialLinks?: Record<
|
|
34
|
+
socialLinks?: Partial<Record<"instagram" | "linkedin" | "youtube" | "googleBusiness", string>> | undefined;
|
|
35
35
|
userResume?: string | undefined;
|
|
36
36
|
skills?: {
|
|
37
37
|
skill: string;
|
|
@@ -58,6 +58,11 @@ export declare const userAtom: import("jotai").WritableAtom<{
|
|
|
58
58
|
pinCode?: string | undefined;
|
|
59
59
|
registrationNumber?: string | undefined;
|
|
60
60
|
}[] | undefined;
|
|
61
|
+
businessDocument?: string | undefined;
|
|
62
|
+
businessIdType?: "PAN" | "GST" | "Udyam" | "PersonalPAN" | undefined;
|
|
63
|
+
businessIdNumber?: string | undefined;
|
|
64
|
+
businessApiVerificationStatus?: "pending" | "verified" | "failed" | undefined;
|
|
65
|
+
businessVerificationDenialReason?: string | undefined;
|
|
61
66
|
} | null, [{
|
|
62
67
|
username: string;
|
|
63
68
|
firstName: string;
|
|
@@ -88,7 +93,7 @@ export declare const userAtom: import("jotai").WritableAtom<{
|
|
|
88
93
|
accessToken?: string | undefined;
|
|
89
94
|
refreshToken?: string | undefined;
|
|
90
95
|
verifiedIdCard?: boolean | undefined;
|
|
91
|
-
socialLinks?: Record<
|
|
96
|
+
socialLinks?: Partial<Record<"instagram" | "linkedin" | "youtube" | "googleBusiness", string>> | undefined;
|
|
92
97
|
userResume?: string | undefined;
|
|
93
98
|
skills?: {
|
|
94
99
|
skill: string;
|
|
@@ -115,6 +120,11 @@ export declare const userAtom: import("jotai").WritableAtom<{
|
|
|
115
120
|
pinCode?: string | undefined;
|
|
116
121
|
registrationNumber?: string | undefined;
|
|
117
122
|
}[] | undefined;
|
|
123
|
+
businessDocument?: string | undefined;
|
|
124
|
+
businessIdType?: "PAN" | "GST" | "Udyam" | "PersonalPAN" | undefined;
|
|
125
|
+
businessIdNumber?: string | undefined;
|
|
126
|
+
businessApiVerificationStatus?: "pending" | "verified" | "failed" | undefined;
|
|
127
|
+
businessVerificationDenialReason?: string | undefined;
|
|
118
128
|
} | typeof import("jotai/utils").RESET | ((prev: {
|
|
119
129
|
username: string;
|
|
120
130
|
firstName: string;
|
|
@@ -145,7 +155,7 @@ export declare const userAtom: import("jotai").WritableAtom<{
|
|
|
145
155
|
accessToken?: string | undefined;
|
|
146
156
|
refreshToken?: string | undefined;
|
|
147
157
|
verifiedIdCard?: boolean | undefined;
|
|
148
|
-
socialLinks?: Record<
|
|
158
|
+
socialLinks?: Partial<Record<"instagram" | "linkedin" | "youtube" | "googleBusiness", string>> | undefined;
|
|
149
159
|
userResume?: string | undefined;
|
|
150
160
|
skills?: {
|
|
151
161
|
skill: string;
|
|
@@ -172,6 +182,11 @@ export declare const userAtom: import("jotai").WritableAtom<{
|
|
|
172
182
|
pinCode?: string | undefined;
|
|
173
183
|
registrationNumber?: string | undefined;
|
|
174
184
|
}[] | undefined;
|
|
185
|
+
businessDocument?: string | undefined;
|
|
186
|
+
businessIdType?: "PAN" | "GST" | "Udyam" | "PersonalPAN" | undefined;
|
|
187
|
+
businessIdNumber?: string | undefined;
|
|
188
|
+
businessApiVerificationStatus?: "pending" | "verified" | "failed" | undefined;
|
|
189
|
+
businessVerificationDenialReason?: string | undefined;
|
|
175
190
|
} | null) => {
|
|
176
191
|
username: string;
|
|
177
192
|
firstName: string;
|
|
@@ -202,7 +217,7 @@ export declare const userAtom: import("jotai").WritableAtom<{
|
|
|
202
217
|
accessToken?: string | undefined;
|
|
203
218
|
refreshToken?: string | undefined;
|
|
204
219
|
verifiedIdCard?: boolean | undefined;
|
|
205
|
-
socialLinks?: Record<
|
|
220
|
+
socialLinks?: Partial<Record<"instagram" | "linkedin" | "youtube" | "googleBusiness", string>> | undefined;
|
|
206
221
|
userResume?: string | undefined;
|
|
207
222
|
skills?: {
|
|
208
223
|
skill: string;
|
|
@@ -229,6 +244,11 @@ export declare const userAtom: import("jotai").WritableAtom<{
|
|
|
229
244
|
pinCode?: string | undefined;
|
|
230
245
|
registrationNumber?: string | undefined;
|
|
231
246
|
}[] | undefined;
|
|
247
|
+
businessDocument?: string | undefined;
|
|
248
|
+
businessIdType?: "PAN" | "GST" | "Udyam" | "PersonalPAN" | undefined;
|
|
249
|
+
businessIdNumber?: string | undefined;
|
|
250
|
+
businessApiVerificationStatus?: "pending" | "verified" | "failed" | undefined;
|
|
251
|
+
businessVerificationDenialReason?: string | undefined;
|
|
232
252
|
} | typeof import("jotai/utils").RESET | null) | null], void>;
|
|
233
253
|
export declare const isLoggedInAtom: import("jotai").WritableAtom<boolean, [boolean | typeof import("jotai/utils").RESET | ((prev: boolean) => boolean | typeof import("jotai/utils").RESET)], void>;
|
|
234
254
|
export declare const userLoadingAtom: import("jotai").Atom<boolean>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"userAtom.d.ts","sourceRoot":"","sources":["../../src/lib/userAtom.ts"],"names":[],"mappings":"AAgEA,eAAO,MAAM,sBAAsB;;CAAuB,CAAC;AAG3D,eAAO,MAAM,QAAQ
|
|
1
|
+
{"version":3,"file":"userAtom.d.ts","sourceRoot":"","sources":["../../src/lib/userAtom.ts"],"names":[],"mappings":"AAgEA,eAAO,MAAM,sBAAsB;;CAAuB,CAAC;AAG3D,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;6DAQpB,CAAC;AAEF,eAAO,MAAM,cAAc,iKAA6C,CAAC;AAGzE,eAAO,MAAM,eAAe,+BAM1B,CAAC;AAGH,eAAO,MAAM,yBAAyB;;CA+CrC,CAAC;AAGF,wBAAgB,cAAc,SAS7B"}
|
package/dist/lib/userAtom.js
CHANGED
|
@@ -3,7 +3,6 @@ import CryptoJS from 'crypto-js';
|
|
|
3
3
|
import { atom, getDefaultStore } from 'jotai';
|
|
4
4
|
import { atomWithStorage } from 'jotai/utils';
|
|
5
5
|
import { getCurrentUser } from './actions/actions';
|
|
6
|
-
import { validateSession } from './actions/auth';
|
|
7
6
|
const STORAGE_KEY = process.env.NEXT_PUBLIC_USER_KEY;
|
|
8
7
|
const LOGIN_KEY = process.env.NEXT_PUBLIC_LOGIN_KEY;
|
|
9
8
|
const SECRET_KEY = process.env.NEXT_PUBLIC_RACE;
|
|
@@ -77,16 +76,19 @@ export const initializeAuthSessionAtom = atom(null, async (get, set) => {
|
|
|
77
76
|
// Only run in browser
|
|
78
77
|
if (typeof window === 'undefined')
|
|
79
78
|
return;
|
|
80
|
-
// 1. Validate session (
|
|
81
|
-
const session = await validateSession();
|
|
82
|
-
if (session.success) {
|
|
83
|
-
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
79
|
+
// 1. Validate session (role-aware — host route differs from user route)
|
|
80
|
+
// const session = await validateSession();
|
|
81
|
+
// if (session.success) {
|
|
82
|
+
// Session validated successfully
|
|
83
|
+
// } else {
|
|
84
|
+
// resetAuthState();
|
|
85
|
+
// set(storageInitializedAtom, true);
|
|
86
|
+
// return;
|
|
87
|
+
// }
|
|
88
|
+
// NOTE: if validateSession fails we do NOT reset — we just fall through
|
|
89
|
+
// to cache/API. A failed ping could mean the backend is temporarily down,
|
|
90
|
+
// the user is a host (different endpoint), etc. We only clear state if we
|
|
91
|
+
// POSITIVELY know the user is logged out (getCurrentUser fails).
|
|
90
92
|
// 2. Try cache (localStorage)
|
|
91
93
|
const userData = getWithExpiry(STORAGE_KEY);
|
|
92
94
|
if (userData) {
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Normalizes social media input (username or partial URL) into a fully qualified URL.
|
|
3
|
+
* Handles cases where users enter just a username, handle, or partial URL.
|
|
4
|
+
*/
|
|
5
|
+
export type SocialPlatformType = 'instagram' | 'twitter' | 'linkedin' | 'facebook' | 'youtube' | 'github' | 'googleBusiness';
|
|
6
|
+
interface PlatformConfig {
|
|
7
|
+
baseUrl: string;
|
|
8
|
+
usernameRegex: RegExp;
|
|
9
|
+
urlPattern: RegExp;
|
|
10
|
+
buildUrl: (username: string) => string;
|
|
11
|
+
placeholder: string;
|
|
12
|
+
hint: string;
|
|
13
|
+
}
|
|
14
|
+
declare const PLATFORM_CONFIGS: Record<SocialPlatformType, PlatformConfig>;
|
|
15
|
+
/**
|
|
16
|
+
* Attempts to normalize a social media input into a full URL.
|
|
17
|
+
* Returns { url, error } — url is the corrected URL or the original input, error is a message if invalid.
|
|
18
|
+
*/
|
|
19
|
+
export declare function normalizeSocialUrl(platform: SocialPlatformType, input: string): {
|
|
20
|
+
url: string;
|
|
21
|
+
error: string | null;
|
|
22
|
+
};
|
|
23
|
+
export { PLATFORM_CONFIGS };
|
|
24
|
+
export type { SocialPlatformType as SocialPlatform };
|
|
25
|
+
//# sourceMappingURL=socialMediaUrl.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"socialMediaUrl.d.ts","sourceRoot":"","sources":["../../../src/lib/utils/socialMediaUrl.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,MAAM,kBAAkB,GAAG,WAAW,GAAG,SAAS,GAAG,UAAU,GAAG,UAAU,GAAG,SAAS,GAAG,QAAQ,GAAG,gBAAgB,CAAC;AAE7H,UAAU,cAAc;IACpB,OAAO,EAAE,MAAM,CAAC;IAEhB,aAAa,EAAE,MAAM,CAAC;IAEtB,UAAU,EAAE,MAAM,CAAC;IAEnB,QAAQ,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,MAAM,CAAC;IACvC,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;CAChB;AAED,QAAA,MAAM,gBAAgB,EAAE,MAAM,CAAC,kBAAkB,EAAE,cAAc,CAyDhE,CAAC;AAEF;;;GAGG;AACH,wBAAgB,kBAAkB,CAC9B,QAAQ,EAAE,kBAAkB,EAC5B,KAAK,EAAE,MAAM,GACd;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,CAiCvC;AAED,OAAO,EAAE,gBAAgB,EAAE,CAAC;AAC5B,YAAY,EAAE,kBAAkB,IAAI,cAAc,EAAE,CAAC"}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Normalizes social media input (username or partial URL) into a fully qualified URL.
|
|
3
|
+
* Handles cases where users enter just a username, handle, or partial URL.
|
|
4
|
+
*/
|
|
5
|
+
const PLATFORM_CONFIGS = {
|
|
6
|
+
instagram: {
|
|
7
|
+
baseUrl: 'https://instagram.com/',
|
|
8
|
+
usernameRegex: /^[a-zA-Z0-9._]{1,30}$/,
|
|
9
|
+
urlPattern: /^https?:\/\/(www\.)?instagram\.com\/([a-zA-Z0-9._]+)\/?/,
|
|
10
|
+
buildUrl: (u) => `https://instagram.com/${u}`,
|
|
11
|
+
placeholder: 'pankaj.sharma or https://instagram.com/pankaj.sharma',
|
|
12
|
+
hint: 'Username: letters, numbers, . and _ (max 30 chars)',
|
|
13
|
+
},
|
|
14
|
+
twitter: {
|
|
15
|
+
baseUrl: 'https://x.com/',
|
|
16
|
+
usernameRegex: /^[a-zA-Z0-9_]{1,15}$/,
|
|
17
|
+
urlPattern: /^https?:\/\/(www\.)?(twitter\.com|x\.com)\/([a-zA-Z0-9_]+)\/?/,
|
|
18
|
+
buildUrl: (u) => `https://x.com/${u}`,
|
|
19
|
+
placeholder: 'pankajsharma or https://x.com/pankajsharma',
|
|
20
|
+
hint: 'Username: letters, numbers, _ (max 15 chars)',
|
|
21
|
+
},
|
|
22
|
+
linkedin: {
|
|
23
|
+
baseUrl: 'https://linkedin.com/in/',
|
|
24
|
+
usernameRegex: /^[a-zA-Z0-9-]{3,100}$/,
|
|
25
|
+
urlPattern: /^https?:\/\/(www\.)?linkedin\.com\/in\/([a-zA-Z0-9-]+)\/?/,
|
|
26
|
+
buildUrl: (u) => `https://linkedin.com/in/${u}`,
|
|
27
|
+
placeholder: 'pankaj-sharma or https://linkedin.com/in/pankaj-sharma',
|
|
28
|
+
hint: 'Username: letters, numbers, - (3–100 chars)',
|
|
29
|
+
},
|
|
30
|
+
facebook: {
|
|
31
|
+
baseUrl: 'https://facebook.com/',
|
|
32
|
+
usernameRegex: /^[a-zA-Z0-9.]{5,50}$/,
|
|
33
|
+
urlPattern: /^https?:\/\/(www\.)?facebook\.com\/([a-zA-Z0-9.]+)\/?/,
|
|
34
|
+
buildUrl: (u) => `https://facebook.com/${u}`,
|
|
35
|
+
placeholder: 'pankaj.sharma or https://facebook.com/pankaj.sharma',
|
|
36
|
+
hint: 'Username: letters, numbers, . (5–50 chars)',
|
|
37
|
+
},
|
|
38
|
+
youtube: {
|
|
39
|
+
baseUrl: 'https://youtube.com/@',
|
|
40
|
+
usernameRegex: /^@?[a-zA-Z0-9_-]{3,30}$/,
|
|
41
|
+
urlPattern: /^https?:\/\/(www\.)?youtube\.com\/@?([a-zA-Z0-9_-]+)\/?/,
|
|
42
|
+
buildUrl: (u) => `https://youtube.com/@${u.replace(/^@/, '')}`,
|
|
43
|
+
placeholder: '@pankajsharma or https://youtube.com/@pankajsharma',
|
|
44
|
+
hint: 'Handle: letters, numbers, _ and - (3–30 chars)',
|
|
45
|
+
},
|
|
46
|
+
github: {
|
|
47
|
+
baseUrl: 'https://github.com/',
|
|
48
|
+
usernameRegex: /^[a-zA-Z0-9-]{1,39}$/,
|
|
49
|
+
urlPattern: /^https?:\/\/(www\.)?github\.com\/([a-zA-Z0-9-]+)\/?/,
|
|
50
|
+
buildUrl: (u) => `https://github.com/${u}`,
|
|
51
|
+
placeholder: 'pankaj-sharma or https://github.com/pankaj-sharma',
|
|
52
|
+
hint: 'Username: letters, numbers, - (max 39 chars)',
|
|
53
|
+
},
|
|
54
|
+
googleBusiness: {
|
|
55
|
+
baseUrl: 'https://mybusiness.google.com/',
|
|
56
|
+
usernameRegex: /^[a-zA-Z0-9-]{1,39}$/, // Adjust regex as needed
|
|
57
|
+
urlPattern: /^https?:\/\/(www\.)?mybusiness\.google\.com\/([a-zA-Z0-9-]+)\/?/,
|
|
58
|
+
buildUrl: (u) => `https://mybusiness.google.com/${u}`,
|
|
59
|
+
placeholder: 'pankaj-sharma or https://mybusiness.google.com/pankaj-sharma',
|
|
60
|
+
hint: 'Username: letters, numbers, - (max 39 chars)',
|
|
61
|
+
},
|
|
62
|
+
};
|
|
63
|
+
/**
|
|
64
|
+
* Attempts to normalize a social media input into a full URL.
|
|
65
|
+
* Returns { url, error } — url is the corrected URL or the original input, error is a message if invalid.
|
|
66
|
+
*/
|
|
67
|
+
export function normalizeSocialUrl(platform, input) {
|
|
68
|
+
const cfg = PLATFORM_CONFIGS[platform];
|
|
69
|
+
if (!input || input.trim() === '')
|
|
70
|
+
return { url: '', error: null };
|
|
71
|
+
const trimmed = input.trim();
|
|
72
|
+
// Already a full URL for this platform → extract username and rebuild canonical
|
|
73
|
+
const urlMatch = trimmed.match(cfg.urlPattern);
|
|
74
|
+
if (urlMatch) {
|
|
75
|
+
// Take the captured username group (last capture group)
|
|
76
|
+
const username = urlMatch[urlMatch.length - 1] ?? trimmed;
|
|
77
|
+
return { url: cfg.buildUrl(username), error: null };
|
|
78
|
+
}
|
|
79
|
+
// Looks like a URL for a *different* site or malformed URL
|
|
80
|
+
if (trimmed.startsWith('http://') || trimmed.startsWith('https://') || trimmed.includes('.com/') || trimmed.includes('.net/')) {
|
|
81
|
+
return {
|
|
82
|
+
url: trimmed,
|
|
83
|
+
error: `That doesn't look like a valid ${platform} URL. ${cfg.hint}`,
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
// Plain username — validate and build URL
|
|
87
|
+
const usernameToTest = trimmed.replace(/^@/, ''); // strip leading @ for youtube/etc
|
|
88
|
+
const testValue = platform === 'youtube' ? trimmed : usernameToTest;
|
|
89
|
+
if (!cfg.usernameRegex.test(testValue)) {
|
|
90
|
+
return {
|
|
91
|
+
url: trimmed,
|
|
92
|
+
error: `Invalid ${platform} username. ${cfg.hint}`,
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
return { url: cfg.buildUrl(usernameToTest), error: null };
|
|
96
|
+
}
|
|
97
|
+
export { PLATFORM_CONFIGS };
|
package/dist/lib/utils.js
CHANGED
|
@@ -61,11 +61,11 @@ export function getProgressValue(status) {
|
|
|
61
61
|
export const truncateText = (text, limit) => text.length > limit ? text.substring(0, limit) + "..." : text;
|
|
62
62
|
export const numToStr = (input) => {
|
|
63
63
|
if (input > 1000000000)
|
|
64
|
-
return `${input /
|
|
64
|
+
return `${(input / 1000000000).toFixed(1)}B+`;
|
|
65
65
|
if (input > 1000000)
|
|
66
|
-
return `${input / 1000000}M+`;
|
|
66
|
+
return `${(input / 1000000).toFixed(1)}M+`;
|
|
67
67
|
if (input > 1000)
|
|
68
|
-
return `${input / 1000}K+`;
|
|
68
|
+
return `${(input / 1000).toFixed(1)}K+`;
|
|
69
69
|
return `${input}`;
|
|
70
70
|
};
|
|
71
71
|
export const handleEmail = (email, subject, body) => window.location.href = `mailto:${email}?subject=${subject}&body=${body}`;
|
|
@@ -173,7 +173,7 @@ export function incompleteMVP(user) {
|
|
|
173
173
|
if (!user.pinCode)
|
|
174
174
|
incompletions.push("PinCode");
|
|
175
175
|
if (!user.profilePic)
|
|
176
|
-
incompletions.push("
|
|
176
|
+
incompletions.push("Profile Pic");
|
|
177
177
|
}
|
|
178
178
|
else {
|
|
179
179
|
incompletions.push("Please login first");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@myrjfa/state",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.1.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./dist/index.js",
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
"description": "Shared state management for myrjfa apps",
|
|
10
10
|
"main": "dist/index.js",
|
|
11
11
|
"types": "dist/index.d.ts",
|
|
12
|
+
"sideEffects": false,
|
|
12
13
|
"files": [
|
|
13
14
|
"dist"
|
|
14
15
|
],
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"severActions.d.ts","sourceRoot":"","sources":["../../../src/lib/actions/severActions.ts"],"names":[],"mappings":"AAKA,wBAAsB,eAAe,IAAI,OAAO,CAAC,MAAM,CAAC,CAKvD;AAED,wBAAsB,OAAO,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAQtD"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"notfications.d.ts","sourceRoot":"","sources":["../../../src/lib/models/notfications.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA0DtB,CAAC;AAEH,MAAM,MAAM,KAAK,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAAC,CAAC"}
|
|
File without changes
|