@careflair/common 1.0.4 → 1.0.6

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 (47) hide show
  1. package/dist/constants/index.d.ts +78 -0
  2. package/dist/constants/index.js +102 -13
  3. package/dist/index.d.ts +8 -7
  4. package/dist/index.js +23 -19
  5. package/dist/interfaces/common-fields.input.d.ts +15 -15
  6. package/dist/interfaces/common-fields.input.js +2 -2
  7. package/dist/interfaces/common-fields.output.d.ts +26 -26
  8. package/dist/interfaces/common-fields.output.js +2 -2
  9. package/dist/interfaces/index.d.ts +0 -0
  10. package/dist/interfaces/index.js +1 -0
  11. package/dist/schemas/availabilitySchemaValidation.d.ts +56 -56
  12. package/dist/schemas/availabilitySchemaValidation.js +79 -79
  13. package/dist/schemas/businessServicesValidation.d.ts +6 -6
  14. package/dist/schemas/businessServicesValidation.js +23 -23
  15. package/dist/schemas/educationSchemas.d.ts +38 -38
  16. package/dist/schemas/educationSchemas.js +29 -29
  17. package/dist/schemas/forms.d.ts +210 -0
  18. package/dist/schemas/forms.js +192 -0
  19. package/dist/schemas/hourlyRateSchemaValidation.d.ts +36 -36
  20. package/dist/schemas/hourlyRateSchemaValidation.js +25 -25
  21. package/dist/schemas/index.d.ts +2 -6
  22. package/dist/schemas/index.js +18 -16
  23. package/dist/schemas/userValiationSchema.d.ts +30 -30
  24. package/dist/schemas/userValiationSchema.js +38 -38
  25. package/dist/schemas/validation.d.ts +33 -0
  26. package/dist/schemas/validation.js +38 -0
  27. package/dist/schemas/workHistorySchema.d.ts +33 -33
  28. package/dist/schemas/workHistorySchema.js +28 -28
  29. package/dist/utils/date.d.ts +35 -0
  30. package/dist/utils/date.js +166 -0
  31. package/dist/utils/debounce.d.ts +8 -0
  32. package/dist/utils/debounce.js +22 -0
  33. package/dist/utils/enum.d.ts +6 -0
  34. package/dist/utils/enum.js +9 -0
  35. package/dist/utils/index.d.ts +6 -0
  36. package/dist/utils/index.js +28 -0
  37. package/dist/utils/phone.d.ts +9 -0
  38. package/dist/utils/phone.js +52 -0
  39. package/dist/utils/time.d.ts +63 -0
  40. package/dist/utils/time.js +134 -0
  41. package/dist/utils/utils.d.ts +6 -6
  42. package/dist/utils/utils.js +9 -9
  43. package/dist/utils/video.d.ts +25 -0
  44. package/dist/utils/video.js +80 -0
  45. package/dist/utils/videoValidation.d.ts +31 -31
  46. package/dist/utils/videoValidation.js +119 -119
  47. package/package.json +81 -46
@@ -0,0 +1,80 @@
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
+ */
40
+ function detectVideoProvider(url) {
41
+ const trimmedUrl = url.trim().toLowerCase();
42
+ if (trimmedUrl.includes("youtube.com") || trimmedUrl.includes("youtu.be")) {
43
+ return "youtube";
44
+ }
45
+ if (trimmedUrl.includes("vimeo.com")) {
46
+ return "vimeo";
47
+ }
48
+ if (trimmedUrl.includes("loom.com")) {
49
+ return "loom";
50
+ }
51
+ if (trimmedUrl.includes("tiktok.com")) {
52
+ return "tiktok";
53
+ }
54
+ return null;
55
+ }
56
+ /**
57
+ * Check if URL is valid YouTube or Vimeo URL
58
+ */
59
+ function isValidYouTubeOrVimeoUrl(url) {
60
+ const provider = detectVideoProvider(url);
61
+ return provider === "youtube" || provider === "vimeo";
62
+ }
63
+ /**
64
+ * Check if URL is valid community video URL (YouTube, Vimeo, Loom, TikTok)
65
+ */
66
+ function isValidCommunityVideoUrl(url) {
67
+ return detectVideoProvider(url) !== null;
68
+ }
69
+ /**
70
+ * Basic URL validation
71
+ */
72
+ function isValidURL(url) {
73
+ try {
74
+ new URL(url);
75
+ return true;
76
+ }
77
+ catch {
78
+ return false;
79
+ }
80
+ }
@@ -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
+ }
package/package.json CHANGED
@@ -1,46 +1,81 @@
1
- {
2
- "name": "@careflair/common",
3
- "version": "1.0.4",
4
- "description": "Shared assets for CareFlair",
5
- "main": "dist/index.js",
6
- "types": "dist/index.d.ts",
7
- "scripts": {
8
- "build": "tsc",
9
- "prepublishOnly": "npm run build"
10
- },
11
- "devDependencies": {
12
- "typescript": "^5.7.4"
13
- },
14
- "keywords": [
15
- "pnp-zod"
16
- ],
17
- "author": "Farhan Hossain",
18
- "license": "ISC",
19
- "dependencies": {
20
- "zod": "^3.23.8"
21
- },
22
- "files": [
23
- "dist"
24
- ],
25
- "exports": {
26
- ".": "./dist/index.js",
27
- "./enums": "./dist/enums/index.js",
28
- "./enums/*": "./dist/enums/*",
29
- "./constants": "./dist/constants/index.js",
30
- "./constants/*": "./dist/constants/*",
31
- "./schemas": "./dist/schemas/index.js",
32
- "./schemas/*": "./dist/schemas/*",
33
- "./utils": "./dist/utils/index.js",
34
- "./utils/*": "./dist/utils/*",
35
- "./interfaces": "./dist/interfaces/index.js",
36
- "./interfaces/*": "./dist/interfaces/*"
37
- },
38
- "typesVersions": {
39
- "*": {
40
- "*": [
41
- "dist/*"
42
- ]
43
- }
44
- },
45
- "sideEffects": false
46
- }
1
+ {
2
+ "name": "@careflair/common",
3
+ "version": "1.0.6",
4
+ "description": "Shared assets for CareFlair",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "scripts": {
8
+ "build": "tsc",
9
+ "prepublishOnly": "npm run build"
10
+ },
11
+ "devDependencies": {
12
+ "typescript": "^5.7.4"
13
+ },
14
+ "keywords": [
15
+ "pnp-zod"
16
+ ],
17
+ "author": "Farhan Hossain",
18
+ "license": "ISC",
19
+ "dependencies": {
20
+ "zod": "^3.23.8",
21
+ "date-fns": "^4.1.0",
22
+ "libphonenumber-js": "^1.11.16"
23
+ },
24
+ "files": [
25
+ "dist"
26
+ ],
27
+ "exports": {
28
+ ".": {
29
+ "types": "./dist/index.d.ts",
30
+ "default": "./dist/index.js"
31
+ },
32
+ "./enums": {
33
+ "types": "./dist/enums/index.d.ts",
34
+ "default": "./dist/enums/index.js"
35
+ },
36
+ "./enums/*": {
37
+ "types": "./dist/enums/*.d.ts",
38
+ "default": "./dist/enums/*.js"
39
+ },
40
+ "./constants": {
41
+ "types": "./dist/constants/index.d.ts",
42
+ "default": "./dist/constants/index.js"
43
+ },
44
+ "./constants/*": {
45
+ "types": "./dist/constants/*.d.ts",
46
+ "default": "./dist/constants/*.js"
47
+ },
48
+ "./schemas": {
49
+ "types": "./dist/schemas/index.d.ts",
50
+ "default": "./dist/schemas/index.js"
51
+ },
52
+ "./schemas/*": {
53
+ "types": "./dist/schemas/*.d.ts",
54
+ "default": "./dist/schemas/*.js"
55
+ },
56
+ "./utils": {
57
+ "types": "./dist/utils/index.d.ts",
58
+ "default": "./dist/utils/index.js"
59
+ },
60
+ "./utils/*": {
61
+ "types": "./dist/utils/*.d.ts",
62
+ "default": "./dist/utils/*.js"
63
+ },
64
+ "./interfaces": {
65
+ "types": "./dist/interfaces/index.d.ts",
66
+ "default": "./dist/interfaces/index.js"
67
+ },
68
+ "./interfaces/*": {
69
+ "types": "./dist/interfaces/*.d.ts",
70
+ "default": "./dist/interfaces/*.js"
71
+ }
72
+ },
73
+ "typesVersions": {
74
+ "*": {
75
+ "*": [
76
+ "dist/*"
77
+ ]
78
+ }
79
+ },
80
+ "sideEffects": false
81
+ }