-
Notifications
You must be signed in to change notification settings - Fork 11
/
normalizers.ts
31 lines (27 loc) · 1.11 KB
/
normalizers.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 { normalize, schema } from 'normalizr';
export default class Normalizer {
private idOption: object;
private job: schema.Entity;
private task: schema.Entity;
// tslint:disable-next-line
private provider_task: schema.Entity;
// tslint:disable-next-line
private provider_tasks: schema.Array;
private run: schema.Entity;
private runs: schema.Array;
private user: schema.Entity;
private userData: schema.Entity;
public constructor() {
this.idOption = { idAttribute: 'uid' };
// run schemas
this.job = new schema.Entity('jobs', {}, this.idOption);
this.task = new schema.Entity('tasks', {}, this.idOption);
this.provider_task = new schema.Entity('provider_tasks', { tasks: new schema.Array(this.task) }, this.idOption);
this.provider_tasks = new schema.Array(this.provider_task);
this.run = new schema.Entity('runs', { job: this.job, provider_tasks: this.provider_tasks }, this.idOption);
this.runs = new schema.Array(this.run);
}
public normalizeRun(run) {
return normalize(run, this.run);
}
}