@unedio/types 0.0.1
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.
- package/package.json +18 -0
- package/src/types/api.types.ts +423 -0
- package/src/types/database.types.ts +375 -0
- package/src/types/enums.ts +62 -0
- package/src/types/hono.types.ts +32 -0
- package/src/utils/ai.ts +70 -0
- package/src/utils/email.ts +26 -0
- package/src/utils/errors.ts +60 -0
- package/src/utils/json.ts +26 -0
- package/src/utils/pagination.ts +44 -0
- package/src/utils/storage.ts +57 -0
- package/src/utils/stripe.ts +240 -0
- package/src/validators/application.validator.ts +61 -0
- package/src/validators/candidate.validator.ts +52 -0
- package/src/validators/client.validator.ts +29 -0
- package/src/validators/common.validator.ts +16 -0
- package/src/validators/contact.validator.ts +29 -0
- package/src/validators/email-template.validator.ts +28 -0
- package/src/validators/job.validator.ts +61 -0
- package/src/validators/parse-cv.validator.ts +28 -0
- package/src/validators/saved-candidate.validator.ts +27 -0
- package/src/validators/seeker.validator.ts +29 -0
- package/src/validators/subscription.validator.ts +21 -0
- package/src/validators/user.validator.ts +86 -0
- package/src/validators/waitlist.validator.ts +8 -0
- package/src/validators/workspace.validator.ts +93 -0
- package/tsconfig.json +14 -0
package/package.json
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@unedio/types",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"main": "src/index.ts",
|
|
5
|
+
"dependencies": {
|
|
6
|
+
"@hono/zod-openapi": "^1.2.0",
|
|
7
|
+
"@supabase/supabase-js": "^2.89.0",
|
|
8
|
+
"@google/generative-ai": "^0.24.1",
|
|
9
|
+
"jose": "^6.1.3",
|
|
10
|
+
"zod": "^3.24.1"
|
|
11
|
+
},
|
|
12
|
+
"devDependencies": {
|
|
13
|
+
"typescript": "~5.9.2"
|
|
14
|
+
},
|
|
15
|
+
"publishConfig": {
|
|
16
|
+
"access": "public"
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,423 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* API Request and Response types
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { BillingPlanDetails } from '../utils/stripe';
|
|
6
|
+
|
|
7
|
+
import {
|
|
8
|
+
ApplicationStatus,
|
|
9
|
+
Client,
|
|
10
|
+
Contact,
|
|
11
|
+
EmailTemplate,
|
|
12
|
+
Job,
|
|
13
|
+
JobApplication,
|
|
14
|
+
JobApplicationComment,
|
|
15
|
+
JobApplicationHistory,
|
|
16
|
+
Note,
|
|
17
|
+
Plan,
|
|
18
|
+
SavedCandidate,
|
|
19
|
+
SeekerProfile,
|
|
20
|
+
Subscription,
|
|
21
|
+
User,
|
|
22
|
+
Workspace,
|
|
23
|
+
WorkspaceBranding,
|
|
24
|
+
} from './database.types';
|
|
25
|
+
|
|
26
|
+
export type { Contact } from './database.types';
|
|
27
|
+
|
|
28
|
+
import {
|
|
29
|
+
EmailTemplateType,
|
|
30
|
+
ErrorCode,
|
|
31
|
+
JobStatus,
|
|
32
|
+
JobType,
|
|
33
|
+
UserType,
|
|
34
|
+
WorkModality,
|
|
35
|
+
WorkspaceUserRole,
|
|
36
|
+
} from './enums';
|
|
37
|
+
|
|
38
|
+
// ============================================================================
|
|
39
|
+
// COMMON TYPES
|
|
40
|
+
// ============================================================================
|
|
41
|
+
|
|
42
|
+
export interface PaginationParams {
|
|
43
|
+
page?: number;
|
|
44
|
+
limit?: number;
|
|
45
|
+
search?: string;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export interface PaginationMeta {
|
|
49
|
+
page: number;
|
|
50
|
+
limit: number;
|
|
51
|
+
total: number;
|
|
52
|
+
totalPages: number;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export interface ApiResponse<T> {
|
|
56
|
+
data: T;
|
|
57
|
+
meta?: PaginationMeta;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export interface ApiError {
|
|
61
|
+
message: string;
|
|
62
|
+
code: ErrorCode | string;
|
|
63
|
+
details: any;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// ============================================================================
|
|
67
|
+
// AUTH
|
|
68
|
+
// ============================================================================
|
|
69
|
+
|
|
70
|
+
export interface LoginRequest {
|
|
71
|
+
email: string;
|
|
72
|
+
password: string;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export interface RegisterRequest {
|
|
76
|
+
email: string;
|
|
77
|
+
password: string;
|
|
78
|
+
name: string;
|
|
79
|
+
type: UserType;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export interface AuthResponse {
|
|
83
|
+
user: User;
|
|
84
|
+
session: {
|
|
85
|
+
access_token: string;
|
|
86
|
+
refresh_token: string;
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// ============================================================================
|
|
91
|
+
// USERS
|
|
92
|
+
// ============================================================================
|
|
93
|
+
|
|
94
|
+
export interface UpdateUserRequest {
|
|
95
|
+
name?: string;
|
|
96
|
+
avatarUrl?: string;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// Basic user info for public profiles/lists
|
|
100
|
+
export type PublicUserResponse = Pick<User, 'id' | 'email' | 'name' | 'avatar_url'>;
|
|
101
|
+
|
|
102
|
+
export type UserResponse = Omit<User, 'external_id'>;
|
|
103
|
+
|
|
104
|
+
export type AuthUserResponse = UserResponse & {
|
|
105
|
+
workspace?: (WorkspaceResponse & { role: WorkspaceUserRole }) | null;
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
// ============================================================================
|
|
109
|
+
// SEEKER PROFILES
|
|
110
|
+
// ============================================================================
|
|
111
|
+
|
|
112
|
+
export interface UpdateSeekerProfileRequest {
|
|
113
|
+
fullName?: string;
|
|
114
|
+
phone?: string;
|
|
115
|
+
linkedinUrl?: string;
|
|
116
|
+
city?: string;
|
|
117
|
+
country?: string;
|
|
118
|
+
summary?: string;
|
|
119
|
+
skills?: string[];
|
|
120
|
+
experienceYears?: number;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
export interface SearchSeekersRequest extends PaginationParams {
|
|
124
|
+
skills?: string[];
|
|
125
|
+
city?: string;
|
|
126
|
+
country?: string;
|
|
127
|
+
minExperience?: number;
|
|
128
|
+
maxExperience?: number;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
export type SeekerProfileResponse = Omit<SeekerProfile, 'last_placed_at_client_id'> & {
|
|
132
|
+
user: PublicUserResponse;
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
// ============================================================================
|
|
136
|
+
// WORKSPACES
|
|
137
|
+
// ============================================================================
|
|
138
|
+
|
|
139
|
+
export interface CreateWorkspaceRequest {
|
|
140
|
+
name: string;
|
|
141
|
+
domain?: string;
|
|
142
|
+
subdomain?: string;
|
|
143
|
+
workspaceMode?: 'company' | 'agency';
|
|
144
|
+
language: string;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
export interface UpdateWorkspaceRequest {
|
|
148
|
+
name?: string;
|
|
149
|
+
domain?: string;
|
|
150
|
+
customDomainStatus?: string;
|
|
151
|
+
workspaceMode?: 'company' | 'agency';
|
|
152
|
+
language?: string;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
export interface InviteUserRequest {
|
|
156
|
+
email: string;
|
|
157
|
+
role: WorkspaceUserRole;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
export type WorkspaceResponse = Workspace & {
|
|
161
|
+
branding?: BrandingResponse;
|
|
162
|
+
subscription?: Subscription;
|
|
163
|
+
membersCount?: number;
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
export interface ClientResponse extends Client {
|
|
167
|
+
contacts?: ContactResponse[];
|
|
168
|
+
notes?: NoteResponse[];
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
export type ContactResponse = Contact;
|
|
172
|
+
|
|
173
|
+
export interface WorkspaceMemberResponse {
|
|
174
|
+
id: string;
|
|
175
|
+
user: PublicUserResponse;
|
|
176
|
+
role: WorkspaceUserRole;
|
|
177
|
+
created_at: string;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
// ============================================================================
|
|
181
|
+
// WORKSPACE BRANDING
|
|
182
|
+
// ============================================================================
|
|
183
|
+
|
|
184
|
+
export interface UpdateBrandingRequest {
|
|
185
|
+
primaryColor?: string;
|
|
186
|
+
secondaryColor?: string;
|
|
187
|
+
fontFamily?: string;
|
|
188
|
+
logoUrl?: string;
|
|
189
|
+
faviconUrl?: string;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
export type BrandingResponse = Omit<WorkspaceBranding, 'workspace_id'>;
|
|
193
|
+
|
|
194
|
+
// ============================================================================
|
|
195
|
+
// JOBS
|
|
196
|
+
// ============================================================================
|
|
197
|
+
|
|
198
|
+
export interface CreateJobRequest {
|
|
199
|
+
title: string;
|
|
200
|
+
description: string;
|
|
201
|
+
workModality?: WorkModality;
|
|
202
|
+
jobType?: JobType;
|
|
203
|
+
location?: string;
|
|
204
|
+
salaryRange?: string;
|
|
205
|
+
status?: JobStatus;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
export interface UpdateJobRequest {
|
|
209
|
+
title?: string;
|
|
210
|
+
description?: string;
|
|
211
|
+
workModality?: WorkModality;
|
|
212
|
+
jobType?: JobType;
|
|
213
|
+
location?: string;
|
|
214
|
+
salaryRange?: string;
|
|
215
|
+
status?: JobStatus;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
export interface ListJobsRequest extends PaginationParams {
|
|
219
|
+
status?: JobStatus;
|
|
220
|
+
workModality?: WorkModality;
|
|
221
|
+
jobType?: JobType;
|
|
222
|
+
search?: string;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
export type JobResponse = Job & {
|
|
226
|
+
workspace: Pick<Workspace, 'id' | 'name' | 'subdomain'>;
|
|
227
|
+
recruiter?: PublicUserResponse;
|
|
228
|
+
client?: Pick<Client, 'id' | 'name'>;
|
|
229
|
+
contact?: Pick<Contact, 'id' | 'full_name' | 'email'>;
|
|
230
|
+
applicationsCount?: number;
|
|
231
|
+
viewsCount?: number;
|
|
232
|
+
};
|
|
233
|
+
|
|
234
|
+
export interface JobStatsResponse {
|
|
235
|
+
total_views: number;
|
|
236
|
+
total_applications: number;
|
|
237
|
+
views_by_source: Record<string, number>;
|
|
238
|
+
applications_by_source: Record<string, number>;
|
|
239
|
+
applications_by_status: Record<string, number>;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
// ============================================================================
|
|
243
|
+
// APPLICATIONS
|
|
244
|
+
// ============================================================================
|
|
245
|
+
|
|
246
|
+
export interface CreateApplicationRequest {
|
|
247
|
+
jobId: string;
|
|
248
|
+
source?: string;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
export interface UpdateApplicationRequest {
|
|
252
|
+
statusId?: string;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
export interface ListApplicationsRequest extends PaginationParams {
|
|
256
|
+
jobId?: string;
|
|
257
|
+
statusId?: string;
|
|
258
|
+
search?: string;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
export type ApplicationResponse = JobApplication & {
|
|
262
|
+
job: Pick<Job, 'id' | 'title'>;
|
|
263
|
+
seeker: SeekerProfileResponse;
|
|
264
|
+
status?: ApplicationStatus;
|
|
265
|
+
commentsCount?: number;
|
|
266
|
+
};
|
|
267
|
+
|
|
268
|
+
// ============================================================================
|
|
269
|
+
// APPLICATION STATUSES
|
|
270
|
+
// ============================================================================
|
|
271
|
+
|
|
272
|
+
export interface CreateStatusRequest {
|
|
273
|
+
statusName: string;
|
|
274
|
+
order?: number;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
export interface UpdateStatusRequest {
|
|
278
|
+
statusName?: string;
|
|
279
|
+
order?: number;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
export interface ReorderStatusesRequest {
|
|
283
|
+
statuses: { id: string; order: number }[];
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
export type StatusResponse = ApplicationStatus;
|
|
287
|
+
|
|
288
|
+
// ============================================================================
|
|
289
|
+
// COMMENTS
|
|
290
|
+
// ============================================================================
|
|
291
|
+
|
|
292
|
+
export interface CreateCommentRequest {
|
|
293
|
+
commentText: string;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
export type CommentResponse = Omit<JobApplicationComment, 'job_application_id' | 'user_id'> & {
|
|
297
|
+
user: PublicUserResponse;
|
|
298
|
+
};
|
|
299
|
+
|
|
300
|
+
// ============================================================================
|
|
301
|
+
// HISTORY
|
|
302
|
+
// ============================================================================
|
|
303
|
+
|
|
304
|
+
export type HistoryResponse = Omit<JobApplicationHistory, 'job_application_id' | 'actor_id'> & {
|
|
305
|
+
actor?: Pick<User, 'id' | 'name' | 'email'>;
|
|
306
|
+
};
|
|
307
|
+
|
|
308
|
+
// ============================================================================
|
|
309
|
+
// NOTES
|
|
310
|
+
// ============================================================================
|
|
311
|
+
|
|
312
|
+
export interface CreateNoteRequest {
|
|
313
|
+
content: string;
|
|
314
|
+
seekerId?: string;
|
|
315
|
+
jobId?: string;
|
|
316
|
+
clientId?: string;
|
|
317
|
+
contactId?: string;
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
export type NoteResponse = Note & {
|
|
321
|
+
author?: PublicUserResponse;
|
|
322
|
+
};
|
|
323
|
+
|
|
324
|
+
// ============================================================================
|
|
325
|
+
// EMAIL TEMPLATES
|
|
326
|
+
// ============================================================================
|
|
327
|
+
|
|
328
|
+
export interface CreateTemplateRequest {
|
|
329
|
+
name: string;
|
|
330
|
+
subject: string;
|
|
331
|
+
bodyText: string;
|
|
332
|
+
type: EmailTemplateType;
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
export interface UpdateTemplateRequest {
|
|
336
|
+
name?: string;
|
|
337
|
+
subject?: string;
|
|
338
|
+
bodyText?: string;
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
export interface SendEmailRequest {
|
|
342
|
+
to: string;
|
|
343
|
+
variables?: Record<string, string>;
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
export type TemplateResponse = EmailTemplate;
|
|
347
|
+
|
|
348
|
+
// ============================================================================
|
|
349
|
+
// SAVED CANDIDATES
|
|
350
|
+
// ============================================================================
|
|
351
|
+
|
|
352
|
+
export interface SaveCandidateRequest {
|
|
353
|
+
seekerId: string;
|
|
354
|
+
notes?: string;
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
export interface UpdateSavedCandidateRequest {
|
|
358
|
+
notes?: string;
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
export type SavedCandidateResponse = Omit<SavedCandidate, 'added_by'> & {
|
|
362
|
+
seeker: SeekerProfileResponse;
|
|
363
|
+
added_by_user?: PublicUserResponse;
|
|
364
|
+
};
|
|
365
|
+
|
|
366
|
+
// ============================================================================
|
|
367
|
+
// SUBSCRIPTIONS & PLANS
|
|
368
|
+
// ============================================================================
|
|
369
|
+
|
|
370
|
+
export interface CreateSubscriptionRequest {
|
|
371
|
+
planId: string;
|
|
372
|
+
paymentMethodId?: string;
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
export type PlanResponse = BillingPlanDetails;
|
|
376
|
+
|
|
377
|
+
export type SubscriptionResponse = Subscription & {
|
|
378
|
+
plan: Plan | null;
|
|
379
|
+
};
|
|
380
|
+
|
|
381
|
+
export interface WorkspaceAccessState {
|
|
382
|
+
read_only: boolean;
|
|
383
|
+
public_portal_active: boolean;
|
|
384
|
+
billing_required: boolean;
|
|
385
|
+
trial_ends_at: string | null;
|
|
386
|
+
subscription_status: Subscription['status'] | 'none';
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
export interface WorkspaceSubscriptionResponse {
|
|
390
|
+
subscription: Subscription | null;
|
|
391
|
+
limits: {
|
|
392
|
+
max_jobs: number;
|
|
393
|
+
max_applications_per_job: number;
|
|
394
|
+
};
|
|
395
|
+
plan_details: BillingPlanDetails | null;
|
|
396
|
+
access: WorkspaceAccessState;
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
export interface WorkspaceUsageResponse {
|
|
400
|
+
limits: {
|
|
401
|
+
max_jobs: number;
|
|
402
|
+
max_applications_per_job: number;
|
|
403
|
+
};
|
|
404
|
+
usage: {
|
|
405
|
+
jobs: number;
|
|
406
|
+
};
|
|
407
|
+
canCreateJob: boolean;
|
|
408
|
+
access: WorkspaceAccessState;
|
|
409
|
+
plan_details: BillingPlanDetails | null;
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
// ============================================================================
|
|
413
|
+
// WAITLIST
|
|
414
|
+
// ============================================================================
|
|
415
|
+
|
|
416
|
+
export interface WaitlistRequest {
|
|
417
|
+
email: string;
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
export interface WaitlistResponse {
|
|
421
|
+
email: string;
|
|
422
|
+
created_at: string;
|
|
423
|
+
}
|