recruter/src/sources.ts
2026-11-14 21:45:11 +05:00

29 lines
968 B
TypeScript

export interface Resume {
url: string;
fullName: string;
phone?: string;
email?: string;
city?: string;
channel?: "whatsapp" | "telegram";
}
/** Контракт адаптера площадки: поиск резюме по тексту одного требования. */
export interface SourceAdapter {
readonly name: string;
search(requirement: string): Promise<Resume[]>;
}
/** Мок площадки: отдаёт заранее заданные резюме по подстроке требования; может «падать». */
export class MockSourceAdapter implements SourceAdapter {
constructor(
readonly name: string,
private readonly data: Record<string, Resume[]> = {},
private readonly failing = false,
) {}
async search(requirement: string): Promise<Resume[]> {
if (this.failing) throw new Error(`${this.name}: площадка недоступна`);
return this.data[requirement] ?? [];
}
}