Skip to content

Commit

Permalink
tsc now generated .d.ts files
Browse files Browse the repository at this point in the history
  • Loading branch information
chopster44 committed Mar 15, 2023
1 parent cc59ba2 commit 556516e
Show file tree
Hide file tree
Showing 10 changed files with 240 additions and 9 deletions.
79 changes: 79 additions & 0 deletions build/API/edulink.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
import { Day, HomeworkResult, RawHomeworkResult, RawTimetableResult, Week } from "../types/result.js";
import { RawHomeworkParams, RawTimetableParams } from "../types/params.js";
/**
* Class for interaction with the Edulink API
*/
export declare class Edulink {
/**
* a variable representing if the user has authenticated
* @type {boolean}
*/
isAuthenticated: boolean;
/**
* the part of the web address which goes before .edulinkone.com
* @type {string}
*/
readonly schoolId: string;
/**
* the auth token given by edulink allowing for interactions. generated on class creation
* @type {string}
*/
authToken: string;
/**
* the name used to identify the user in the edulink backend
* @type {string}
*/
learner_id: string;
private authParams;
/**
* Create an instance of the edulink API helper.
* @param {string} schoolId - the part of the web address which goes before .edulinkone.com
* @param {string} username - the username used to log in to edulink
* @param {string} password - the password used to log in to edulink
* @param {number} establishment_id - unknown usage but cannot log in without it
*/
constructor(schoolId: string, username: string, password: string, establishment_id: number);
/**
* Send a request to the edulink API
* @param {Params} params - the edulink action and any data being sent in the http request body
* @private
*/
private request;
/**
* Used to log in to edulink allowing the api to be used.
* @private
*/
Authenticate(): Promise<void>;
/**
* gets the raw edulink API timetable data
* @param {RawTimetableParams} params - takes in the current date and userid/learner_id
* @return {RawTimetableResult}
*/
getRawTimetable(params: RawTimetableParams): Promise<RawTimetableResult>;
/**
* gets the data for the week edulink classes as the 'current week'
* @return {Week}
*/
getThisWeek(): Promise<Week>;
/**
* gets the data for the day edulink classes as "today"
* @return {Day}
*/
getToday(): Promise<Day>;
/**
* gets the raw edulink API homework data
* @param {RawHomeworkParams} params - not sure why, but it wants a number here
* @return {RawHomeworkResult}
*/
getRawHomework(params: RawHomeworkParams): Promise<RawHomeworkResult>;
/**
* gets the homework edulink calls current
* @return {HomeworkResult}
*/
getCurrentHomework(): Promise<HomeworkResult>;
/**
* gets the homework edulink calls past
* @return {HomeworkResult}
*/
getPastHomework(): Promise<HomeworkResult>;
}
4 changes: 4 additions & 0 deletions build/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { Edulink } from "./API/edulink.js";
import * as EdulinkTypes from "./types/types.js";
export { EdulinkTypes };
export { Edulink };
1 change: 1 addition & 0 deletions build/tests/index.test.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export {};
2 changes: 1 addition & 1 deletion build/tests/index.test.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 29 additions & 0 deletions build/types/params.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
export interface Params {
action?: string;
data: {};
}
export interface AuthParams extends Params {
data: {
establishment_id: number;
fcm_token_old?: string;
from_app?: boolean;
password: string;
ui_info?: {
format: number;
version: string;
git_sha: string;
};
username: string;
};
}
export interface RawTimetableParams extends Params {
data: {
date: string;
learner_id: string;
};
}
export interface RawHomeworkParams extends Params {
data: {
format: number;
};
}
113 changes: 113 additions & 0 deletions build/types/result.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
export interface RawResult {
id: string;
jsonrpc: string;
result: {
success: boolean;
error?: boolean;
};
}
export interface AuthResult extends RawResult {
result: {
analytics_enabled: Array<any>;
api_version: number;
authtoken: string;
success: boolean;
user: User;
};
}
export interface RawTimetableResult extends RawResult {
result: {
requested_date: string;
showing_from: string;
showing_to: string;
success: boolean;
weeks: Array<Week>;
};
}
export interface RawHomeworkResult extends RawResult {
result: {
homework: {
current: Array<Homework>;
past: Array<Homework>;
};
success: boolean;
};
}
export type HomeworkResult = Array<Homework>;
export interface User {
community_group_id: string;
establishment_id: string;
forename: string;
form_group_id: string;
gender: string;
remember_password_permitted: boolean;
surname: string;
types: Array<string>;
username: string;
year_group_id: string;
id: string;
}
export interface Homework {
activity: string;
attachments: Array<any>;
available_date: string;
available_text: string;
cloneable: boolean;
completed: boolean;
deletable: boolean;
due_date: string;
due_reminder: any;
due_text: string;
duration: any;
employee_received: any;
format: number;
icon: string;
id: string;
owner_id: string;
set_by: string;
source: string;
status: string;
subject: string;
user_type: string;
}
export interface Week {
name: string;
is_current: boolean;
days: Array<Day>;
}
export interface Day {
cycle_day_id: string;
date: string;
is_current: boolean;
lessons: Array<Lesson>;
name: string;
original_name: string;
periods: Array<Period>;
}
export interface Lesson {
period_id: string;
room: {
id: string;
moved: boolean;
name: string;
};
teacher: {
forename: string;
id: string;
title: string;
};
teachers: string;
teaching_group: {
id: string;
name: string;
subject: string;
};
}
export interface Period {
empty: boolean;
end_time: string;
external_id: string;
id: string;
name: string;
start_time: string;
}
3 changes: 3 additions & 0 deletions build/types/types.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import * as ParamTypes from "./params.js";
import * as ResultTypes from "./result.js";
export { ParamTypes, ResultTypes };
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "edulinkone-api",
"version": "1.1.0",
"version": "1.1.1",
"description": "A custom-built unofficial api for OvernetData's Edulinkone",
"homepage": "https://github.com/chopster44/edulinkone-api#readme",
"bugs": {
Expand Down
12 changes: 6 additions & 6 deletions src/tests/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,20 @@ async function main () {
learner_id: edulinkTest.learner_id
}
});
if (rawTimetable == undefined) {
if (rawTimetable === undefined) {
throw new Error("Timetable Error: out from timetable is undefined");
}

let thisWeek = await edulinkTest.getThisWeek();
if (thisWeek == undefined) {
if (thisWeek === undefined) {
throw new Error("Timetable Error: out from getThisWeek() is undefined");
}
if (!thisWeek.is_current) {
throw new Error("Timetable Error: this week is not this week");
}

let today = await edulinkTest.getToday();
if (today == undefined) {
if (today === undefined) {
throw new Error("Timetable Error: out from getToday() is undefined");
}
if (!today.is_current) {
Expand All @@ -36,17 +36,17 @@ async function main () {
format: 2
}
});
if (rawHomework == undefined) {
if (rawHomework === undefined) {
throw new Error("Homework Error: out from homework is undefined");
}

let currentHomework = await edulinkTest.getCurrentHomework();
if (currentHomework == undefined) {
if (currentHomework === undefined) {
throw new Error("Homework Error: out from current homework is undefined");
}

let pastHomework = await edulinkTest.getCurrentHomework();
if (pastHomework == undefined) {
if (pastHomework === undefined) {
throw new Error("Homework Error: out from past homework is undefined");
}
}
Expand Down
4 changes: 3 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
],
"sourceMap": true,
"removeComments": false,
"moduleResolution": "NodeNext"
"moduleResolution": "NodeNext",
"declaration": true,
"emitDeclarationOnly": false
},
"exclude": [
"node_modules",
Expand Down

0 comments on commit 556516e

Please sign in to comment.