Skip to content

Commit 1b94a95

Browse files
committed
fix broken typescript paths
1 parent bf3ebba commit 1b94a95

15 files changed

+68
-57
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "dsbmobile",
3-
"version": "1.1.4",
3+
"version": "1.1.5",
44
"description": "A Javascript wrapper for the dsbmobile api",
55
"main": "dist/index.js",
66
"types": "dist/index.d.ts",

src/documents/documentcollection.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { DocumentPost } from "@/documents/documentpost";
1+
import { DocumentPost } from "./documentpost";
22

33
export class DocumentPostCollection {
44
constructor(public readonly posts: DocumentPost[]) {}

src/documents/documentpost.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { isText, parseDate } from "@/utility";
1+
import { isText, parseDate } from "../utility";
22

33
export class DocumentPost {
44
/**

src/documents/index.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
export { DocumentPost } from "@/documents/documentpost";
2-
export { DocumentPostCollection } from "@/documents/documentcollection";
1+
export { DocumentPost } from "./documentpost";
2+
export { DocumentPostCollection } from "./documentcollection";

src/dsbmobile.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ import {
44
NewsPostCollection,
55
TimeTable,
66
MissingToken,
7-
} from "@";
7+
} from "./";
88
import axios from "axios";
9-
import { NewsPost } from "@/news/newspost";
10-
import { Requester } from "@/requester";
9+
import { NewsPost } from "./";
10+
import { Requester } from "./requester";
1111

1212
/**
1313
* The configuration Object for a `Dsbmobile` instance

src/index.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import Dsbmobile from "@/dsbmobile";
1+
import Dsbmobile from "./dsbmobile";
22

33
export default Dsbmobile;
4-
export { DsbmobileConfig } from "@/dsbmobile";
5-
export { UnknownSubject, WrongCredentials, MissingToken } from "@/errors";
6-
export { NewsPostCollection, NewsPost } from "@/news";
7-
export { TimeTable, Entry } from "@/timetable";
8-
export { DocumentPostCollection, DocumentPost } from "@/documents";
4+
export { DsbmobileConfig } from "./dsbmobile";
5+
export { UnknownSubject, WrongCredentials, MissingToken } from "./errors";
6+
export { NewsPostCollection, NewsPost } from "./news";
7+
export { TimeTable, Entry } from "./timetable";
8+
export { DocumentPostCollection, DocumentPost } from "./documents";

src/news/index.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
export { NewsPost } from "@/news/newspost";
2-
export { NewsPostCollection } from "@/news/newspostcollection";
1+
export { NewsPost } from "./newspost";
2+
export { NewsPostCollection } from "./newspostcollection";

src/news/newspost.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { isText, parseDate } from "@/utility";
1+
import { isText, parseDate } from "../utility";
22

33
export class NewsPost {
44
public readonly date: Date;

src/news/newspostcollection.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { NewsPost } from "@/news";
1+
import { NewsPost } from "./newspost";
22

33
/**
44
* The resource **NewsPostCollection**.

src/requester.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { AxiosInstance, AxiosRequestConfig } from "axios";
2-
import { WrongCredentials } from "@";
3-
import { ServerError, UnknownFetchError } from "@/errors";
2+
import { WrongCredentials } from "./";
3+
import { ServerError, UnknownFetchError } from "./errors";
44

55
/**
66
* The requester used to make requests to the dsbmobile-api

src/timetable/entry.ts

+43-28
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,32 @@
1-
import { isText } from "@/utility";
2-
import { UnknownSubject } from "@";
1+
import { isText } from "../utility";
2+
import { UnknownSubject } from "../";
33

44
export class Entry {
55
public readonly date: Date;
6+
public readonly subjectShorts = new Map<string, string>([
7+
["D", "Deutsch"],
8+
["E", "Englisch"],
9+
["WI", "Wirtschaft"],
10+
["GGK", "Geschichte und Gemeinschaftskunde"],
11+
["CH", "Chemie"],
12+
["S", "Sport"],
13+
["M", "Mathe"],
14+
["BK", "Bildende Kunst"],
15+
["BK1", "Bildende Kunst"],
16+
["BK2", "Bildende Kunst"],
17+
["GS", "Global Studies"],
18+
["PH", "Physik"],
19+
["IT", "Informatik"],
20+
["INF", "Informationstechnik"],
21+
["ITÜS", "IT Softwareentwicklung"],
22+
["ITÜH", "IT Hardware"],
23+
["EVR", "Religion"],
24+
["ETH", "Ethik"],
25+
["SP", "Zweitsprache"],
26+
["IFÖM", "Mathe Förderunterricht"],
27+
["IFÖE", "Englisch Förderunterricht"],
28+
["IFÖD", "Deutsch Förderunterricht"],
29+
]);
630

731
constructor(
832
date: Date | string,
@@ -97,6 +121,22 @@ export class Entry {
97121
return this.longSubjectName(this.oldSubject);
98122
}
99123

124+
/**
125+
* Update the subject shorts with a map
126+
* @param subjectShorts
127+
*
128+
* @example
129+
* ```js
130+
* entry.updateSubjectShorts(new Map([["D", "Deutsch"]]))
131+
* ```
132+
*/
133+
public registerSubjectShorts(subjectShorts: Map<string, string>) {
134+
// Update the subjectShorts map with the parameter map
135+
for (const [k, v] of subjectShorts) {
136+
this.subjectShorts.set(k, v);
137+
}
138+
}
139+
100140
private longSubjectName(subjectShort: string): string {
101141
const validReg = /[a-bA-b]/;
102142
if (!validReg.test(subjectShort)) {
@@ -106,32 +146,7 @@ export class Entry {
106146
const replaceReg = /([0-9]|\/).*$/;
107147
subjectShort = subjectShort.replace(replaceReg, "");
108148

109-
const subjectShorts = {
110-
D: "Deutsch",
111-
E: "Englisch",
112-
WI: "Wirtschaft",
113-
GGK: "Geschichte und Gemeinschaftskunde",
114-
CH: "Chemie",
115-
S: "Sport",
116-
M: "Mathe",
117-
BK: "Bildende Kunst",
118-
BK1: "Bildende Kunst",
119-
BK2: "Bildende Kunst",
120-
GS: "Global Studies",
121-
PH: "Physik",
122-
IT: "Informatik",
123-
INF: "Informationstechnik",
124-
ITÜS: "IT Softwareentwicklung",
125-
ITÜH: "IT Hardware",
126-
EVR: "Religion",
127-
ETH: "Ethik",
128-
SP: "Zweitsprache",
129-
IFÖM: "Mathe Förderunterricht",
130-
IFÖE: "Englisch Förderunterricht",
131-
IFÖD: "Deutsch Förderunterricht",
132-
};
133-
134-
const subjectLong = subjectShorts[subjectShort];
149+
const subjectLong = this.subjectShorts.get(subjectShort);
135150

136151
if (subjectLong === undefined) {
137152
throw new UnknownSubject(subjectShort);

src/timetable/index.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
export { TimeTable } from "@/timetable/timetable";
2-
export { Entry } from "@/timetable/entry";
1+
export { TimeTable } from "./timetable";
2+
export { Entry } from "./entry";

src/timetable/timetable.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Entry } from "@/timetable/entry";
1+
import { Entry } from "./entry";
22
import cheerio from "cheerio";
33

44
/**

test/components.spec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ describe("Test components(classes)", () => {
2626
const entry2 = Entry.fromJSON(data);
2727

2828
try {
29-
// `expect` beneath should throw an exception
29+
// `expect` below should throw an exception
3030
expect(entry2.longNewSubject).to.throw("UnknownSubject");
3131
throw new Error();
3232
} catch (e) {

tsconfig.json

+1-5
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,7 @@
1111
"esModuleInterop": true,
1212
"strict": true,
1313
"downlevelIteration": true,
14-
"resolveJsonModule": true,
15-
"paths": {
16-
"@": ["./"],
17-
"@/*": ["./*"]
18-
}
14+
"resolveJsonModule": true
1915
},
2016
"include": ["src/**/*"]
2117
}

0 commit comments

Comments
 (0)