Skip to content

Commit a776265

Browse files
authored
Bump scraper deps (#3125)
1 parent 1f85a7e commit a776265

File tree

7 files changed

+1003
-1065
lines changed

7 files changed

+1003
-1065
lines changed

scrapers/nus-v2/package.json

Lines changed: 26 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -17,52 +17,50 @@
1717
"test:watch": "jest --watch"
1818
},
1919
"devDependencies": {
20-
"@types/bunyan": "1.8.5",
20+
"@types/bunyan": "1.8.6",
2121
"@types/deep-diff": "1.0.0",
22-
"@types/fs-extra": "5.0.5",
23-
"@types/jest": "23.3.13",
24-
"@types/joi": "14.3.1",
22+
"@types/fs-extra": "9.0.6",
2523
"@types/lodash": "4.14.167",
26-
"@types/mock-fs": "4.10.0",
27-
"@types/oboe": "2.0.28",
24+
"@types/mock-fs": "4.13.0",
25+
"@types/node": "14.14.19",
26+
"@types/oboe": "2.0.29",
2827
"@types/promise-queue": "2.2.0",
29-
"@types/ramda": "0.25.50",
30-
"@types/yargs": "12.0.9",
31-
"@types/node": "12.12.6",
32-
"@typescript-eslint/eslint-plugin": "3.10.1",
33-
"@typescript-eslint/parser": "3.10.1",
34-
"eslint": "7.16.0",
28+
"@types/ramda": "0.27.34",
29+
"@types/yargs": "15.0.12",
30+
"@typescript-eslint/eslint-plugin": "4.11.1",
31+
"@typescript-eslint/parser": "4.11.1",
32+
"eslint": "7.17.0",
3533
"eslint-config-airbnb-base": "14.2.1",
36-
"eslint-config-prettier": "6.15.0",
34+
"eslint-config-prettier": "7.1.0",
3735
"eslint-plugin-import": "2.22.1",
3836
"eslint-plugin-prettier": "3.3.0",
39-
"http-status": "1.3.1",
37+
"http-status": "1.5.0",
4038
"jest": "26.6.3",
41-
"jest-junit": "11.0.1",
39+
"jest-junit": "12.0.0",
4240
"mock-fs": "4.13.0",
43-
"prettier": "2.0.5",
41+
"prettier": "2.2.1",
4442
"swagger-ui-dist": "3.38.0",
45-
"ts-jest": "26.1.3",
46-
"ts-node": "8.10.2",
47-
"typescript": "3.9.7"
43+
"ts-jest": "26.4.4",
44+
"ts-node": "9.1.1",
45+
"typescript": "4.1.3"
4846
},
4947
"dependencies": {
5048
"@elastic/elasticsearch": "7.10.0",
51-
"@sentry/node": "4.6.6",
52-
"axios": "0.18.0",
53-
"bunyan": "1.8.12",
54-
"chevrotain": "4.8.1",
55-
"date-fns": "2.0.0-alpha.27",
49+
"@sentry/node": "5.29.2",
50+
"axios": "0.21.1",
51+
"bunyan": "1.8.14",
52+
"chevrotain": "7.1.0",
53+
"date-fns": "2.16.1",
5654
"deep-diff": "1.0.2",
57-
"fs-extra": "7.0.1",
58-
"joi": "14.3.1",
59-
"lodash": "4.17.11",
55+
"fs-extra": "9.0.1",
56+
"joi": "17.3.0",
57+
"lodash": "4.17.20",
6058
"nusmoderator": "3.0.0",
6159
"oboe": "2.1.5",
6260
"promise-queue": "2.2.5",
6361
"ramda": "0.27.1",
6462
"romanify": "1.0.0",
65-
"yargs": "13.3.2"
63+
"yargs": "16.2.0"
6664
},
6765
"engines": {
6866
"node": ">=10"

scrapers/nus-v2/src/services/logger/SentryStream.ts

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
*/
55

66
import * as Sentry from '@sentry/node';
7-
import { each, pick } from 'lodash';
8-
import { Stream } from 'bunyan';
7+
import type { Stream } from 'bunyan';
8+
import { mapValues, pick } from 'lodash';
99

1010
/* eslint-disable @typescript-eslint/no-explicit-any */
1111

@@ -42,7 +42,7 @@ function getSentryLevel(record: BunyanRecord): Sentry.Severity {
4242
* Error deserializing function. Bunyan serializes the error to object
4343
* https://github.com/trentm/node-bunyan/blob/master/lib/bunyan.js#L1089
4444
* @param {object} data serialized Bunyan
45-
* @return {Error} the deserialiazed error
45+
* @return {Error} the deserialized error
4646
*/
4747
function deserializeError(data: any) {
4848
if (data instanceof Error) return data;
@@ -66,34 +66,22 @@ type StreamConfig = {
6666
};
6767

6868
export default function getSentryStream(config: StreamConfig = {}): Stream {
69-
const tagProps = config.tags || [];
70-
const extraProps = config.extra || [];
69+
const tagProps = config.tags ?? [];
70+
const extraProps = config.extra ?? [];
7171

7272
const stream: any = {
7373
write(record: BunyanRecord) {
74-
const tags = pick(record, tagProps);
75-
const extra = pick(record, extraProps);
76-
const level = getSentryLevel(record);
77-
7874
Sentry.withScope((scope) => {
79-
scope.setLevel(level);
80-
81-
each(tags, (value, prop) => {
82-
scope.setTag(prop, String(value));
83-
});
84-
85-
each(extra, (value, prop) => {
86-
scope.setExtra(prop, value || null);
87-
});
88-
75+
scope.setLevel(getSentryLevel(record));
76+
scope.setTags(mapValues(pick(record, tagProps), (v) => String(v)));
77+
scope.setExtras(mapValues(pick(record, extraProps), (v) => v ?? null));
8978
if (record.err) {
9079
scope.setExtra('msg', record.msg);
9180
Sentry.captureException(deserializeError(record.err));
9281
} else {
9382
Sentry.captureMessage(record.msg);
9483
}
9584
});
96-
9785
return true;
9886
},
9987
};

scrapers/nus-v2/src/services/logger/serializer.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import type { AxiosRequestConfig } from 'axios';
12
import { errorSerializer } from './serializer';
23
import { UnknownApiError } from '../../utils/errors';
34
import { mockResponse } from '../../utils/test-utils';
@@ -12,7 +13,7 @@ describe(errorSerializer, () => {
1213
msg: 'The server is on fire',
1314
data: ['Oh noes!'],
1415
};
15-
const config = {
16+
const config: AxiosRequestConfig = {
1617
url: 'https://example.com/api/test',
1718
method: 'post',
1819
data: '{"hello": "world"}',

scrapers/nus-v2/src/services/requisite-tree/parseString.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as R from 'ramda';
2-
import { createToken, Lexer, Parser, IToken, TokenType } from 'chevrotain';
2+
import { EmbeddedActionsParser, IToken, Lexer, TokenType, createToken } from 'chevrotain';
33

44
import { PrereqTree } from '../../types/modules';
55
import { Logger } from '../logger';
@@ -70,15 +70,15 @@ function generateOrBranch(modules: PrereqTree[]) {
7070
* The code is extremely similar to the following example:
7171
* @see https://github.com/SAP/chevrotain/blob/master/examples/grammars/calculator/calculator_embedded_actions.js
7272
*/
73-
class ReqTreeParser extends Parser {
73+
class ReqTreeParser extends EmbeddedActionsParser {
7474
parse: () => PrereqTree;
7575
orExpression: () => PrereqTree;
7676
andExpression: () => PrereqTree;
7777
parenthesisExpression: () => PrereqTree;
78-
atomicExpression: () => string;
78+
atomicExpression: () => PrereqTree;
7979

8080
constructor() {
81-
super(allTokens, { recoveryEnabled: true, outputCst: false });
81+
super(allTokens, { recoveryEnabled: true });
8282

8383
this.parse = this.RULE('parse', () => this.SUBRULE(this.andExpression));
8484

scrapers/nus-v2/src/services/validation.ts

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,16 @@ const lessonSchema = Joi.object({
1919
end_time: Joi.string().not(Joi.ref('start_time')),
2020
eventdate: Joi.string().isoDate(),
2121

22-
activity: Joi.string().only(Object.keys(activityLessonType)),
22+
activity: Joi.string()
23+
.allow(...Object.keys(activityLessonType))
24+
.only(),
2325

2426
modgrp: Joi.string(),
2527

2628
// Assume lessons on Sunday are invalid
27-
day: Joi.string().only(Object.keys(dayTextMap)),
29+
day: Joi.string()
30+
.allow(...Object.keys(dayTextMap))
31+
.only(),
2832

2933
numweeks: Joi.number().integer().greater(0),
3034

@@ -33,7 +37,7 @@ const lessonSchema = Joi.object({
3337
});
3438

3539
export function validateLesson(lesson: TimetableLesson, logger: Logger = rootLogger) {
36-
const result = Joi.validate(lesson, lessonSchema, {
40+
const result = lessonSchema.validate(lesson, {
3741
presence: 'required',
3842
allowUnknown: true,
3943
// Don't abort early so we can log all errors
@@ -52,7 +56,7 @@ const examSchema = Joi.object({
5256
});
5357

5458
export function validateExam(exam: ModuleExam, logger: Logger = rootLogger) {
55-
const result = Joi.validate(exam, examSchema, {
59+
const result = examSchema.validate(exam, {
5660
presence: 'required',
5761
allowUnknown: true,
5862
// Don't abort early so we can log all errors
@@ -63,8 +67,11 @@ export function validateExam(exam: ModuleExam, logger: Logger = rootLogger) {
6367
return !result.error;
6468
}
6569

66-
const semesterSchema = Joi.number().only(Semesters);
70+
const semesterSchema = Joi.number()
71+
.allow(...Semesters)
72+
.only();
73+
6774
export function validateSemester(semester: string | Semester) {
68-
const result = Joi.validate(+semester, semesterSchema, { presence: 'required' });
75+
const result = semesterSchema.validate(+semester, { presence: 'required' });
6976
return !result.error;
7077
}

scrapers/nus-v2/src/types/v1.ts

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,13 @@ type DayText = string; // E.g. "Monday", "Tuesday"
77
type Department = string;
88
type StartTime = string; // E.g. "1400"
99
type EndTime = string; // E.g. "1500"
10-
type Faculty = string;
1110
type LessonType = string; // E.g. "Lecture", "Tutorial"
12-
type LessonTime = StartTime | EndTime;
1311
type ModuleCode = string; // E.g. "CS3216"
1412
type ModuleTitle = string;
1513
type Semester = number; // E.g. 1/2/3/4. 3 and 4 means special sem i and ii.
1614
type WeekText = string; // E.g. "Every Week", "Odd Week"
1715
type Venue = string;
1816

19-
// Auxiliary data types
20-
type Day = 'Monday' | 'Tuesday' | 'Wednesday' | 'Thursday' | 'Friday' | 'Saturday' | 'Sunday';
21-
22-
type Time = 'Morning' | 'Afternoon' | 'Evening';
23-
24-
type ModuleLevel = 1 | 2 | 3 | 4 | 5 | 6 | 8;
25-
26-
type WorkloadComponent = 'Lecture' | 'Tutorial' | 'Laboratory' | 'Project' | 'Preparation';
27-
2817
// RawLesson is a lesson time slot obtained from the API.
2918
// Usually ModuleCode and ModuleTitle has to be injected in before using in the timetable.
3019
export type V1RawLesson = {

0 commit comments

Comments
 (0)