This repository was archived by the owner on Aug 2, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 5 files changed +86
-3
lines changed
Expand file tree Collapse file tree 5 files changed +86
-3
lines changed Original file line number Diff line number Diff line change @@ -26,14 +26,14 @@ export type Notice<TAudience> = {
2626} ;
2727
2828// Fetch output must be serialisable to JSON
29- export interface DataProvider < TAudience > {
29+ export interface DataProvider < TAudience = never > {
3030 activate ( ) : void ;
3131 deactivate ( ) : void ;
3232 isActivated ( ) : boolean ;
3333
3434 config : {
3535 name : LongOrShortString ;
36- description : LongOrShortString ;
36+ description : string ;
3737 } ;
3838
3939 barcode ?: {
@@ -58,6 +58,7 @@ export interface DataProvider<TAudience> {
5858 } ;
5959
6060 newsletter ?: {
61- newsletterDownloadUrl : string ;
61+ downloadUrl : string ;
62+ name : string ;
6263 } ;
6364}
Original file line number Diff line number Diff line change 1+ import { NoticeYear } from "../../../consumers/sbhsApi/schemas" ;
2+ import { DataProvider , Notice , Period } from "../../../interfaces/DataProvider" ;
3+ import { DateTime } from "luxon" ;
4+
5+ export class SbhsDataProvider implements DataProvider < NoticeYear > {
6+ activate ( ) : void {
7+ throw new Error ( "Method not implemented." ) ;
8+ }
9+ deactivate ( ) : void {
10+ throw new Error ( "Method not implemented." ) ;
11+ }
12+ isActivated ( ) : boolean {
13+ throw new Error ( "Method not implemented." ) ;
14+ }
15+
16+ config = {
17+ name : { short : "SBHS" , long : "SBHS Student Portal" } ,
18+ description : "Accesses timetable and notices from the SBHS Student Portal." ,
19+ } ;
20+
21+ barcode ?:
22+ | { fetch : ( ) => Promise < unknown > ; parse : ( data : unknown ) => string }
23+ | undefined ;
24+
25+ dtt ?:
26+ | {
27+ fetch : ( date : DateTime ) => Promise < unknown > ;
28+ parse : ( data : unknown ) => Period [ ] ;
29+ }
30+ | undefined ;
31+
32+ cycle ?:
33+ | { fetch : ( ) => Promise < unknown > ; parse : ( data : unknown ) => Period [ ] }
34+ | undefined ;
35+
36+ notices ?:
37+ | {
38+ fetch : ( ) => Promise < unknown > ;
39+ parse : ( data : unknown ) => Notice < NoticeYear > [ ] ;
40+ }
41+ | undefined ;
42+
43+ newsletter = { downloadUrl : "https://sbhs.co/hnpdf" , name : "High Notes" } ;
44+ }
Original file line number Diff line number Diff line change 1+ export { SbhsDataProvider } from "./SbhsDataProvider" ;
Original file line number Diff line number Diff line change 1+ import { DataProvider } from "../../../interfaces/DataProvider" ;
2+ import { z } from "zod" ;
3+
4+ export class TestDataProvider implements DataProvider {
5+ private activated = false ;
6+
7+ activate = ( ) => {
8+ this . activated = true ;
9+ } ;
10+
11+ deactivate = ( ) => {
12+ this . activated = false ;
13+ } ;
14+
15+ isActivated = ( ) => this . activated ;
16+
17+ config = {
18+ name : { short : "Test" } ,
19+ description : "Test" ,
20+ } ;
21+
22+ // Example implentation of fetch and parse
23+ barcode = {
24+ fetch : async ( ) => ( {
25+ barcode : "Test Barcode" , // In reality, this would be fetched from the API
26+ } ) ,
27+
28+ parse : ( data : unknown ) => {
29+ const barcodeSchema = z . object ( {
30+ barcode : z . string ( ) ,
31+ } ) ;
32+ const { barcode } = barcodeSchema . parse ( data ) ;
33+
34+ return barcode ;
35+ } ,
36+ } ;
37+ }
You can’t perform that action at this time.
0 commit comments