-
Notifications
You must be signed in to change notification settings - Fork 117
Expand file tree
/
Copy pathuserCandidate.ts
More file actions
96 lines (89 loc) · 2.6 KB
/
userCandidate.ts
File metadata and controls
96 lines (89 loc) · 2.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
import {
CandidateStatus,
EmploymentType,
LocationType,
SalaryPeriod,
} from '@dailydotdev/schema';
import z from 'zod';
import { acceptedEmploymentAgreementFiles, createFileSchema } from './files';
export enum RoleType {
IC = 0.0,
Auto = 0.5,
Managerial = 1.0,
}
export const gcsBlobSchema = z.object({
blob: z.string().optional(),
fileName: z.string().optional(),
contentType: z.string().optional(),
bucket: z.string().optional(),
lastModified: z.date().optional(),
signedUrl: z.string().optional().nullable(),
});
export type UserCandidateCV = z.infer<typeof gcsBlobSchema>;
export type GCSBlob = z.infer<typeof gcsBlobSchema>;
export const salaryExpectationSchema = z.object({
min: z.coerce
.bigint()
.min(BigInt(0))
.transform((val) => val.toString())
.optional()
.nullable(),
period: z
.enum(SalaryPeriod, { error: 'Invalid salary period' })
.refine((val) => val !== SalaryPeriod.UNSPECIFIED, {
message: 'Invalid salary period',
})
.optional()
.nullable(),
});
export const candidatePreferenceSchema = z.object({
status: z
.enum(CandidateStatus, { error: 'Invalid candidate status' })
.refine((val) => val !== CandidateStatus.UNSPECIFIED, {
message: 'Invalid candidate status',
})
.optional(),
role: z.string().max(400).optional(),
roleType: z.enum(RoleType, { error: 'Invalid role type' }).optional(),
employmentType: z
.array(
z
.enum(EmploymentType, { error: 'Invalid employment type' })
.refine((val) => val !== EmploymentType.UNSPECIFIED, {
message: 'Invalid employment type',
}),
)
.optional(),
salaryExpectation: salaryExpectationSchema.optional(),
location: z
.array(
z.object({
city: z.string().optional(),
country: z.string().optional(),
}),
)
.optional(),
externalLocationId: z.preprocess(
(val) => (val === '' ? null : val),
z.string().nullish().default(null),
),
locationType: z
.array(
z
.enum(LocationType, { error: 'Invalid location type' })
.refine((val) => val !== LocationType.UNSPECIFIED, {
message: 'Invalid location type',
}),
)
.optional(),
customKeywords: z.boolean().optional(),
});
export const userCandidateToggleKeywordSchema = z.object({
keywords: z
.array(z.string().trim().min(1, 'Keyword cannot be empty'))
.min(1, 'At least one keyword is required')
.max(100, 'Too many keywords provided'),
});
export const uploadEmploymentAgreementSchema = z.object({
file: z.promise(createFileSchema(acceptedEmploymentAgreementFiles)),
});