@careflair/common 1.0.25 → 1.0.27

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.
@@ -125,42 +125,48 @@ export declare const ContactDetailsFormSchema: z.ZodObject<{
125
125
  /**
126
126
  * Education and training form schema
127
127
  */
128
- export declare const EducationAndTrainingFormSchema: z.ZodObject<{
129
- type: z.ZodObject<{
130
- label: z.ZodString;
131
- value: z.ZodString;
132
- }, "strip", z.ZodTypeAny, {
133
- value: string;
134
- label: string;
135
- }, {
136
- value: string;
137
- label: string;
138
- }>;
128
+ export declare const EducationAndTrainingFormSchema: z.ZodEffects<z.ZodEffects<z.ZodObject<{
129
+ type: z.ZodString;
139
130
  school: z.ZodString;
140
131
  degree: z.ZodString;
141
132
  startDate: z.ZodDate;
142
- endDate: z.ZodNullable<z.ZodOptional<z.ZodDate>>;
143
- isCurrentlyStudying: z.ZodOptional<z.ZodUnion<[z.ZodBoolean, z.ZodLiteral<false>]>>;
133
+ endDate: z.ZodDate;
144
134
  }, "strip", z.ZodTypeAny, {
145
- type: {
146
- value: string;
147
- label: string;
148
- };
135
+ type: string;
149
136
  school: string;
150
137
  degree: string;
151
138
  startDate: Date;
152
- endDate?: Date | null | undefined;
153
- isCurrentlyStudying?: boolean | undefined;
139
+ endDate: Date;
154
140
  }, {
155
- type: {
156
- value: string;
157
- label: string;
158
- };
141
+ type: string;
142
+ school: string;
143
+ degree: string;
144
+ startDate: Date;
145
+ endDate: Date;
146
+ }>, {
147
+ type: string;
148
+ school: string;
149
+ degree: string;
150
+ startDate: Date;
151
+ endDate: Date;
152
+ }, {
153
+ type: string;
154
+ school: string;
155
+ degree: string;
156
+ startDate: Date;
157
+ endDate: Date;
158
+ }>, {
159
+ type: string;
160
+ school: string;
161
+ degree: string;
162
+ startDate: Date;
163
+ endDate: Date;
164
+ }, {
165
+ type: string;
159
166
  school: string;
160
167
  degree: string;
161
168
  startDate: Date;
162
- endDate?: Date | null | undefined;
163
- isCurrentlyStudying?: boolean | undefined;
169
+ endDate: Date;
164
170
  }>;
165
171
  /**
166
172
  * Work history form schema
@@ -169,42 +175,35 @@ export declare const WorkHistoryFormSchema: z.ZodEffects<z.ZodEffects<z.ZodObjec
169
175
  jobTitle: z.ZodString;
170
176
  organisation: z.ZodString;
171
177
  startDate: z.ZodEffects<z.ZodString, string, string>;
172
- endDate: z.ZodEffects<z.ZodOptional<z.ZodString>, string | undefined, string | undefined>;
173
- isCurrentlyWorking: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
178
+ endDate: z.ZodString;
174
179
  }, "strip", z.ZodTypeAny, {
175
180
  startDate: string;
181
+ endDate: string;
176
182
  jobTitle: string;
177
183
  organisation: string;
178
- endDate?: string | undefined;
179
- isCurrentlyWorking?: boolean | undefined;
180
184
  }, {
181
185
  startDate: string;
186
+ endDate: string;
182
187
  jobTitle: string;
183
188
  organisation: string;
184
- endDate?: string | undefined;
185
- isCurrentlyWorking?: boolean | undefined;
186
189
  }>, {
187
190
  startDate: string;
191
+ endDate: string;
188
192
  jobTitle: string;
189
193
  organisation: string;
190
- endDate?: string | undefined;
191
- isCurrentlyWorking?: boolean | undefined;
192
194
  }, {
193
195
  startDate: string;
196
+ endDate: string;
194
197
  jobTitle: string;
195
198
  organisation: string;
196
- endDate?: string | undefined;
197
- isCurrentlyWorking?: boolean | undefined;
198
199
  }>, {
199
200
  startDate: string;
201
+ endDate: string;
200
202
  jobTitle: string;
201
203
  organisation: string;
202
- endDate?: string | undefined;
203
- isCurrentlyWorking?: boolean | undefined;
204
204
  }, {
205
205
  startDate: string;
206
+ endDate: string;
206
207
  jobTitle: string;
207
208
  organisation: string;
208
- endDate?: string | undefined;
209
- isCurrentlyWorking?: boolean | undefined;
210
209
  }>;
@@ -96,11 +96,9 @@ exports.ContactDetailsFormSchema = zod_1.z.object({
96
96
  /**
97
97
  * Education and training form schema
98
98
  */
99
- exports.EducationAndTrainingFormSchema = zod_1.z.object({
100
- type: zod_1.z.object({
101
- label: zod_1.z.string(),
102
- value: zod_1.z.string(),
103
- }),
99
+ exports.EducationAndTrainingFormSchema = zod_1.z
100
+ .object({
101
+ type: zod_1.z.string().min(1, "Type is required"),
104
102
  school: zod_1.z
105
103
  .string()
106
104
  .min(1, "School/Instituation is required")
@@ -112,8 +110,25 @@ exports.EducationAndTrainingFormSchema = zod_1.z.object({
112
110
  startDate: zod_1.z.date({
113
111
  required_error: "Start date is required",
114
112
  }),
115
- endDate: zod_1.z.date().optional().nullable(),
116
- isCurrentlyStudying: zod_1.z.boolean().or(zod_1.z.literal(false)).optional(),
113
+ endDate: zod_1.z.date({
114
+ required_error: "End date is required",
115
+ }),
116
+ })
117
+ .refine((data) => {
118
+ // Check if end date is after start date
119
+ return data.endDate > data.startDate;
120
+ }, {
121
+ message: "End date must be after start date",
122
+ path: ["endDate"],
123
+ })
124
+ .refine((data) => {
125
+ // Check if there's at least 1 month difference
126
+ const diffInMonths = (data.endDate.getFullYear() - data.startDate.getFullYear()) * 12 +
127
+ (data.endDate.getMonth() - data.startDate.getMonth());
128
+ return diffInMonths >= 1;
129
+ }, {
130
+ message: "There must be at least 1 month between start and end date",
131
+ path: ["endDate"],
117
132
  });
118
133
  // Helper function to check if date is in the future
119
134
  const isDateInFuture = (date) => {
@@ -150,18 +165,9 @@ exports.WorkHistoryFormSchema = zod_1.z
150
165
  .refine((date) => !isDateInFuture(date), {
151
166
  message: "Start date cannot be in the future",
152
167
  }),
153
- endDate: zod_1.z
154
- .string()
155
- .optional()
156
- .refine((date) => !date || !isDateInFuture(date), {
157
- message: "End date cannot be in the future",
158
- }),
159
- isCurrentlyWorking: zod_1.z.boolean().default(false).optional(),
168
+ endDate: zod_1.z.string().min(1, "End date is required"),
160
169
  })
161
170
  .refine((data) => {
162
- // Skip validation if currently working or no end date
163
- if (data.isCurrentlyWorking || !data.endDate)
164
- return true;
165
171
  // Check if end date is after start date
166
172
  const startDate = new Date(data.startDate);
167
173
  const endDate = new Date(data.endDate);
@@ -171,9 +177,6 @@ exports.WorkHistoryFormSchema = zod_1.z
171
177
  path: ["endDate"],
172
178
  })
173
179
  .refine((data) => {
174
- // Skip validation if currently working or no end date
175
- if (data.isCurrentlyWorking || !data.endDate)
176
- return true;
177
180
  // Check if there's at least 1 month difference
178
181
  return isAtLeastOneMonthDifference(data.startDate, data.endDate);
179
182
  }, {
@@ -10,7 +10,7 @@ export interface VideoValidationResult {
10
10
  export declare function validateVideoLink(url: string, allowedProviders: VideoProvider[]): VideoValidationResult;
11
11
  /**
12
12
  * Extract YouTube video ID from various URL formats
13
- * Handles: youtube.com, m.youtube.com, youtu.be, /embed, /v, etc.
13
+ * Handles: youtube.com, m.youtube.com, youtu.be, /embed, /v, /shorts, etc.
14
14
  */
15
15
  export declare function extractYouTubeVideoId(url: string): string | null;
16
16
  /**
@@ -30,7 +30,7 @@ function validateVideoLink(url, allowedProviders) {
30
30
  }
31
31
  /**
32
32
  * Extract YouTube video ID from various URL formats
33
- * Handles: youtube.com, m.youtube.com, youtu.be, /embed, /v, etc.
33
+ * Handles: youtube.com, m.youtube.com, youtu.be, /embed, /v, /shorts, etc.
34
34
  */
35
35
  function extractYouTubeVideoId(url) {
36
36
  if (!url)
@@ -38,22 +38,27 @@ function extractYouTubeVideoId(url) {
38
38
  const trimmed = url.trim();
39
39
  let videoId = null;
40
40
  // Handle youtu.be/VIDEO_ID
41
- if (trimmed.includes('youtu.be/')) {
41
+ if (trimmed.includes("youtu.be/")) {
42
42
  const match = trimmed.match(/youtu\.be\/([a-zA-Z0-9_-]{11})/);
43
43
  videoId = match ? match[1] : null;
44
44
  }
45
45
  // Handle youtube.com/watch?v=VIDEO_ID (works for www, m, etc.)
46
- else if (trimmed.includes('youtube.com/watch')) {
46
+ else if (trimmed.includes("youtube.com/watch")) {
47
47
  const match = trimmed.match(/[?&]v=([a-zA-Z0-9_-]{11})/);
48
48
  videoId = match ? match[1] : null;
49
49
  }
50
+ // Handle youtube.com/shorts/VIDEO_ID
51
+ else if (trimmed.includes("youtube.com/shorts/")) {
52
+ const match = trimmed.match(/\/shorts\/([a-zA-Z0-9_-]{11})/);
53
+ videoId = match ? match[1] : null;
54
+ }
50
55
  // Handle youtube.com/embed/VIDEO_ID
51
- else if (trimmed.includes('youtube.com/embed/')) {
56
+ else if (trimmed.includes("youtube.com/embed/")) {
52
57
  const match = trimmed.match(/\/embed\/([a-zA-Z0-9_-]{11})/);
53
58
  videoId = match ? match[1] : null;
54
59
  }
55
60
  // Handle youtube.com/v/VIDEO_ID
56
- else if (trimmed.includes('youtube.com/v/')) {
61
+ else if (trimmed.includes("youtube.com/v/")) {
57
62
  const match = trimmed.match(/\/v\/([a-zA-Z0-9_-]{11})/);
58
63
  videoId = match ? match[1] : null;
59
64
  }
@@ -73,7 +78,8 @@ function detectVideoProvider(url) {
73
78
  if (!url)
74
79
  return null;
75
80
  const lower = url.toLowerCase();
76
- if ((lower.includes("youtube.com") || lower.includes("youtu.be")) && extractYouTubeVideoId(url)) {
81
+ if ((lower.includes("youtube.com") || lower.includes("youtu.be")) &&
82
+ extractYouTubeVideoId(url)) {
77
83
  return "youtube";
78
84
  }
79
85
  if (lower.includes("vimeo.com"))
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@careflair/common",
3
- "version": "1.0.25",
3
+ "version": "1.0.27",
4
4
  "description": "Shared assets for CareFlair",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",