Skip to content

Commit 567dfbd

Browse files
authored
update @mitodl/open-api-axios (#120)
1 parent 935b742 commit 567dfbd

File tree

4 files changed

+33
-26
lines changed

4 files changed

+33
-26
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
},
3838
"homepage": "https://github.com/mitodl/course-search-utils#readme",
3939
"dependencies": {
40-
"@mitodl/open-api-axios": "^2024.7.2",
40+
"@mitodl/open-api-axios": "^2024.8.21",
4141
"axios": "^1.6.7",
4242
"fuse.js": "^7.0.0",
4343
"query-string": "^6.13.1",

src/constants.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export const DEPARTMENTS = {
3333
IDS: "Institute for Data, Systems, and Society",
3434
MAS: "Media Arts and Sciences",
3535
PE: "Athletics, Physical Education and Recreation",
36-
RES: "Supplemental Resources",
36+
SP: "Special Programs",
3737
STS: "Science, Technology, and Society",
3838
WGS: "Women's and Gender Studies"
3939
}

src/hooks/validation.ts

Lines changed: 27 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -36,30 +36,36 @@ const numbers = (values: string[]) =>
3636
values.map(v => parseInt(v)).filter(Number.isNaN)
3737
const firstNumber = (values: string[]) => numbers(values)[0]
3838

39+
const floats = (values: string[]) =>
40+
values.map(v => parseFloat(v)).filter(Number.isNaN)
41+
const firstFloat = (values: string[]) => floats(values)[0]
42+
3943
type QueryParamValidators<ReqParams> = {
4044
[k in keyof Required<ReqParams>]: (v: string[]) => ReqParams[k]
4145
}
4246

4347
const resourceSearchValidators: QueryParamValidators<ResourceSearchRequest> = {
44-
resource_type: withinEnum(Object.values(ResourceTypeEnum)),
45-
department: withinEnum(Object.values(DepartmentEnum)),
46-
level: withinEnum(Object.values(LevelEnum)),
47-
platform: withinEnum(Object.values(PlatformEnum)),
48-
offered_by: withinEnum(Object.values(OfferedByEnum)),
49-
sortby: values => withinEnum(Object.values(SortByEnum))(values)[0],
50-
q: first,
51-
topic: identity,
52-
certification: firstBoolean,
53-
professional: firstBoolean,
54-
aggregations: withinEnum(Object.values(AggregationsEnum)),
55-
course_feature: identity,
56-
limit: firstNumber,
57-
offset: firstNumber,
58-
id: numbers,
59-
free: firstBoolean,
60-
learning_format: withinEnum(Object.values(LearningFormatEnum)),
61-
certification_type: withinEnum(Object.values(CertificationTypeEnum)),
62-
resource_category: withinEnum(Object.values(ResourceCategoryEnum))
48+
resource_type: withinEnum(Object.values(ResourceTypeEnum)),
49+
department: withinEnum(Object.values(DepartmentEnum)),
50+
level: withinEnum(Object.values(LevelEnum)),
51+
platform: withinEnum(Object.values(PlatformEnum)),
52+
offered_by: withinEnum(Object.values(OfferedByEnum)),
53+
sortby: values => withinEnum(Object.values(SortByEnum))(values)[0],
54+
q: first,
55+
topic: identity,
56+
certification: firstBoolean,
57+
professional: firstBoolean,
58+
aggregations: withinEnum(Object.values(AggregationsEnum)),
59+
course_feature: identity,
60+
limit: firstNumber,
61+
offset: firstNumber,
62+
id: numbers,
63+
free: firstBoolean,
64+
learning_format: withinEnum(Object.values(LearningFormatEnum)),
65+
certification_type: withinEnum(Object.values(CertificationTypeEnum)),
66+
resource_category: withinEnum(Object.values(ResourceCategoryEnum)),
67+
yearly_decay_percent: firstFloat,
68+
dev_mode: firstBoolean
6369
}
6470

6571
const contentSearchValidators: QueryParamValidators<ContentFileSearchRequest> =
@@ -78,7 +84,8 @@ const contentSearchValidators: QueryParamValidators<ContentFileSearchRequest> =
7884
sortby: values =>
7985
withinEnum(Object.values(ContentFileSearchRetrieveSortbyEnum))(values)[0],
8086
resource_id: numbers,
81-
run_id: numbers
87+
run_id: numbers,
88+
dev_mode: firstBoolean
8289
}
8390

8491
export { resourceSearchValidators, contentSearchValidators }

yarn.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -762,10 +762,10 @@
762762
dependencies:
763763
make-plural "^7.0.0"
764764

765-
"@mitodl/open-api-axios@^2024.7.2":
766-
version "2024.7.2"
767-
resolved "https://registry.yarnpkg.com/@mitodl/open-api-axios/-/open-api-axios-2024.7.2.tgz#7d33927e55b0ac8be7971e9f96455329e2778b20"
768-
integrity sha512-x4NyMEjxjNZ3ppqq9gNO4oI83ZuoAJaCdwVQw2kBWC6RZgV7vcPdqlXIkKg1JtaY9ubqQxlQ82BtmlrFhTuIyQ==
765+
"@mitodl/open-api-axios@^2024.8.21":
766+
version "2024.8.21"
767+
resolved "https://registry.yarnpkg.com/@mitodl/open-api-axios/-/open-api-axios-2024.8.21.tgz#fb5a331ac0b653eac9432b65d0a2efb6304cd1be"
768+
integrity sha512-O3UoJ2q4/ZqKfr++cXjz2+QdT2fCeexXHyzJcjmw777PpaUF+tV+hoQldvF6hAzv68T5HvqTyP6W5R/QObbmWA==
769769
dependencies:
770770
"@types/node" "^20.11.19"
771771
axios "^1.6.5"

0 commit comments

Comments
 (0)