W3: add v2 API types and client functions (cv import, postings fetch, batch scoring, today, interview prep, telemetry, demo seed)
This commit is contained in:
parent
9ee5449acb
commit
115fea39f2
2 changed files with 153 additions and 2 deletions
|
|
@ -6,13 +6,21 @@ import type {
|
|||
Application,
|
||||
Approval,
|
||||
Artifact,
|
||||
BatchScoringResponse,
|
||||
CoverLetterResponse,
|
||||
CritiqueComment,
|
||||
CvImportConfirmResponse,
|
||||
CvImportResponse,
|
||||
CvSection,
|
||||
DemoSeedResponse,
|
||||
InterviewPrepResponse,
|
||||
JobPosting,
|
||||
PostingsFetchResponse,
|
||||
Profile,
|
||||
RenderCvResponse,
|
||||
ScoreResponse
|
||||
ScoreResponse,
|
||||
TaskRun,
|
||||
TodayResponse
|
||||
} from '@/types'
|
||||
|
||||
const API_BASE: string =
|
||||
|
|
@ -154,17 +162,77 @@ export function outboxSend(approvalId: string, payload: Record<string, unknown>)
|
|||
})
|
||||
}
|
||||
|
||||
// --- Telemetry ---
|
||||
|
||||
export function getTelemetryTasks(): Promise<TaskRun[]> {
|
||||
return request<TaskRun[]>('/telemetry/tasks')
|
||||
}
|
||||
|
||||
// --- v1.0 additions (api-contract-v2.md) ---
|
||||
|
||||
export function importCv(filename: string, contentBase64: string): Promise<CvImportResponse> {
|
||||
return request<CvImportResponse>('/cv/import', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ filename, content_base64: contentBase64 })
|
||||
})
|
||||
}
|
||||
|
||||
export function confirmCvImport(drafts: CvImportResponse['drafts']): Promise<CvImportConfirmResponse> {
|
||||
return request<CvImportConfirmResponse>('/cv/import/confirm', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ drafts })
|
||||
})
|
||||
}
|
||||
|
||||
export function fetchPostings(query: string, region?: string): Promise<PostingsFetchResponse> {
|
||||
const body: Record<string, string> = { query }
|
||||
if (region) body.region = region
|
||||
return request<PostingsFetchResponse>('/postings/fetch', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(body)
|
||||
})
|
||||
}
|
||||
|
||||
export function batchScore(applicationIds: string[]): Promise<BatchScoringResponse> {
|
||||
return request<BatchScoringResponse>('/scoring/batch', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ application_ids: applicationIds })
|
||||
})
|
||||
}
|
||||
|
||||
export function getToday(): Promise<TodayResponse> {
|
||||
return request<TodayResponse>('/today')
|
||||
}
|
||||
|
||||
export function interviewPrep(applicationId: string): Promise<InterviewPrepResponse> {
|
||||
return request<InterviewPrepResponse>(`/applications/${applicationId}/interview-prep`, {
|
||||
method: 'POST'
|
||||
})
|
||||
}
|
||||
|
||||
export function seedDemo(): Promise<DemoSeedResponse> {
|
||||
return request<DemoSeedResponse>('/concierge/seed-demo', { method: 'POST' })
|
||||
}
|
||||
|
||||
// Re-export types for convenience
|
||||
export type {
|
||||
AiAssistResponse,
|
||||
Application,
|
||||
Approval,
|
||||
Artifact,
|
||||
BatchScoringResponse,
|
||||
CoverLetterResponse,
|
||||
CritiqueComment,
|
||||
CvImportConfirmResponse,
|
||||
CvImportResponse,
|
||||
CvSection,
|
||||
DemoSeedResponse,
|
||||
InterviewPrepResponse,
|
||||
JobPosting,
|
||||
PostingsFetchResponse,
|
||||
Profile,
|
||||
RenderCvResponse,
|
||||
ScoreResponse
|
||||
ScoreResponse,
|
||||
TaskRun,
|
||||
TodayResponse
|
||||
}
|
||||
|
|
@ -125,4 +125,87 @@ export interface AiAssistResponse {
|
|||
|
||||
export interface ApiError {
|
||||
error: { code: string; message: string }
|
||||
}
|
||||
|
||||
// --- v1.0 additions (api-contract-v2.md) ---
|
||||
|
||||
export interface CvDraft {
|
||||
kind: CvSectionKind
|
||||
title: string
|
||||
org: string
|
||||
location: string
|
||||
start_date: string
|
||||
end_date: string | null
|
||||
bullets: string[]
|
||||
tags: string[]
|
||||
}
|
||||
|
||||
export interface CvImportResponse {
|
||||
drafts: CvDraft[]
|
||||
}
|
||||
|
||||
export interface CvImportConfirmResponse {
|
||||
created: number
|
||||
sections: CvSection[]
|
||||
}
|
||||
|
||||
export interface PostingsFetchResponse {
|
||||
new: number
|
||||
dupes: number
|
||||
}
|
||||
|
||||
export interface BatchScoringResult {
|
||||
application_id: string
|
||||
score: number
|
||||
rationale: Record<string, unknown>
|
||||
red_flags: string[]
|
||||
}
|
||||
|
||||
export interface BatchScoringResponse {
|
||||
results: BatchScoringResult[]
|
||||
}
|
||||
|
||||
export interface TodayDigestItem {
|
||||
application_id: string
|
||||
title: string
|
||||
company: string
|
||||
score: number
|
||||
}
|
||||
|
||||
export interface TodayNudge {
|
||||
application_id: string
|
||||
days_since_sent: number
|
||||
suggestion: string
|
||||
}
|
||||
|
||||
export interface TodayResponse {
|
||||
digest: TodayDigestItem[]
|
||||
nudges: TodayNudge[]
|
||||
pending_approvals: number
|
||||
}
|
||||
|
||||
export interface InterviewPrepResponse {
|
||||
artifact_id: string
|
||||
content: string
|
||||
}
|
||||
|
||||
export interface DemoSeedResponse {
|
||||
profile: string
|
||||
postings: number
|
||||
applications: number
|
||||
sections: number
|
||||
}
|
||||
|
||||
export interface TaskRun {
|
||||
id: string
|
||||
task_type: string
|
||||
model: string
|
||||
tokens_in: number
|
||||
tokens_out: number
|
||||
cost: number | null
|
||||
created_at: string
|
||||
}
|
||||
|
||||
export interface RedFlagsMap {
|
||||
[applicationId: string]: string[]
|
||||
}
|
||||
Loading…
Reference in a new issue