-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Job.ts
31 lines (26 loc) · 884 Bytes
/
Job.ts
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
import { getJobDebugInfo, listJobsFor } from './generated/AirbyteApi';
import {
JobDebugInfoRead,
JobListRequestBody,
JobRead,
} from './generated/AirbyteApi.schemas';
import { ConnectionModel } from './models/ConnectionModel';
import { JobModel } from './models/JobModel';
export class Job {
connection: ConnectionModel;
constructor(connection: ConnectionModel) {
this.connection = connection;
}
async getAllJobs(jobListRequestBody: JobListRequestBody) {
const allJobs = await listJobsFor(jobListRequestBody);
const getDebugJobs = await Promise.all(
allJobs.jobs.map(
async (job) => await getJobDebugInfo({ id: (job.job as JobRead).id }),
),
);
return Job.createJobInstances(getDebugJobs);
}
static createJobInstances(jobs: Array<JobDebugInfoRead>) {
return jobs.map((job) => JobModel.createJobInstance(job));
}
}