@zyacreatives/shared 2.1.11 → 2.1.13

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.
@@ -322,7 +322,7 @@ export declare const JobWithRoleDetailsEntitySchema: z.ZodObject<{
322
322
  "Project Based": "Project Based";
323
323
  }>>;
324
324
  }, z.core.$strip>;
325
- export declare const CreateJobInputSchema: z.ZodObject<{
325
+ export declare const CreateJobInputSchema: z.ZodPipe<z.ZodObject<{
326
326
  title: z.ZodString;
327
327
  brandId: z.ZodCUID2;
328
328
  jobType: z.ZodEnum<{
@@ -361,7 +361,25 @@ export declare const CreateJobInputSchema: z.ZodObject<{
361
361
  jobSections: z.ZodArray<z.ZodEnum<{
362
362
  [x: string]: string;
363
363
  }>>;
364
- }, z.core.$strip>;
364
+ }, z.core.$strip>, z.ZodTransform<{
365
+ title: string;
366
+ brandId: string;
367
+ jobType: "GIG" | "ROLE";
368
+ workMode: "Remote" | "Hybrid" | "On Site";
369
+ location: "Africa" | "Asia" | "Europe" | "North America" | "South America" | "Middle East" | "Oceania" | "Global" | "Other" | "Remote" | "EMEA" | "Asia Pacific";
370
+ jobSections: string[];
371
+ employmentType?: "Full Time" | "Part Time" | "Freelance" | "Internship" | undefined;
372
+ gigType?: "One Time" | "Recurring" | undefined;
373
+ }, {
374
+ title: string;
375
+ brandId: string;
376
+ jobType: "GIG" | "ROLE";
377
+ workMode: "Remote" | "Hybrid" | "On Site";
378
+ location: "Africa" | "Asia" | "Europe" | "North America" | "South America" | "Middle East" | "Oceania" | "Global" | "Other" | "Remote" | "EMEA" | "Asia Pacific";
379
+ jobSections: string[];
380
+ employmentType?: "Full Time" | "Part Time" | "Freelance" | "Internship" | undefined;
381
+ gigType?: "One Time" | "Recurring" | undefined;
382
+ }>>;
365
383
  export declare const CreateRoleJobInputSchema: z.ZodObject<{
366
384
  id: z.ZodCUID2;
367
385
  experienceLevel: z.ZodEnum<{
@@ -24,6 +24,7 @@ exports.BaseJobEntitySchema = zod_1.z.object({
24
24
  constants_1.JOB_SECTIONS.PERSONAL_INFORMATION,
25
25
  constants_1.JOB_SECTIONS.PROFESSIONAL_INFORMATION,
26
26
  constants_1.JOB_SECTIONS.RESUME,
27
+ constants_1.JOB_SECTIONS.COVER_LETTER,
27
28
  ]),
28
29
  createdAt: zod_1.z.date(),
29
30
  updatedAt: zod_1.z.date(),
@@ -53,6 +54,7 @@ exports.JobEntitySchema = zod_1.z.object({
53
54
  constants_1.JOB_SECTIONS.PERSONAL_INFORMATION,
54
55
  constants_1.JOB_SECTIONS.PROFESSIONAL_INFORMATION,
55
56
  constants_1.JOB_SECTIONS.RESUME,
57
+ constants_1.JOB_SECTIONS.COVER_LETTER,
56
58
  ]),
57
59
  createdAt: zod_1.z.date(),
58
60
  updatedAt: zod_1.z.date(),
@@ -94,8 +96,7 @@ exports.RoleJobEntitySchema = zod_1.z.object({
94
96
  .optional(),
95
97
  });
96
98
  exports.JobWithRoleDetailsEntitySchema = exports.JobEntitySchema.extend(exports.RoleJobEntitySchema.shape);
97
- exports.CreateJobInputSchema = zod_1.z
98
- .object({
99
+ const CreateJobInputBaseSchema = zod_1.z.object({
99
100
  title: zod_1.z.string(),
100
101
  brandId: zod_1.z.cuid2(),
101
102
  jobType: zod_1.z.enum(Object.values(constants_1.JOB_TYPE)),
@@ -111,45 +112,31 @@ exports.CreateJobInputSchema = zod_1.z
111
112
  .default(constants_1.JOB_LOCATIONS.REMOTE),
112
113
  jobSections: zod_1.z
113
114
  .array(JobSectionEnum)
114
- .refine((sections) => sections.includes(constants_1.JOB_SECTIONS.PERSONAL_INFORMATION) &&
115
- sections.includes(constants_1.JOB_SECTIONS.PROFESSIONAL_INFORMATION) &&
116
- sections.includes(constants_1.JOB_SECTIONS.RESUME), {
117
- message: "jobSections must always include PERSONAL_INFORMATION, PROFESSIONAL_INFORMATION, and RESUME",
118
- }),
119
- })
120
- .superRefine((data, ctx) => {
115
+ .min(1, { message: "At least one job section must be provided." }),
116
+ });
117
+ exports.CreateJobInputSchema = CreateJobInputBaseSchema.superRefine((data, ctx) => {
118
+ if (data.jobType === constants_1.JOB_TYPE.ROLE && !data.employmentType) {
119
+ ctx.addIssue({
120
+ path: ["employmentType"],
121
+ code: "custom",
122
+ message: "employmentType is required for ROLE jobs",
123
+ });
124
+ }
125
+ if (data.jobType === constants_1.JOB_TYPE.GIG && !data.gigType) {
126
+ ctx.addIssue({
127
+ path: ["gigType"],
128
+ code: "custom",
129
+ message: "gigType is required for GIG jobs",
130
+ });
131
+ }
132
+ }).transform((data) => {
121
133
  if (data.jobType === constants_1.JOB_TYPE.ROLE) {
122
- if (data.gigType !== undefined) {
123
- ctx.addIssue({
124
- path: ["gigType"],
125
- code: "custom",
126
- message: "gigType must be null/undefined for PROJECT jobs",
127
- });
128
- }
129
- if (!data.employmentType) {
130
- ctx.addIssue({
131
- path: ["employmentType"],
132
- code: "custom",
133
- message: "employmentType is required for PROJECT jobs",
134
- });
135
- }
134
+ return { ...data, gigType: undefined };
136
135
  }
137
136
  if (data.jobType === constants_1.JOB_TYPE.GIG) {
138
- if (!data.gigType) {
139
- ctx.addIssue({
140
- path: ["gigType"],
141
- code: "custom",
142
- message: "gigType is required for GIG jobs",
143
- });
144
- }
145
- if (data.employmentType !== undefined) {
146
- ctx.addIssue({
147
- path: ["employmentType"],
148
- code: "custom",
149
- message: "employmentType must be null/undefined for GIG jobs",
150
- });
151
- }
137
+ return { ...data, employmentType: undefined };
152
138
  }
139
+ return data;
153
140
  });
154
141
  exports.CreateRoleJobInputSchema = zod_1.z
155
142
  .object({
@@ -196,7 +183,7 @@ exports.CreateGigJobInputSchema = zod_1.z
196
183
  });
197
184
  exports.UpdateRoleJobInputSchema = exports.CreateRoleJobInputSchema.partial().required({ id: true });
198
185
  exports.UpdateGigJobInputSchema = exports.CreateGigJobInputSchema.partial().required({ id: true });
199
- exports.UpdateJobInputSchema = exports.CreateJobInputSchema.partial().extend({
186
+ exports.UpdateJobInputSchema = CreateJobInputBaseSchema.partial().extend({
200
187
  id: zod_1.z.cuid2(),
201
188
  status: zod_1.z
202
189
  .enum(Object.values(constants_1.JOB_STATUS))
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zyacreatives/shared",
3
- "version": "2.1.11",
3
+ "version": "2.1.13",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -1,4 +1,4 @@
1
- import { optional, z } from "zod";
1
+ import { z } from "zod";
2
2
  import {
3
3
  EMPLOYMENT_TYPE,
4
4
  EmploymentType,
@@ -6,12 +6,10 @@ import {
6
6
  ExperienceLevel,
7
7
  GIG_TYPE,
8
8
  GigType,
9
- JOB_AVAILABILITY_TYPES,
10
9
  JOB_LOCATIONS,
11
10
  JOB_SECTIONS,
12
11
  JOB_STATUS,
13
12
  JOB_TYPE,
14
- JobAvailabilityTypes,
15
13
  JobLocation,
16
14
  JobStatus,
17
15
  JobType,
@@ -51,6 +49,7 @@ export const BaseJobEntitySchema = z.object({
51
49
  JOB_SECTIONS.PERSONAL_INFORMATION,
52
50
  JOB_SECTIONS.PROFESSIONAL_INFORMATION,
53
51
  JOB_SECTIONS.RESUME,
52
+ JOB_SECTIONS.COVER_LETTER,
54
53
  ]),
55
54
  createdAt: z.date(),
56
55
  updatedAt: z.date(),
@@ -86,6 +85,7 @@ export const JobEntitySchema = z.object({
86
85
  JOB_SECTIONS.PERSONAL_INFORMATION,
87
86
  JOB_SECTIONS.PROFESSIONAL_INFORMATION,
88
87
  JOB_SECTIONS.RESUME,
88
+ JOB_SECTIONS.COVER_LETTER,
89
89
  ]),
90
90
  createdAt: z.date(),
91
91
 
@@ -139,71 +139,61 @@ export const JobWithRoleDetailsEntitySchema = JobEntitySchema.extend(
139
139
  RoleJobEntitySchema.shape
140
140
  );
141
141
 
142
- export const CreateJobInputSchema = z
143
- .object({
144
- title: z.string(),
145
- brandId: z.cuid2(),
146
- jobType: z.enum(Object.values(JOB_TYPE) as [JobType, ...JobType[]]),
147
- employmentType: z
148
- .enum(
149
- Object.values(EMPLOYMENT_TYPE) as [EmploymentType, ...EmploymentType[]]
150
- )
151
- .optional(),
152
- workMode: z.enum(Object.values(WORK_MODE) as [WorkMode, ...WorkMode[]]),
153
- gigType: z
154
- .enum(Object.values(GIG_TYPE) as [GigType, ...GigType[]])
155
- .optional(),
156
- location: z
157
- .enum(Object.values(JOB_LOCATIONS) as [JobLocation, ...JobLocation[]])
158
- .default(JOB_LOCATIONS.REMOTE),
159
- jobSections: z
160
- .array(JobSectionEnum)
161
- .refine(
162
- (sections) =>
163
- sections.includes(JOB_SECTIONS.PERSONAL_INFORMATION) &&
164
- sections.includes(JOB_SECTIONS.PROFESSIONAL_INFORMATION) &&
165
- sections.includes(JOB_SECTIONS.RESUME),
166
- {
167
- message:
168
- "jobSections must always include PERSONAL_INFORMATION, PROFESSIONAL_INFORMATION, and RESUME",
169
- }
170
- ),
171
- })
172
- .superRefine((data, ctx) => {
173
- if (data.jobType === JOB_TYPE.ROLE) {
174
- if (data.gigType !== undefined) {
175
- ctx.addIssue({
176
- path: ["gigType"],
177
- code: "custom",
178
- message: "gigType must be null/undefined for PROJECT jobs",
179
- });
180
- }
181
- if (!data.employmentType) {
182
- ctx.addIssue({
183
- path: ["employmentType"],
184
- code: "custom",
185
- message: "employmentType is required for PROJECT jobs",
186
- });
187
- }
142
+ const CreateJobInputBaseSchema = z.object({
143
+ title: z.string(),
144
+ brandId: z.cuid2(),
145
+ jobType: z.enum(Object.values(JOB_TYPE) as [JobType, ...JobType[]]),
146
+
147
+ employmentType: z
148
+ .enum(
149
+ Object.values(EMPLOYMENT_TYPE) as [EmploymentType, ...EmploymentType[]]
150
+ )
151
+ .optional(),
152
+
153
+ workMode: z.enum(Object.values(WORK_MODE) as [WorkMode, ...WorkMode[]]),
154
+
155
+ gigType: z
156
+ .enum(Object.values(GIG_TYPE) as [GigType, ...GigType[]])
157
+ .optional(),
158
+
159
+ location: z
160
+ .enum(Object.values(JOB_LOCATIONS) as [JobLocation, ...JobLocation[]])
161
+ .default(JOB_LOCATIONS.REMOTE),
162
+
163
+ jobSections: z
164
+ .array(JobSectionEnum)
165
+ .min(1, { message: "At least one job section must be provided." }),
166
+ });
167
+
168
+ export const CreateJobInputSchema = CreateJobInputBaseSchema.superRefine(
169
+ (data, ctx) => {
170
+ if (data.jobType === JOB_TYPE.ROLE && !data.employmentType) {
171
+ ctx.addIssue({
172
+ path: ["employmentType"],
173
+ code: "custom",
174
+ message: "employmentType is required for ROLE jobs",
175
+ });
188
176
  }
189
177
 
190
- if (data.jobType === JOB_TYPE.GIG) {
191
- if (!data.gigType) {
192
- ctx.addIssue({
193
- path: ["gigType"],
194
- code: "custom",
195
- message: "gigType is required for GIG jobs",
196
- });
197
- }
198
- if (data.employmentType !== undefined) {
199
- ctx.addIssue({
200
- path: ["employmentType"],
201
- code: "custom",
202
- message: "employmentType must be null/undefined for GIG jobs",
203
- });
204
- }
178
+ if (data.jobType === JOB_TYPE.GIG && !data.gigType) {
179
+ ctx.addIssue({
180
+ path: ["gigType"],
181
+ code: "custom",
182
+ message: "gigType is required for GIG jobs",
183
+ });
205
184
  }
206
- });
185
+ }
186
+ ).transform((data) => {
187
+ if (data.jobType === JOB_TYPE.ROLE) {
188
+ return { ...data, gigType: undefined };
189
+ }
190
+
191
+ if (data.jobType === JOB_TYPE.GIG) {
192
+ return { ...data, employmentType: undefined };
193
+ }
194
+
195
+ return data;
196
+ });
207
197
 
208
198
  export const CreateRoleJobInputSchema = z
209
199
  .object({
@@ -273,7 +263,7 @@ export const UpdateRoleJobInputSchema =
273
263
  export const UpdateGigJobInputSchema =
274
264
  CreateGigJobInputSchema.partial().required({ id: true });
275
265
 
276
- export const UpdateJobInputSchema = CreateJobInputSchema.partial().extend({
266
+ export const UpdateJobInputSchema = CreateJobInputBaseSchema.partial().extend({
277
267
  id: z.cuid2(),
278
268
  status: z
279
269
  .enum(Object.values(JOB_STATUS) as [JobStatus, ...JobStatus[]])