@internwave/scrapers-api
Version:
A helper API for web scrapers in the InternWave desktop application
229 lines (200 loc) • 6.93 kB
text/typescript
interface ILocation {
country?: string;
city?: string;
region?: string;
state?: string;
address?: string;
type?: string;
postalCode?: string;
}
interface IDates {
postedAt?: number;
deadlineAt?: number;
startAt?: number;
endAt?: number;
duration?: string[];
}
interface ICompany {
name: string;
url?: string;
}
interface ICategorizations {
technologies?: string[];
skills?: string[];
industries?: string[];
applicationDocuments?: string[];
specialRequirements?: string[];
compensationAndBenefits?: string[];
}
declare enum ChartType {
PIE = 0
}
interface IChartData {
title: string;
data: {
[key: string]: number;
};
type: ChartType;
}
interface IChartDataWithKey extends IChartData {
key: string;
}
type ICharts = {
[key: string]: IChartData;
};
interface IDescription {
title: string;
content: string;
type: string;
}
interface IScrapedSalary {
amount: string;
currency?: string;
period?: string;
}
interface IScrapedJobSalaries {
salary?: IScrapedSalary;
salaryMin?: IScrapedSalary;
salaryMax?: IScrapedSalary;
coop1Salary?: IScrapedSalary;
coop2Salary?: IScrapedSalary;
coop3Salary?: IScrapedSalary;
coop4Salary?: IScrapedSalary;
coop5Salary?: IScrapedSalary;
coop6Salary?: IScrapedSalary;
coop7PlusSalary?: IScrapedSalary;
}
interface ILink {
url: string;
title?: string;
}
interface IScrapedJob {
id: string;
url?: string;
jobType?: string[];
company: ICompany;
jobTitle: string;
openings?: number;
location?: ILocation;
dates?: IDates;
applications?: number;
links?: ILink[];
status?: string;
categorizations?: ICategorizations;
descriptions?: IDescription[];
charts?: ICharts;
salaries?: IScrapedJobSalaries;
}
interface ICheckboxScraperInput extends IScraperInput {
type: ScraperInputType.CHECKBOX;
initialValue?: boolean;
}
interface IPasswordScraperInput extends IScraperInput {
type: ScraperInputType.PASSWORD;
}
interface ISelectScraperInput extends IScraperInput {
type: ScraperInputType.SELECT;
selectOptions: string[];
}
interface ITextScraperInput extends IScraperInput {
type: ScraperInputType.TEXT;
}
declare enum ScraperInputType {
SELECT = "Select",
TEXT = "Text",
PASSWORD = "Password",
CHECKBOX = "Checkbox"
}
interface IScraperInput {
label: string;
type: ScraperInputType;
required?: boolean;
}
type ScraperInput = ITextScraperInput | IPasswordScraperInput | ISelectScraperInput | ICheckboxScraperInput;
interface IProgressReporter {
nextStep(message: string, workUnits: number): void;
reportProgress(message: string, percentage: number): void;
requestAction(message: string, percentage?: number): void;
requestInput(inputs: ScraperInput[], message?: string): Promise<string[]>;
}
declare class ProgressReporter implements IProgressReporter {
private _totalSteps;
private _currentStep;
private _workReporter;
constructor(_totalSteps: number);
nextStep(message: string, workUnits: number, initWorkUnits?: number): void;
reportProgress(message?: string): void;
requestAction(message: string): void;
requestInput(inputs: ScraperInput[], message?: string): Promise<string[]>;
}
declare const onStartScraping: (totalSteps: number) => (callback: (args: string[], progressReporter: ProgressReporter) => Promise<IScrapedJob[]>) => void;
declare enum MessageType {
START_SCRAPING = "START_SCRAPING",
REPORT_SCRAPING_ERROR = "REPORT_SCRAPING_ERROR",
REPORT_SCRAPING_ACTION_REQUEST = "REPORT_SCRAPING_ACTION_REQUEST",
REPORT_SCRAPING_PROGRESS = "REPORT_SCRAPING_PROGRESS",
SEND_REPORT_SCRAPING_INPUT_REQUEST = "REPORT_SCRAPING_INPUT_REQUEST",
RCV_REPORT_SCRAPING_INPUT_REQUEST = "RCV_REPORT_SCRAPING_INPUT_REQUEST",
DONE_SCRAPING = "DONE_SCRAPING"
}
interface IMessage<T> {
type: MessageType;
payload: T;
}
interface IDoneScrapingPayload {
jobs: IScrapedJob[];
}
interface IDoneScrapingMessage extends IMessage<IDoneScrapingPayload> {
type: MessageType.DONE_SCRAPING;
}
interface IReportScrapingActionRequestPayload {
message: string;
percentage?: number;
currentStep?: number;
}
interface IReportScrapingActionRequestMessage extends IMessage<IReportScrapingActionRequestPayload> {
type: MessageType.REPORT_SCRAPING_ACTION_REQUEST;
}
interface IReportScrapingErrorPayload {
message: string;
}
interface IReportScrapingErrorMessage extends IMessage<IReportScrapingErrorPayload> {
type: MessageType.REPORT_SCRAPING_ERROR;
}
interface IReportScrapingProgressMessagePayload {
message: string;
percentage: number;
totalSteps: number;
currentStep: number;
}
interface IReportScrapingProgressMessage extends IMessage<IReportScrapingProgressMessagePayload> {
type: MessageType.REPORT_SCRAPING_PROGRESS;
}
interface IRcvReportScrapingInputRequestPayload {
percentage?: number;
inputs: ScraperInput[];
currentStep?: number;
message?: string;
}
interface IRcvReportScrapingInputRequestMessage extends IMessage<IRcvReportScrapingInputRequestPayload> {
type: MessageType.RCV_REPORT_SCRAPING_INPUT_REQUEST;
}
type ReportingScrapingMessage = IReportScrapingErrorMessage | IReportScrapingActionRequestMessage | IReportScrapingProgressMessage | IDoneScrapingMessage | IRcvReportScrapingInputRequestMessage;
declare const getRandomJob: (index: number) => IScrapedJob;
interface ISendReportScrapingInputRequestPayload {
values: string[];
}
interface ISendReportScrapingInputRequestMessage extends IMessage<ISendReportScrapingInputRequestPayload> {
type: MessageType.SEND_REPORT_SCRAPING_INPUT_REQUEST;
}
interface IStartScrapingPayload {
optionValues: string[];
}
interface IStartScrapingMessage extends IMessage<IStartScrapingPayload> {
type: MessageType.START_SCRAPING;
}
type SendScrapingMessage = ISendReportScrapingInputRequestMessage;
declare const API: {
onStartScraping: (totalSteps: number) => (callback: (args: string[], progressReporter: ProgressReporter) => Promise<IScrapedJob[]>) => void;
};
export { API, ChartType, type ICategorizations, type IChartData, type IChartDataWithKey, type ICharts, type ICompany, type IDates, type IDescription, type IDoneScrapingMessage, type IDoneScrapingPayload, type ILocation, type IMessage, type IPasswordScraperInput, type IProgressReporter, type IRcvReportScrapingInputRequestMessage, type IScrapedJob, type IScrapedJobSalaries, type IScrapedSalary, type IScraperInput, type ISelectScraperInput, type ISendReportScrapingInputRequestMessage, type IStartScrapingMessage, type IStartScrapingPayload, type ITextScraperInput, MessageType, ProgressReporter, type ReportingScrapingMessage, type ScraperInput, ScraperInputType, type SendScrapingMessage, getRandomJob, onStartScraping };