-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSkills.ts
More file actions
25 lines (22 loc) · 885 Bytes
/
Skills.ts
File metadata and controls
25 lines (22 loc) · 885 Bytes
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
import { Output, array, length, object, record, string } from 'valibot';
import ExternalResource from '../../utils/data/models/ExternalResource';
import { filterCommonEscoDataSet } from '../../utils/esco';
import { getEscoAPIEndpoint } from '../../utils/runtime';
const SkillSchema = object({
uri: string(),
prefLabel: record(string([length(2)]), string()),
});
type Skill = Output<typeof SkillSchema>;
const SkillsResponseSchema = array(SkillSchema);
type SkillsResponse = Output<typeof SkillsResponseSchema>;
export default new ExternalResource({
name: 'Skills',
uri: `${getEscoAPIEndpoint()}/skills`,
parsers: {
input: SkillsResponseSchema,
async transform(skills: SkillsResponse, params?: Record<string, string>) {
return filterCommonEscoDataSet<Skill>(skills, params);
},
output: SkillsResponseSchema,
},
});