-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOccupationsFlatURL.ts
More file actions
40 lines (37 loc) · 1.4 KB
/
OccupationsFlatURL.ts
File metadata and controls
40 lines (37 loc) · 1.4 KB
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
32
33
34
35
36
37
38
39
40
import { Output, array, length, object, optional, record, string } from 'valibot';
import ExternalZipResource from '../../utils/data/models/ExternalZipResource';
const IscoInputSchema = array(object({
uri: string(),
notation: optional(string()),
prefLabel: record(string([length(2)]), string()),
}));
type IscoInput = Output<typeof IscoInputSchema>;
const IscoOutputSchema = array(object({
uri: string(),
notation: string(),
prefLabel: record(string([length(2)]), string()),
}));
export default new ExternalZipResource({
name: 'OccupationsFlatURL',
uri: 'https://tyomarkkinatori.fi/dam/jcr:42efb1fc-93f3-4146-a46f-71c2f9f5eb9b/occupations.json.zip',
mime: 'application/json; charset=utf-8',
parsers: {
input: IscoInputSchema,
async transform(occupationsRaw: IscoInput) {
return occupationsRaw
.filter((occupation) => Boolean(occupation.notation))
.map((occupation) => {
return {
uri: occupation.uri,
notation: occupation.notation,
prefLabel: {
fi: occupation.prefLabel.fi,
sv: occupation.prefLabel.sv,
en: occupation.prefLabel.en,
},
};
});
},
output: IscoOutputSchema,
}
});