Skip to content
This repository was archived by the owner on Aug 2, 2025. It is now read-only.

Commit 49589b5

Browse files
committed
feat: add timetabl type definition
1 parent 0c9dee8 commit 49589b5

File tree

3 files changed

+45
-10
lines changed

3 files changed

+45
-10
lines changed
Lines changed: 45 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,63 @@
11
import { DateTime } from "luxon";
22

3-
// A data provider provides a queryFn and a select function. The result of
4-
// queryFn should be serializable and deserializable with JSON.stringify. THis
5-
// means types like Date will not work, as they will be serialised to a string
6-
// but not deserialised back to a Date.
7-
8-
type LongOrShortString = {
3+
export type LongOrShortString = {
94
short: string;
105
long?: string;
116
};
127

13-
type Period = {
8+
export type Period = {
149
start: DateTime;
1510
end: DateTime;
1611
teacher?: LongOrShortString;
1712
name?: LongOrShortString;
1813
location?: LongOrShortString;
1914
};
2015

21-
export interface DataProvider {
16+
export const ContentEncodings = ["html", "markdown"] as const;
17+
export type ContentEncoding = typeof ContentEncodings[number];
18+
19+
export type Notice<TAudience> = {
20+
date: DateTime;
21+
title: string;
22+
content: string;
23+
content_encoding: ContentEncoding;
24+
audiences: TAudience[];
25+
author: string;
26+
};
27+
28+
// Fetch output must be serialisable to JSON
29+
export interface DataProvider<TAudience> {
2230
activate(): void;
2331
deactivate(): void;
2432
isActivated(): boolean;
2533

26-
// Returns a scan-on barcode if applicable
27-
barcode?(): Promise<string>;
34+
config: {
35+
name: LongOrShortString;
36+
description: LongOrShortString;
37+
};
38+
39+
barcode?: {
40+
fetch: () => Promise<unknown>;
41+
parse: (data: unknown) => string;
42+
};
43+
44+
// Day Timetable
45+
dtt?: {
46+
fetch: (date: DateTime) => Promise<unknown>;
47+
parse: (data: unknown) => Period[];
48+
};
49+
50+
cycle?: {
51+
fetch: () => Promise<unknown>;
52+
parse: (data: unknown) => Period[];
53+
};
54+
55+
notices?: {
56+
fetch: () => Promise<unknown>;
57+
parse: (data: unknown) => Notice<TAudience>[];
58+
};
59+
60+
newsletter?: {
61+
newsletterDownloadUrl: string;
62+
};
2863
}

apps/client/src/services/dataProviders/SbhsDataProvider/SbhsDataProvider.ts

Whitespace-only changes.

apps/client/src/services/dataProviders/SbhsDataProvider/index.ts

Whitespace-only changes.

0 commit comments

Comments
 (0)