@myrjfa/state 1.1.1 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +34 -18
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +34 -18
- package/dist/lib/actions/actions.d.ts +170 -170
- package/dist/lib/actions/actions.js +307 -307
- package/dist/lib/actions/auth.d.ts +20 -0
- package/dist/lib/actions/auth.d.ts.map +1 -1
- package/dist/lib/actions/booking.d.ts +30 -0
- package/dist/lib/actions/booking.d.ts.map +1 -0
- package/dist/lib/actions/booking.js +77 -0
- package/dist/lib/actions/fetcher.js +84 -84
- package/dist/lib/actions/severActions.js +2 -2
- package/dist/lib/authSessionManager.js +34 -34
- package/dist/lib/context/ChatContext.js +338 -338
- package/dist/lib/models/adventure.d.ts +75 -0
- package/dist/lib/models/adventure.d.ts.map +1 -0
- package/dist/lib/models/adventure.js +1 -0
- package/dist/lib/models/blog.d.ts +4 -4
- package/dist/lib/models/booking.d.ts +47 -0
- package/dist/lib/models/booking.d.ts.map +1 -0
- package/dist/lib/models/booking.js +1 -0
- package/dist/lib/models/guide.d.ts +43 -0
- package/dist/lib/models/guide.d.ts.map +1 -0
- package/dist/lib/models/guide.js +1 -0
- package/dist/lib/models/notfications.d.ts +93 -93
- package/dist/lib/models/opportunities/freelance.d.ts +74 -6
- package/dist/lib/models/opportunities/freelance.d.ts.map +1 -1
- package/dist/lib/models/opportunities/internship.d.ts +74 -6
- package/dist/lib/models/opportunities/internship.d.ts.map +1 -1
- package/dist/lib/models/opportunities/job.d.ts +74 -6
- package/dist/lib/models/opportunities/job.d.ts.map +1 -1
- package/dist/lib/models/opportunities/opportunity.d.ts +74 -6
- package/dist/lib/models/opportunities/opportunity.d.ts.map +1 -1
- package/dist/lib/models/opportunities/volunteerJob.d.ts +74 -6
- package/dist/lib/models/opportunities/volunteerJob.d.ts.map +1 -1
- package/dist/lib/models/package.d.ts +264 -0
- package/dist/lib/models/package.d.ts.map +1 -0
- package/dist/lib/models/package.js +58 -0
- package/dist/lib/models/portfolio.d.ts +42 -42
- package/dist/lib/models/props.d.ts +3 -0
- package/dist/lib/models/props.d.ts.map +1 -1
- package/dist/lib/models/props.js +36 -0
- package/dist/lib/models/rental.d.ts +85 -0
- package/dist/lib/models/rental.d.ts.map +1 -0
- package/dist/lib/models/rental.js +1 -0
- package/dist/lib/models/review.d.ts +1 -1
- package/dist/lib/models/review.d.ts.map +1 -1
- package/dist/lib/models/stay.d.ts +459 -0
- package/dist/lib/models/stay.d.ts.map +1 -0
- package/dist/lib/models/stay.js +214 -0
- package/dist/lib/models/tile.d.ts +53 -28
- package/dist/lib/models/tile.d.ts.map +1 -1
- package/dist/lib/models/user.d.ts +48 -0
- package/dist/lib/models/user.d.ts.map +1 -1
- package/dist/lib/models/user.js +10 -0
- package/dist/lib/userAtom.d.ts +238 -198
- package/dist/lib/userAtom.d.ts.map +1 -1
- package/dist/lib/userAtom.js +127 -127
- package/package.json +6 -1
- package/dist/lib/actions/property.d.ts +0 -77
- package/dist/lib/actions/property.d.ts.map +0 -1
- package/dist/lib/actions/property.js +0 -133
- package/dist/lib/actions.d.ts +0 -141
- package/dist/lib/actions.d.ts.map +0 -1
- package/dist/lib/actions.js +0 -307
- package/dist/lib/auth.d.ts +0 -150
- package/dist/lib/auth.d.ts.map +0 -1
- package/dist/lib/auth.js +0 -125
- package/dist/lib/fetcher.d.ts +0 -9
- package/dist/lib/fetcher.d.ts.map +0 -1
- package/dist/lib/fetcher.js +0 -84
- package/dist/lib/models/property.d.ts +0 -79
- package/dist/lib/models/property.d.ts.map +0 -1
- package/dist/lib/models/property.js +0 -134
- package/dist/lib/models/volunteerJob.d.ts +0 -398
- package/dist/lib/models/volunteerJob.d.ts.map +0 -1
- package/dist/lib/models/volunteerJob.js +0 -152
- package/dist/lib/severActions.d.ts +0 -3
- package/dist/lib/severActions.d.ts.map +0 -1
- package/dist/lib/severActions.js +0 -19
- package/dist/lib/socket.d.ts +0 -7
- package/dist/lib/socket.d.ts.map +0 -1
- package/dist/lib/socket.js +0 -22
- package/dist/lib/utils/socialMediaUrl.d.ts +0 -25
- package/dist/lib/utils/socialMediaUrl.d.ts.map +0 -1
- package/dist/lib/utils/socialMediaUrl.js +0 -97
|
@@ -1,152 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
import { UserSchema, zroles } from "./user";
|
|
3
|
-
import { QuestionSchema } from "./props";
|
|
4
|
-
export const OpportunitySchema = z.object({
|
|
5
|
-
slug: z.string(),
|
|
6
|
-
title: z.string(),
|
|
7
|
-
skills: z.array(z.string()),
|
|
8
|
-
description: z.string(),
|
|
9
|
-
images: z.array(z.string()),
|
|
10
|
-
categoryId: z.string().optional(),
|
|
11
|
-
city: z.string(),
|
|
12
|
-
state: z.string(),
|
|
13
|
-
country: z.string(),
|
|
14
|
-
address: z.string().optional(),
|
|
15
|
-
availableFrom: z.date(),
|
|
16
|
-
minDuration: z.number(),
|
|
17
|
-
maxDuration: z.number(),
|
|
18
|
-
urgent: z.boolean(),
|
|
19
|
-
applicationCount: z.number(),
|
|
20
|
-
peopleRequired: z.number(),
|
|
21
|
-
facilities: z.array(z.string()),
|
|
22
|
-
responsibilities: z.array(z.string()),
|
|
23
|
-
questions: z.array(QuestionSchema), // 👈 use validated QuestionSchema
|
|
24
|
-
rating: z.number(),
|
|
25
|
-
ratingCount: z.number(),
|
|
26
|
-
reviewCount: z.number(),
|
|
27
|
-
hostId: z.lazy(() => UserSchema), // 👈 assuming user validation
|
|
28
|
-
applicationObservers: z.array(z.object({
|
|
29
|
-
username: z.string(),
|
|
30
|
-
role: zroles,
|
|
31
|
-
countryCode: z.string(),
|
|
32
|
-
phoneNumber: z.string(),
|
|
33
|
-
email: z.string(),
|
|
34
|
-
})).optional(),
|
|
35
|
-
hostingType: z.string().optional(),
|
|
36
|
-
views: z.number(),
|
|
37
|
-
shares: z.number(),
|
|
38
|
-
status: z.enum(['draft', 'archived', 'pending', 'open', 'closed', 'denied', 'deleted']),
|
|
39
|
-
createdAt: z.date().optional(),
|
|
40
|
-
updatedAt: z.date().optional(),
|
|
41
|
-
adminApproval: z.boolean(),
|
|
42
|
-
}).strict();
|
|
43
|
-
// options for what volunteers get
|
|
44
|
-
export const facilitiesOptions = [
|
|
45
|
-
{ icon: "/images/facilities/room.webp", title: "Shared Room" },
|
|
46
|
-
{ icon: "/images/facilities/room.webp", title: "Private Room" },
|
|
47
|
-
{ icon: "/images/facilities/room.webp", title: "Dormitory" },
|
|
48
|
-
{ icon: "/images/facilities/room.webp", title: "Accomodation" },
|
|
49
|
-
{ icon: "/images/facilities/meal.webp", title: "1 Meal/Day" },
|
|
50
|
-
{ icon: "/images/facilities/meal.webp", title: "2 Meals/Day" },
|
|
51
|
-
{ icon: "/images/facilities/meal.webp", title: "3 Meals/Day" },
|
|
52
|
-
{ icon: "/images/facilities/meal.webp", title: "Food" },
|
|
53
|
-
{ icon: "/images/facilities/meal.webp", title: "Snacks / Tea" },
|
|
54
|
-
{ icon: "/images/facilities/meal.webp", title: "Cooking Facilities" },
|
|
55
|
-
{ icon: "/images/facilities/laundry.webp", title: "Free Laundry" },
|
|
56
|
-
{ icon: "/images/facilities/laundry.webp", title: "Paid Laundry" },
|
|
57
|
-
{ icon: "/images/facilities/internet.webp", title: "Wi-Fi" },
|
|
58
|
-
{ icon: "/images/facilities/transport.webp", title: "Airport Pickup" },
|
|
59
|
-
{ icon: "/images/facilities/transport.webp", title: "Local Transport" },
|
|
60
|
-
{ icon: "/images/facilities/study.webp", title: "Study/Work Space" },
|
|
61
|
-
{ icon: "/images/facilities/events.webp", title: "Free Events" },
|
|
62
|
-
{ icon: "/images/facilities/events.webp", title: "Paid Events" },
|
|
63
|
-
{ icon: "/images/facilities/fitness.webp", title: "Gym or Yoga" },
|
|
64
|
-
{ icon: "/images/facilities/recreation.webp", title: "Recreational Activities" },
|
|
65
|
-
{ icon: "/images/facilities/tours.webp", title: "Guided Tours" },
|
|
66
|
-
{ icon: "/images/facilities/certificate.webp", title: "Certificate" },
|
|
67
|
-
];
|
|
68
|
-
export const otherFacilitiesOptions = [
|
|
69
|
-
{ icon: "/images/facilities/room.webp", title: "room" },
|
|
70
|
-
{ icon: "/images/facilities/room.webp", title: "dorm" },
|
|
71
|
-
{ icon: "/images/facilities/room.webp", title: "accomodation" },
|
|
72
|
-
{ icon: "/images/facilities/meal.webp", title: "meal" },
|
|
73
|
-
{ icon: "/images/facilities/meal.webp", title: "breakfast" },
|
|
74
|
-
{ icon: "/images/facilities/meal.webp", title: "dinner" },
|
|
75
|
-
{ icon: "/images/facilities/meal.webp", title: "food" },
|
|
76
|
-
{ icon: "/images/facilities/meal.webp", title: "snack" },
|
|
77
|
-
{ icon: "/images/facilities/meal.webp", title: "cook" },
|
|
78
|
-
{ icon: "/images/facilities/laundry.webp", title: "laundry" },
|
|
79
|
-
{ icon: "/images/facilities/internet.webp", title: "internet" },
|
|
80
|
-
{ icon: "/images/facilities/transport.webp", title: "pickup" },
|
|
81
|
-
{ icon: "/images/facilities/transport.webp", title: "transport" },
|
|
82
|
-
{ icon: "/images/facilities/transport.webp", title: "vehicle" },
|
|
83
|
-
{ icon: "/images/facilities/transport.webp", title: "bus" },
|
|
84
|
-
{ icon: "/images/facilities/study.webp", title: "study" },
|
|
85
|
-
{ icon: "/images/facilities/study.webp", title: "work" },
|
|
86
|
-
{ icon: "/images/facilities/events.webp", title: "event" },
|
|
87
|
-
{ icon: "/images/facilities/events.webp", title: "function" },
|
|
88
|
-
{ icon: "/images/facilities/fitness.webp", title: "gym" },
|
|
89
|
-
{ icon: "/images/facilities/fitness.webp", title: "yoga" },
|
|
90
|
-
{ icon: "/images/facilities/fitness.webp", title: "fit" },
|
|
91
|
-
{ icon: "/images/facilities/recreation.webp", title: "recreational" },
|
|
92
|
-
{ icon: "/images/facilities/tours.webp", title: "guide" },
|
|
93
|
-
{ icon: "/images/facilities/tours.webp", title: "tour" },
|
|
94
|
-
{ icon: "/images/facilities/certificate.webp", title: "certificate" },
|
|
95
|
-
{ icon: "/images/facilities/certificate.webp", title: "award" },
|
|
96
|
-
{ icon: "/images/facilities/certificate.webp", title: "recognition" },
|
|
97
|
-
{ icon: "/images/facilities/certificate.webp", title: "appreciation" },
|
|
98
|
-
{ icon: "/images/facilities/certificate.webp", title: "letter" },
|
|
99
|
-
{ icon: "/images/facilities/money.webp", title: "stipend" },
|
|
100
|
-
{ icon: "/images/facilities/money.webp", title: "cash" },
|
|
101
|
-
{ icon: "/images/facilities/money.webp", title: "payment" },
|
|
102
|
-
{ icon: "/images/facilities/money.webp", title: "salary" },
|
|
103
|
-
{ icon: "/images/facilities/money.webp", title: "compensation" },
|
|
104
|
-
{ icon: "/images/facilities/money.webp", title: "pay" },
|
|
105
|
-
];
|
|
106
|
-
// options for what volunteers offer
|
|
107
|
-
export const responsibilitiesOptions = [
|
|
108
|
-
{ icon: "/images/responsibilities/timer.webp", title: "4 Hours/Day" },
|
|
109
|
-
{ icon: "/images/responsibilities/timer.webp", title: "5 Hours/Day" },
|
|
110
|
-
{ icon: "/images/responsibilities/timer.webp", title: "6 Hours/Day" },
|
|
111
|
-
{ icon: "/images/responsibilities/timer.webp", title: "Flexible Schedule" },
|
|
112
|
-
{ icon: "/images/responsibilities/teamwork.webp", title: "Team Work" },
|
|
113
|
-
{ icon: "/images/responsibilities/initiative.webp", title: "Take Initiative" },
|
|
114
|
-
{ icon: "/images/responsibilities/communication.webp", title: "Good Communication" },
|
|
115
|
-
{ icon: "/images/responsibilities/adaptability.webp", title: "Stay Flexible" },
|
|
116
|
-
{ icon: "/images/responsibilities/punctuality.webp", title: "Be On Time" },
|
|
117
|
-
{ icon: "/images/responsibilities/punctuality.webp", title: "Punctuality" },
|
|
118
|
-
{ icon: "/images/responsibilities/rules.webp", title: "Respect House Rules" },
|
|
119
|
-
{ icon: "/images/responsibilities/learning.webp", title: "Willing to Learn" },
|
|
120
|
-
{ icon: "/images/responsibilities/events.webp", title: "Support Events" },
|
|
121
|
-
{ icon: "/images/responsibilities/cleanliness.webp", title: "Maintain cleanliness" },
|
|
122
|
-
{ icon: "/images/responsibilities/mindset.webp", title: "Positive Attitude" },
|
|
123
|
-
{ icon: "/images/responsibilities/ethics.webp", title: "Respect Culture" },
|
|
124
|
-
];
|
|
125
|
-
export const otherResponsibilitiesOptions = [
|
|
126
|
-
{ icon: "/images/responsibilities/timer.webp", title: "hour" },
|
|
127
|
-
{ icon: "/images/responsibilities/timer.webp", title: "minute" },
|
|
128
|
-
{ icon: "/images/responsibilities/timer.webp", title: "schedule" },
|
|
129
|
-
{ icon: "/images/responsibilities/teamwork.webp", title: "team" },
|
|
130
|
-
{ icon: "/images/responsibilities/teamwork.webp", title: "social" },
|
|
131
|
-
{ icon: "/images/responsibilities/initiative.webp", title: "initiative" },
|
|
132
|
-
{ icon: "/images/responsibilities/initiative.webp", title: "idea" },
|
|
133
|
-
{ icon: "/images/responsibilities/communication.webp", title: "communication" },
|
|
134
|
-
{ icon: "/images/responsibilities/communication.webp", title: "spoke" },
|
|
135
|
-
{ icon: "/images/responsibilities/communication.webp", title: "speak" },
|
|
136
|
-
{ icon: "/images/responsibilities/communication.webp", title: "talk" },
|
|
137
|
-
{ icon: "/images/responsibilities/adaptability.webp", title: "flexible" },
|
|
138
|
-
{ icon: "/images/responsibilities/punctuality.webp", title: "time" },
|
|
139
|
-
{ icon: "/images/responsibilities/punctuality.webp", title: "punctual" },
|
|
140
|
-
{ icon: "/images/responsibilities/rules.webp", title: "rule" },
|
|
141
|
-
{ icon: "/images/responsibilities/learning.webp", title: "learn" },
|
|
142
|
-
{ icon: "/images/responsibilities/learning.webp", title: "grow" },
|
|
143
|
-
{ icon: "/images/responsibilities/events.webp", title: "event" },
|
|
144
|
-
{ icon: "/images/responsibilities/cleanliness.webp", title: "clean" },
|
|
145
|
-
{ icon: "/images/responsibilities/cleanliness.webp", title: "tidy" },
|
|
146
|
-
{ icon: "/images/responsibilities/mindset.webp", title: "mind" },
|
|
147
|
-
{ icon: "/images/responsibilities/mindset.webp", title: "brain" },
|
|
148
|
-
{ icon: "/images/responsibilities/ethics.webp", title: "respect" },
|
|
149
|
-
{ icon: "/images/responsibilities/ethics.webp", title: "culture" },
|
|
150
|
-
{ icon: "/images/responsibilities/ethics.webp", title: "ethics" },
|
|
151
|
-
{ icon: "/images/responsibilities/ethics.webp", title: "rules" },
|
|
152
|
-
];
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"severActions.d.ts","sourceRoot":"","sources":["../../src/lib/severActions.ts"],"names":[],"mappings":"AAKA,wBAAsB,eAAe,IAAI,OAAO,CAAC,MAAM,CAAC,CAKvD;AAED,wBAAsB,OAAO,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAQtD"}
|
package/dist/lib/severActions.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
'use server';
|
|
2
|
-
import { cookies } from 'next/headers';
|
|
3
|
-
import { validRoles } from './utils';
|
|
4
|
-
export async function getCookieHeader() {
|
|
5
|
-
const cookieStore = await cookies();
|
|
6
|
-
return Array.from(cookieStore)
|
|
7
|
-
.map(([name, cookie]) => `${name}=${cookie.value}`)
|
|
8
|
-
.join('; ');
|
|
9
|
-
}
|
|
10
|
-
export async function getRole() {
|
|
11
|
-
try {
|
|
12
|
-
const role = (await cookies()).get("role")?.value ?? null;
|
|
13
|
-
return (role && validRoles.includes(role)) ? role : null;
|
|
14
|
-
}
|
|
15
|
-
catch (err) {
|
|
16
|
-
console.error('Invalid token', err);
|
|
17
|
-
return null;
|
|
18
|
-
}
|
|
19
|
-
}
|
package/dist/lib/socket.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { Socket } from "socket.io-client";
|
|
2
|
-
import { type PrimitiveAtom } from "jotai";
|
|
3
|
-
export declare const socketAtom: PrimitiveAtom<Socket | null>;
|
|
4
|
-
export declare const isConnectedAtom: PrimitiveAtom<boolean>;
|
|
5
|
-
export declare const getSocket: () => Socket;
|
|
6
|
-
export declare const disconnectSocket: () => void;
|
|
7
|
-
//# sourceMappingURL=socket.d.ts.map
|
package/dist/lib/socket.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"socket.d.ts","sourceRoot":"","sources":["../../src/lib/socket.ts"],"names":[],"mappings":"AAAA,OAAO,EAAM,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAQ,KAAK,aAAa,EAAE,MAAM,OAAO,CAAC;AAMjD,eAAO,MAAM,UAAU,EAAE,aAAa,CAAC,MAAM,GAAG,IAAI,CAA6B,CAAC;AAClF,eAAO,MAAM,eAAe,EAAE,aAAa,CAAC,OAAO,CAAwB,CAAC;AAE5E,eAAO,MAAM,SAAS,QAAO,MAS5B,CAAC;AAEF,eAAO,MAAM,gBAAgB,YAK5B,CAAA"}
|
package/dist/lib/socket.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { io } from "socket.io-client";
|
|
2
|
-
import { atom } from "jotai";
|
|
3
|
-
const SOCKET_URL = process.env.NEXT_PUBLIC_BACKEND_URL || "http://localhost:8000";
|
|
4
|
-
let socket = null;
|
|
5
|
-
export const socketAtom = atom(null);
|
|
6
|
-
export const isConnectedAtom = atom(false);
|
|
7
|
-
export const getSocket = () => {
|
|
8
|
-
if (!socket) {
|
|
9
|
-
socket = io(SOCKET_URL, {
|
|
10
|
-
autoConnect: false,
|
|
11
|
-
withCredentials: true,
|
|
12
|
-
transports: ["websocket", "polling"],
|
|
13
|
-
});
|
|
14
|
-
}
|
|
15
|
-
return socket;
|
|
16
|
-
};
|
|
17
|
-
export const disconnectSocket = () => {
|
|
18
|
-
if (socket?.connected) {
|
|
19
|
-
socket.disconnect();
|
|
20
|
-
}
|
|
21
|
-
socket = null;
|
|
22
|
-
};
|
|
@@ -1,25 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,97 +0,0 @@
|
|
|
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 };
|