@careflair/common 1.0.6 → 1.0.8

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.
@@ -1,30 +1,30 @@
1
- import { z } from "zod";
2
- export declare const UserRegistrationSchema: z.ZodObject<{
3
- email: z.ZodEffects<z.ZodString, string, string>;
4
- username: z.ZodString;
5
- password: z.ZodString;
6
- role: z.ZodEnum<["business", "provider", "participant", "support_person", "support_worker"]>;
7
- fingerPrint: z.ZodOptional<z.ZodString>;
8
- firstName: z.ZodString;
9
- lastName: z.ZodString;
10
- isSmallProvider: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
11
- }, "strip", z.ZodTypeAny, {
12
- role: "business" | "provider" | "participant" | "support_person" | "support_worker";
13
- username: string;
14
- email: string;
15
- password: string;
16
- firstName: string;
17
- lastName: string;
18
- isSmallProvider: boolean;
19
- fingerPrint?: string | undefined;
20
- }, {
21
- role: "business" | "provider" | "participant" | "support_person" | "support_worker";
22
- username: string;
23
- email: string;
24
- password: string;
25
- firstName: string;
26
- lastName: string;
27
- fingerPrint?: string | undefined;
28
- isSmallProvider?: boolean | undefined;
29
- }>;
30
- export type UserRegistrationInput = z.infer<typeof UserRegistrationSchema>;
1
+ import { z } from "zod";
2
+ export declare const UserRegistrationSchema: z.ZodObject<{
3
+ email: z.ZodEffects<z.ZodString, string, string>;
4
+ username: z.ZodString;
5
+ password: z.ZodString;
6
+ role: z.ZodEnum<["business", "provider", "participant", "support_person", "support_worker"]>;
7
+ fingerPrint: z.ZodOptional<z.ZodString>;
8
+ firstName: z.ZodString;
9
+ lastName: z.ZodString;
10
+ isSmallProvider: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
11
+ }, "strip", z.ZodTypeAny, {
12
+ role: "business" | "provider" | "participant" | "support_person" | "support_worker";
13
+ username: string;
14
+ email: string;
15
+ password: string;
16
+ firstName: string;
17
+ lastName: string;
18
+ isSmallProvider: boolean;
19
+ fingerPrint?: string | undefined;
20
+ }, {
21
+ role: "business" | "provider" | "participant" | "support_person" | "support_worker";
22
+ username: string;
23
+ email: string;
24
+ password: string;
25
+ firstName: string;
26
+ lastName: string;
27
+ fingerPrint?: string | undefined;
28
+ isSmallProvider?: boolean | undefined;
29
+ }>;
30
+ export type UserRegistrationInput = z.infer<typeof UserRegistrationSchema>;
@@ -1,38 +1,38 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.UserRegistrationSchema = void 0;
4
- const zod_1 = require("zod");
5
- const limits_1 = require("../constants/limits");
6
- exports.UserRegistrationSchema = zod_1.z.object({
7
- email: zod_1.z
8
- .string()
9
- .email()
10
- .max(limits_1.EMAIL_MAX_LENGTH, `Email must be at most ${limits_1.EMAIL_MAX_LENGTH} characters long`)
11
- .refine((email) => !email.includes("+"), {
12
- message: "Email aliasing with '+' is not allowed",
13
- }),
14
- username: zod_1.z
15
- .string()
16
- .min(limits_1.USERNAME_MIN_LENGTH, `Username must be at least ${limits_1.USERNAME_MIN_LENGTH} characters long`)
17
- .max(limits_1.USERNAME_MAX_LENGTH, `Username must be at most ${limits_1.USERNAME_MAX_LENGTH} characters long`),
18
- password: zod_1.z
19
- .string()
20
- .min(limits_1.PASSWORD_MIN_LENGTH, `Password must be at least ${limits_1.PASSWORD_MIN_LENGTH} characters long`)
21
- .max(limits_1.PASSWORD_MAX_LENGTH, `Password must be at most ${limits_1.PASSWORD_MAX_LENGTH} characters long`),
22
- role: zod_1.z.enum(["business", "provider", "participant", "support_person", "support_worker"], {
23
- message: "Role must be one of: business, provider, participant, support_person, support_worker",
24
- }),
25
- fingerPrint: zod_1.z.string().optional(),
26
- firstName: zod_1.z
27
- .string()
28
- .min(limits_1.NAME_MIN_LENGTH, `First name must be at least ${limits_1.NAME_MIN_LENGTH} characters long`)
29
- .max(limits_1.NAME_MAX_LENGTH, `First name must be at most ${limits_1.NAME_MAX_LENGTH} characters long`),
30
- lastName: zod_1.z
31
- .string()
32
- .min(limits_1.NAME_MIN_LENGTH, `Last name must be at least ${limits_1.NAME_MIN_LENGTH} characters long`)
33
- .max(limits_1.NAME_MAX_LENGTH, `Last name must be at most ${limits_1.NAME_MAX_LENGTH} characters long`),
34
- isSmallProvider: zod_1.z.boolean().optional().default(false),
35
- // businessName: z.string().optional(),
36
- // entityTypeCode: z.string().optional(),
37
- // abn: z.string().optional(),
38
- });
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UserRegistrationSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ const limits_1 = require("../constants/limits");
6
+ exports.UserRegistrationSchema = zod_1.z.object({
7
+ email: zod_1.z
8
+ .string()
9
+ .email()
10
+ .max(limits_1.EMAIL_MAX_LENGTH, `Email must be at most ${limits_1.EMAIL_MAX_LENGTH} characters long`)
11
+ .refine((email) => !email.includes("+"), {
12
+ message: "Email aliasing with '+' is not allowed",
13
+ }),
14
+ username: zod_1.z
15
+ .string()
16
+ .min(limits_1.USERNAME_MIN_LENGTH, `Username must be at least ${limits_1.USERNAME_MIN_LENGTH} characters long`)
17
+ .max(limits_1.USERNAME_MAX_LENGTH, `Username must be at most ${limits_1.USERNAME_MAX_LENGTH} characters long`),
18
+ password: zod_1.z
19
+ .string()
20
+ .min(limits_1.PASSWORD_MIN_LENGTH, `Password must be at least ${limits_1.PASSWORD_MIN_LENGTH} characters long`)
21
+ .max(limits_1.PASSWORD_MAX_LENGTH, `Password must be at most ${limits_1.PASSWORD_MAX_LENGTH} characters long`),
22
+ role: zod_1.z.enum(["business", "provider", "participant", "support_person", "support_worker"], {
23
+ message: "Role must be one of: business, provider, participant, support_person, support_worker",
24
+ }),
25
+ fingerPrint: zod_1.z.string().optional(),
26
+ firstName: zod_1.z
27
+ .string()
28
+ .min(limits_1.NAME_MIN_LENGTH, `First name must be at least ${limits_1.NAME_MIN_LENGTH} characters long`)
29
+ .max(limits_1.NAME_MAX_LENGTH, `First name must be at most ${limits_1.NAME_MAX_LENGTH} characters long`),
30
+ lastName: zod_1.z
31
+ .string()
32
+ .min(limits_1.NAME_MIN_LENGTH, `Last name must be at least ${limits_1.NAME_MIN_LENGTH} characters long`)
33
+ .max(limits_1.NAME_MAX_LENGTH, `Last name must be at most ${limits_1.NAME_MAX_LENGTH} characters long`),
34
+ isSmallProvider: zod_1.z.boolean().optional().default(false),
35
+ // businessName: z.string().optional(),
36
+ // entityTypeCode: z.string().optional(),
37
+ // abn: z.string().optional(),
38
+ });
@@ -1,33 +1,33 @@
1
- import { z } from "zod";
2
- export declare const WorkHistorySchema: z.ZodEffects<z.ZodObject<{
3
- jobTitle: z.ZodString;
4
- startDate: z.ZodDate;
5
- endDate: z.ZodNullable<z.ZodOptional<z.ZodDate>>;
6
- organisation: z.ZodString;
7
- isCurrentlyWorking: z.ZodDefault<z.ZodBoolean>;
8
- }, "strip", z.ZodTypeAny, {
9
- startDate: Date;
10
- jobTitle: string;
11
- organisation: string;
12
- isCurrentlyWorking: boolean;
13
- endDate?: Date | null | undefined;
14
- }, {
15
- startDate: Date;
16
- jobTitle: string;
17
- organisation: string;
18
- endDate?: Date | null | undefined;
19
- isCurrentlyWorking?: boolean | undefined;
20
- }>, {
21
- startDate: Date;
22
- jobTitle: string;
23
- organisation: string;
24
- isCurrentlyWorking: boolean;
25
- endDate?: Date | null | undefined;
26
- }, {
27
- startDate: Date;
28
- jobTitle: string;
29
- organisation: string;
30
- endDate?: Date | null | undefined;
31
- isCurrentlyWorking?: boolean | undefined;
32
- }>;
33
- export type WorkHistoryInputValidation = z.infer<typeof WorkHistorySchema>;
1
+ import { z } from "zod";
2
+ export declare const WorkHistorySchema: z.ZodEffects<z.ZodObject<{
3
+ jobTitle: z.ZodString;
4
+ startDate: z.ZodDate;
5
+ endDate: z.ZodNullable<z.ZodOptional<z.ZodDate>>;
6
+ organisation: z.ZodString;
7
+ isCurrentlyWorking: z.ZodDefault<z.ZodBoolean>;
8
+ }, "strip", z.ZodTypeAny, {
9
+ startDate: Date;
10
+ jobTitle: string;
11
+ organisation: string;
12
+ isCurrentlyWorking: boolean;
13
+ endDate?: Date | null | undefined;
14
+ }, {
15
+ startDate: Date;
16
+ jobTitle: string;
17
+ organisation: string;
18
+ endDate?: Date | null | undefined;
19
+ isCurrentlyWorking?: boolean | undefined;
20
+ }>, {
21
+ startDate: Date;
22
+ jobTitle: string;
23
+ organisation: string;
24
+ isCurrentlyWorking: boolean;
25
+ endDate?: Date | null | undefined;
26
+ }, {
27
+ startDate: Date;
28
+ jobTitle: string;
29
+ organisation: string;
30
+ endDate?: Date | null | undefined;
31
+ isCurrentlyWorking?: boolean | undefined;
32
+ }>;
33
+ export type WorkHistoryInputValidation = z.infer<typeof WorkHistorySchema>;
@@ -1,28 +1,28 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.WorkHistorySchema = void 0;
4
- const zod_1 = require("zod");
5
- const limits_1 = require("../constants/limits");
6
- exports.WorkHistorySchema = zod_1.z
7
- .object({
8
- jobTitle: zod_1.z
9
- .string()
10
- .min(1, "Job title is required")
11
- .max(limits_1.WORK_HISTORY_TITLE_MAX_LENGTH, `Job title must be at most ${limits_1.WORK_HISTORY_TITLE_MAX_LENGTH} characters long`),
12
- startDate: zod_1.z.date(),
13
- endDate: zod_1.z.date().optional().nullable(),
14
- organisation: zod_1.z
15
- .string()
16
- .min(1, "Organisation is required")
17
- .max(limits_1.WORK_HISTORY_ORGANIZATION_MAX_LENGTH, `Organisation must be at most ${limits_1.WORK_HISTORY_ORGANIZATION_MAX_LENGTH} characters long`),
18
- isCurrentlyWorking: zod_1.z.boolean().default(false),
19
- })
20
- .refine((data) => {
21
- if (data.endDate) {
22
- return !data.isCurrentlyWorking;
23
- }
24
- return data.isCurrentlyWorking || data.endDate !== undefined;
25
- }, {
26
- message: "If there is an endDate, is Currently Working must be false. If is Currently Working is false, endDate must be provided.",
27
- path: ["endDate", "isCurrentlyWorking"],
28
- });
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.WorkHistorySchema = void 0;
4
+ const zod_1 = require("zod");
5
+ const limits_1 = require("../constants/limits");
6
+ exports.WorkHistorySchema = zod_1.z
7
+ .object({
8
+ jobTitle: zod_1.z
9
+ .string()
10
+ .min(1, "Job title is required")
11
+ .max(limits_1.WORK_HISTORY_TITLE_MAX_LENGTH, `Job title must be at most ${limits_1.WORK_HISTORY_TITLE_MAX_LENGTH} characters long`),
12
+ startDate: zod_1.z.date(),
13
+ endDate: zod_1.z.date().optional().nullable(),
14
+ organisation: zod_1.z
15
+ .string()
16
+ .min(1, "Organisation is required")
17
+ .max(limits_1.WORK_HISTORY_ORGANIZATION_MAX_LENGTH, `Organisation must be at most ${limits_1.WORK_HISTORY_ORGANIZATION_MAX_LENGTH} characters long`),
18
+ isCurrentlyWorking: zod_1.z.boolean().default(false),
19
+ })
20
+ .refine((data) => {
21
+ if (data.endDate) {
22
+ return !data.isCurrentlyWorking;
23
+ }
24
+ return data.isCurrentlyWorking || data.endDate !== undefined;
25
+ }, {
26
+ message: "If there is an endDate, is Currently Working must be false. If is Currently Working is false, endDate must be provided.",
27
+ path: ["endDate", "isCurrentlyWorking"],
28
+ });
@@ -1,6 +1,6 @@
1
- type Option = {
2
- label: string;
3
- value: string;
4
- };
5
- export declare function enumToOptions<T extends Record<string, string>>(enumObj: T): Option[];
6
- export {};
1
+ type Option = {
2
+ label: string;
3
+ value: string;
4
+ };
5
+ export declare function enumToOptions<T extends Record<string, string>>(enumObj: T): Option[];
6
+ export {};
@@ -1,9 +1,9 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.enumToOptions = enumToOptions;
4
- function enumToOptions(enumObj) {
5
- return Object.values(enumObj).map((value) => ({
6
- label: value, // Use the enum value for the label
7
- value: value, // Use the enum value for the value
8
- }));
9
- }
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.enumToOptions = enumToOptions;
4
+ function enumToOptions(enumObj) {
5
+ return Object.values(enumObj).map((value) => ({
6
+ label: value, // Use the enum value for the label
7
+ value: value, // Use the enum value for the value
8
+ }));
9
+ }
@@ -1,31 +1,31 @@
1
- export type VideoProvider = "youtube" | "vimeo" | "loom" | "tiktok";
2
- export interface VideoValidationResult {
3
- isValid: boolean;
4
- provider?: VideoProvider;
5
- error?: string;
6
- }
7
- /**
8
- * Unified video link validation function
9
- * @param url - The video URL to validate
10
- * @param allowedProviders - Array of allowed video providers
11
- * @returns VideoValidationResult object
12
- */
13
- export declare function validateVideoLink(url: string, allowedProviders: VideoProvider[]): VideoValidationResult;
14
- /**
15
- * Detect video provider from URL
16
- * @param url - The video URL
17
- * @returns VideoProvider or null if not detected
18
- */
19
- export declare function detectVideoProvider(url: string): VideoProvider | null;
20
- /**
21
- * Convenience function for YouTube and Vimeo only (commonly used)
22
- * @param url - The video URL to validate
23
- * @returns boolean
24
- */
25
- export declare function isValidYouTubeOrVimeoUrl(url: string): boolean;
26
- /**
27
- * Convenience function for community posts (all providers)
28
- * @param url - The video URL to validate
29
- * @returns boolean
30
- */
31
- export declare function isValidCommunityVideoUrl(url: string): boolean;
1
+ export type VideoProvider = "youtube" | "vimeo" | "loom" | "tiktok";
2
+ export interface VideoValidationResult {
3
+ isValid: boolean;
4
+ provider?: VideoProvider;
5
+ error?: string;
6
+ }
7
+ /**
8
+ * Unified video link validation function
9
+ * @param url - The video URL to validate
10
+ * @param allowedProviders - Array of allowed video providers
11
+ * @returns VideoValidationResult object
12
+ */
13
+ export declare function validateVideoLink(url: string, allowedProviders: VideoProvider[]): VideoValidationResult;
14
+ /**
15
+ * Detect video provider from URL
16
+ * @param url - The video URL
17
+ * @returns VideoProvider or null if not detected
18
+ */
19
+ export declare function detectVideoProvider(url: string): VideoProvider | null;
20
+ /**
21
+ * Convenience function for YouTube and Vimeo only (commonly used)
22
+ * @param url - The video URL to validate
23
+ * @returns boolean
24
+ */
25
+ export declare function isValidYouTubeOrVimeoUrl(url: string): boolean;
26
+ /**
27
+ * Convenience function for community posts (all providers)
28
+ * @param url - The video URL to validate
29
+ * @returns boolean
30
+ */
31
+ export declare function isValidCommunityVideoUrl(url: string): boolean;
@@ -1,119 +1,119 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.validateVideoLink = validateVideoLink;
4
- exports.detectVideoProvider = detectVideoProvider;
5
- exports.isValidYouTubeOrVimeoUrl = isValidYouTubeOrVimeoUrl;
6
- exports.isValidCommunityVideoUrl = isValidCommunityVideoUrl;
7
- /**
8
- * Unified video link validation function
9
- * @param url - The video URL to validate
10
- * @param allowedProviders - Array of allowed video providers
11
- * @returns VideoValidationResult object
12
- */
13
- function validateVideoLink(url, allowedProviders) {
14
- if (!url || url.trim() === "") {
15
- return { isValid: true }; // Empty URL is valid (optional field)
16
- }
17
- const trimmedUrl = url.trim();
18
- // Validate URL format
19
- if (!isValidURL(trimmedUrl)) {
20
- return { isValid: false, error: "Invalid URL format" };
21
- }
22
- const provider = detectVideoProvider(trimmedUrl);
23
- if (!provider) {
24
- return {
25
- isValid: false,
26
- error: `Unsupported video provider. Supported: ${allowedProviders.join(", ")}`,
27
- };
28
- }
29
- if (!allowedProviders.includes(provider)) {
30
- return {
31
- isValid: false,
32
- error: `${provider} is not allowed. Supported: ${allowedProviders.join(", ")}`,
33
- };
34
- }
35
- return { isValid: true, provider };
36
- }
37
- /**
38
- * Detect video provider from URL
39
- * @param url - The video URL
40
- * @returns VideoProvider or null if not detected
41
- */
42
- function detectVideoProvider(url) {
43
- const normalizedUrl = url.toLowerCase();
44
- // YouTube detection
45
- if (normalizedUrl.includes("youtube.com") ||
46
- normalizedUrl.includes("youtu.be")) {
47
- const youtubeRegex = /^(https?:\/\/)?(www\.)?(youtube\.com|youtu\.be)\/.+/;
48
- if (youtubeRegex.test(url)) {
49
- return "youtube";
50
- }
51
- }
52
- // Vimeo detection
53
- if (normalizedUrl.includes("vimeo.com")) {
54
- const vimeoRegex = /^(https?:\/\/)?(www\.)?(vimeo\.com)\/.+/;
55
- if (vimeoRegex.test(url)) {
56
- return "vimeo";
57
- }
58
- }
59
- // Loom detection
60
- if (normalizedUrl.includes("loom.com")) {
61
- const loomRegex = /^(https?:\/\/)?(www\.)?(loom\.com)\/share\/([a-zA-Z0-9]+)(\S+)?$/;
62
- if (loomRegex.test(url)) {
63
- return "loom";
64
- }
65
- }
66
- // TikTok detection
67
- if (normalizedUrl.includes("tiktok.com")) {
68
- const tiktokRegex1 = /^(https?:\/\/)?(www\.)?(tiktok\.com)\/@([a-zA-Z0-9_.]+)\/video\/([0-9]+)(\S+)?$/;
69
- const tiktokRegex2 = /^(https?:\/\/)?(vm\.)?(tiktok\.com)\/([a-zA-Z0-9]+)(\S+)?$/;
70
- if (tiktokRegex1.test(url) || tiktokRegex2.test(url)) {
71
- return "tiktok";
72
- }
73
- }
74
- return null;
75
- }
76
- /**
77
- * Basic URL validation
78
- * @param url - The URL to validate
79
- * @returns boolean
80
- */
81
- function isValidURL(url) {
82
- try {
83
- new URL(url);
84
- return true;
85
- }
86
- catch {
87
- // Try with protocol prefix
88
- try {
89
- new URL(`https://${url}`);
90
- return true;
91
- }
92
- catch {
93
- return false;
94
- }
95
- }
96
- }
97
- /**
98
- * Convenience function for YouTube and Vimeo only (commonly used)
99
- * @param url - The video URL to validate
100
- * @returns boolean
101
- */
102
- function isValidYouTubeOrVimeoUrl(url) {
103
- const result = validateVideoLink(url, ["youtube", "vimeo"]);
104
- return result.isValid;
105
- }
106
- /**
107
- * Convenience function for community posts (all providers)
108
- * @param url - The video URL to validate
109
- * @returns boolean
110
- */
111
- function isValidCommunityVideoUrl(url) {
112
- const result = validateVideoLink(url, [
113
- "youtube",
114
- "vimeo",
115
- "loom",
116
- "tiktok",
117
- ]);
118
- return result.isValid;
119
- }
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.validateVideoLink = validateVideoLink;
4
+ exports.detectVideoProvider = detectVideoProvider;
5
+ exports.isValidYouTubeOrVimeoUrl = isValidYouTubeOrVimeoUrl;
6
+ exports.isValidCommunityVideoUrl = isValidCommunityVideoUrl;
7
+ /**
8
+ * Unified video link validation function
9
+ * @param url - The video URL to validate
10
+ * @param allowedProviders - Array of allowed video providers
11
+ * @returns VideoValidationResult object
12
+ */
13
+ function validateVideoLink(url, allowedProviders) {
14
+ if (!url || url.trim() === "") {
15
+ return { isValid: true }; // Empty URL is valid (optional field)
16
+ }
17
+ const trimmedUrl = url.trim();
18
+ // Validate URL format
19
+ if (!isValidURL(trimmedUrl)) {
20
+ return { isValid: false, error: "Invalid URL format" };
21
+ }
22
+ const provider = detectVideoProvider(trimmedUrl);
23
+ if (!provider) {
24
+ return {
25
+ isValid: false,
26
+ error: `Unsupported video provider. Supported: ${allowedProviders.join(", ")}`,
27
+ };
28
+ }
29
+ if (!allowedProviders.includes(provider)) {
30
+ return {
31
+ isValid: false,
32
+ error: `${provider} is not allowed. Supported: ${allowedProviders.join(", ")}`,
33
+ };
34
+ }
35
+ return { isValid: true, provider };
36
+ }
37
+ /**
38
+ * Detect video provider from URL
39
+ * @param url - The video URL
40
+ * @returns VideoProvider or null if not detected
41
+ */
42
+ function detectVideoProvider(url) {
43
+ const normalizedUrl = url.toLowerCase();
44
+ // YouTube detection
45
+ if (normalizedUrl.includes("youtube.com") ||
46
+ normalizedUrl.includes("youtu.be")) {
47
+ const youtubeRegex = /^(https?:\/\/)?(www\.)?(youtube\.com|youtu\.be)\/.+/;
48
+ if (youtubeRegex.test(url)) {
49
+ return "youtube";
50
+ }
51
+ }
52
+ // Vimeo detection
53
+ if (normalizedUrl.includes("vimeo.com")) {
54
+ const vimeoRegex = /^(https?:\/\/)?(www\.)?(vimeo\.com)\/.+/;
55
+ if (vimeoRegex.test(url)) {
56
+ return "vimeo";
57
+ }
58
+ }
59
+ // Loom detection
60
+ if (normalizedUrl.includes("loom.com")) {
61
+ const loomRegex = /^(https?:\/\/)?(www\.)?(loom\.com)\/share\/([a-zA-Z0-9]+)(\S+)?$/;
62
+ if (loomRegex.test(url)) {
63
+ return "loom";
64
+ }
65
+ }
66
+ // TikTok detection
67
+ if (normalizedUrl.includes("tiktok.com")) {
68
+ const tiktokRegex1 = /^(https?:\/\/)?(www\.)?(tiktok\.com)\/@([a-zA-Z0-9_.]+)\/video\/([0-9]+)(\S+)?$/;
69
+ const tiktokRegex2 = /^(https?:\/\/)?(vm\.)?(tiktok\.com)\/([a-zA-Z0-9]+)(\S+)?$/;
70
+ if (tiktokRegex1.test(url) || tiktokRegex2.test(url)) {
71
+ return "tiktok";
72
+ }
73
+ }
74
+ return null;
75
+ }
76
+ /**
77
+ * Basic URL validation
78
+ * @param url - The URL to validate
79
+ * @returns boolean
80
+ */
81
+ function isValidURL(url) {
82
+ try {
83
+ new URL(url);
84
+ return true;
85
+ }
86
+ catch {
87
+ // Try with protocol prefix
88
+ try {
89
+ new URL(`https://${url}`);
90
+ return true;
91
+ }
92
+ catch {
93
+ return false;
94
+ }
95
+ }
96
+ }
97
+ /**
98
+ * Convenience function for YouTube and Vimeo only (commonly used)
99
+ * @param url - The video URL to validate
100
+ * @returns boolean
101
+ */
102
+ function isValidYouTubeOrVimeoUrl(url) {
103
+ const result = validateVideoLink(url, ["youtube", "vimeo"]);
104
+ return result.isValid;
105
+ }
106
+ /**
107
+ * Convenience function for community posts (all providers)
108
+ * @param url - The video URL to validate
109
+ * @returns boolean
110
+ */
111
+ function isValidCommunityVideoUrl(url) {
112
+ const result = validateVideoLink(url, [
113
+ "youtube",
114
+ "vimeo",
115
+ "loom",
116
+ "tiktok",
117
+ ]);
118
+ return result.isValid;
119
+ }