Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

classcharts-api

Package Overview
Dependencies
Maintainers
1
Versions
53
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

classcharts-api - npm Package Compare versions

Comparing version 1.6.0 to 2.0.0

17

dist/baseClient.d.ts
import type { AxiosRequestConfig, AxiosInstance } from "axios";
import type { ActivityResponse, AnnouncementsResponse, AttendanceResponse, BadgesResponse, BehaviourResponse, DetentionsResponse, GetActivityOptions, GetAttendanceOptions, GetBehaviourOptions, GetFullActivityOptions, GetHomeworkOptions, GetLessonsOptions, HomeworksResponse, LessonsResponse, Student } from "./types";
import type { ActivityResponse, AnnouncementsResponse, AttendanceResponse, BadgesResponse, BehaviourResponse, DetentionsResponse, GetActivityOptions, GetAttendanceOptions, GetBehaviourOptions, GetFullActivityOptions, GetHomeworkOptions, GetLessonsOptions, GetStudentInfoResponse, HomeworksResponse, LessonsResponse } from "./types";
/**

@@ -8,3 +8,3 @@ * The base client

studentId: number;
authCookies: Array<string> | undefined;
authCookies: Array<string>;
sessionId: string;

@@ -21,3 +21,2 @@ lastPing: number;

makeAuthedRequest(path: string, axiosOptions: Omit<AxiosRequestConfig, "path">, options?: {
includeMeta?: boolean;
revalidateToken?: boolean;

@@ -29,3 +28,3 @@ }): Promise<any>;

*/
getStudentInfo(): Promise<Student>;
getStudentInfo(): Promise<GetStudentInfoResponse>;
/**

@@ -42,3 +41,3 @@ * This function is only used for pagination, you likely want client.getFullActivity

*/
getFullActivity(options: GetFullActivityOptions): Promise<ActivityResponse>;
getFullActivity(options: GetFullActivityOptions): Promise<ActivityResponse["data"]>;
/**

@@ -55,3 +54,3 @@ * Gets the logged in students behaviour points

*/
listHomeworks(options?: GetHomeworkOptions): Promise<HomeworksResponse>;
getHomeworks(options?: GetHomeworkOptions): Promise<HomeworksResponse>;
/**

@@ -69,6 +68,6 @@ * Gets the logged in student's lessons for a day

/**
* Lists the logged in student's announcements
* Gets the logged in student's announcements
* @returns Array of announcements
*/
listAnnouncements(): Promise<AnnouncementsResponse>;
getAnnouncements(): Promise<AnnouncementsResponse>;
/**

@@ -84,3 +83,3 @@ * Gets the logged in student's detentions

*/
listAttendance(options?: GetAttendanceOptions): Promise<AttendanceResponse>;
getAttendance(options?: GetAttendanceOptions): Promise<AttendanceResponse>;
}

@@ -22,2 +22,3 @@ "use strict";

this.API_BASE = "";
this.authCookies = [];
this.API_BASE = API_BASE;

@@ -41,3 +42,3 @@ this.axios = axios_1.default.create({

},
}, { includeMeta: true, revalidateToken: false });
}, { revalidateToken: false });
this.sessionId = pingData.meta.session_id;

@@ -74,6 +75,3 @@ this.lastPing = Date.now();

}
if (options?.includeMeta) {
return responseJSON;
}
return responseJSON.data;
return responseJSON;
}

@@ -89,3 +87,3 @@ /**

});
return data?.user;
return data;
}

@@ -123,3 +121,3 @@ /**

}
const fragment = await this.getActivity(params);
const fragment = (await this.getActivity(params)).data;
if (!fragment || !fragment.length) {

@@ -153,8 +151,6 @@ gotData = false;

*/
async listHomeworks(options) {
async getHomeworks(options) {
const params = new URLSearchParams();
if (options?.displayDate)
params.append("display_date", String(options?.displayDate));
options?.fromDate && params.append("from", String(options?.fromDate));
options?.toDate && params.append("to", String(options?.toDate));
options?.from && params.append("from", String(options?.from));

@@ -165,8 +161,8 @@ options?.to && params.append("to", String(options?.to));

});
for (let i = 0; i < data.length; i++) {
data[i].description_raw = data[i].description;
for (let i = 0; i < data.data.length; i++) {
data.data[i].description_raw = data.data[i].description;
// homework.lesson.replace(/\\/g, '')
data[i].description = data[i].description.replace(/(<([^>]+)>)/gi, "");
data[i].description = data[i].description.replace(/&nbsp;/g, "");
data[i].description = data[i].description.trim();
data.data[i].description = data.data[i].description.replace(/(<([^>]+)>)/gi, "");
data.data[i].description = data.data[i].description.replace(/&nbsp;/g, "");
data.data[i].description = data.data[i].description.trim();
}

@@ -199,9 +195,9 @@ return data;

/**
* Lists the logged in student's announcements
* Gets the logged in student's announcements
* @returns Array of announcements
*/
async listAnnouncements() {
return await this.makeAuthedRequest(this.API_BASE + "/announcements/" + this.studentId, {
async getAnnouncements() {
return (await this.makeAuthedRequest(this.API_BASE + "/announcements/" + this.studentId, {
method: "GET",
});
})).data;
}

@@ -213,5 +209,5 @@ /**

async getDetentions() {
return await this.makeAuthedRequest(this.API_BASE + "/detentions/" + this.studentId, {
return (await this.makeAuthedRequest(this.API_BASE + "/detentions/" + this.studentId, {
method: "GET",
});
})).data;
}

@@ -223,9 +219,13 @@ /**

*/
async listAttendance(options) {
async getAttendance(options) {
const params = new URLSearchParams();
options?.from && params.append("from", options?.from);
options?.to && params.append("to", options?.to);
return await this.makeAuthedRequest(this.API_BASE + "/attendance/" + this.studentId + "?" + params.toString(), {
return (await this.makeAuthedRequest(this.API_BASE +
"/attendance/" +
this.studentId +
"?" +
params.toString(), {
method: "GET",
});
})).data;
}

@@ -232,0 +232,0 @@ }

export * from "./parentClient";
export * from "./studentClient";
export * from "./types";

@@ -19,3 +19,2 @@ "use strict";

__exportStar(require("./studentClient"), exports);
__exportStar(require("./types"), exports);
//# sourceMappingURL=index.js.map

@@ -5,5 +5,5 @@ import type { AxiosRequestConfig } from "axios";

/**
* The base client
* Parent Client
*/
export declare class ClasschartsParentClient extends ClasschartsClient {
export declare class ParentClient extends ClasschartsClient {
private password;

@@ -24,3 +24,3 @@ private email;

* Get Pupil details
* @returns an array fo Pupils connected to this parent's account
* @returns an array of Pupils connected to this parent's account
*/

@@ -27,0 +27,0 @@ getPupils(): Promise<GetPupilsResponse>;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ClasschartsParentClient = void 0;
exports.ParentClient = void 0;
const baseClient_1 = require("./baseClient");

@@ -8,5 +8,5 @@ const consts_1 = require("./consts");

/**
* The base client
* Parent Client
*/
class ClasschartsParentClient extends baseClient_1.ClasschartsClient {
class ParentClient extends baseClient_1.ClasschartsClient {
/**

@@ -49,3 +49,3 @@ *

const cookies = String(request.headers["set-cookie"]);
this.authCookies = cookies.split(";");
// this.authCookies = cookies.split(";");
const sessionCookies = (0, utils_1.parseCookies)(cookies);

@@ -61,3 +61,3 @@ const sessionID = JSON.parse(String(sessionCookies["parent_session_credentials"]));

* Get Pupil details
* @returns an array fo Pupils connected to this parent's account
* @returns an array of Pupils connected to this parent's account
*/

@@ -87,3 +87,3 @@ async getPupils() {

}
exports.ClasschartsParentClient = ClasschartsParentClient;
exports.ParentClient = ParentClient;
//# sourceMappingURL=parentClient.js.map
import type { AxiosRequestConfig } from "axios";
import { ClasschartsClient } from "./baseClient";
/**
* The base client
* Student Client
*/
export declare class ClasschartsStudentClient extends ClasschartsClient {
export declare class StudentClient extends ClasschartsClient {
studentCode: string;

@@ -8,0 +8,0 @@ dateOfBirth: string;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ClasschartsStudentClient = void 0;
exports.StudentClient = void 0;
const consts_1 = require("./consts");

@@ -8,5 +8,5 @@ const baseClient_1 = require("./baseClient");

/**
* The base client
* Student Client
*/
class ClasschartsStudentClient extends baseClient_1.ClasschartsClient {
class StudentClient extends baseClient_1.ClasschartsClient {
/**

@@ -55,6 +55,6 @@ *

const user = await this.getStudentInfo();
this.studentId = user.id;
this.studentId = user.data.user.id;
}
}
exports.ClasschartsStudentClient = ClasschartsStudentClient;
exports.StudentClient = StudentClient;
//# sourceMappingURL=studentClient.js.map

@@ -0,1 +1,7 @@

type ClassChartsResponse<T, E> = {
data: T;
meta: E;
error?: string;
success: number;
};
export interface Student {

@@ -39,2 +45,9 @@ id: number;

}
interface GetStudentInfoData {
user: Student;
}
interface GetStudentInfoMeta {
version: string;
}
export type GetStudentInfoResponse = ClassChartsResponse<GetStudentInfoData, GetStudentInfoMeta>;
export interface GetBehaviourOptions {

@@ -57,3 +70,3 @@ /**

}
export interface BehaviourResponse {
interface BehaviourResponseData {
timeline: Array<BehaviourTimelinePoint>;

@@ -67,2 +80,8 @@ positive_reasons: Record<string, number>;

}
interface BehaviourResponseMeta {
start_date: string;
end_date: string;
step_size: string;
}
export type BehaviourResponse = ClassChartsResponse<BehaviourResponseData, BehaviourResponseMeta>;
export interface GetActivityOptions {

@@ -106,3 +125,11 @@ /**

}
export type ActivityResponse = Array<ActivityPoint>;
type ActivityResponseData = Array<ActivityPoint>;
interface ActivityResponseMeta {
start_date: string;
end_date: string;
last_id: boolean;
step_size: string;
detention_alias_uc: string;
}
export type ActivityResponse = ClassChartsResponse<ActivityResponseData, ActivityResponseMeta>;
export type DisplayDate = "due_date" | "issue_date";

@@ -115,10 +142,2 @@ export interface GetHomeworkOptions {

/**
* @deprecated Use "from" instead
*/
fromDate?: string;
/**
* @deprecated Use "to" instead
*/
toDate?: string;
/**
* From date, in format YYYY-MM-DD

@@ -168,3 +187,16 @@ */

}
export type HomeworksResponse = Array<Homework>;
type HomeworksResponseData = Array<Homework>;
interface HomeworksResponseMeta {
start_date: string;
end_date: string;
display_type: DisplayDate;
max_files_allowed: number;
allowed_file_types: string[];
this_week_due_count: number;
this_week_outstanding_count: number;
this_week_completed_count: number;
allow_attachments: boolean;
display_marks: boolean;
}
export type HomeworksResponse = ClassChartsResponse<HomeworksResponseData, HomeworksResponseMeta>;
export interface GetLessonsOptions {

@@ -194,3 +226,16 @@ /**

}
export type LessonsResponse = Array<Lesson>;
type LessonsResponseData = Lesson[];
interface PeriodMeta {
number: string;
start_time: string;
end_time: string;
}
interface LessonsResponseMeta {
dates: string[];
timetable_dates: string[];
periods: PeriodMeta[];
start_time: string;
end_time: string;
}
export type LessonsResponse = ClassChartsResponse<LessonsResponseData, LessonsResponseMeta>;
export interface LessonPupilBehaviour {

@@ -224,3 +269,5 @@ reason: string;

}
export type BadgesResponse = Array<Badge>;
type BadgesResponseData = Array<Badge>;
type BadgesResponseMeta = [];
export type BadgesResponse = ClassChartsResponse<BadgesResponseData, BadgesResponseMeta>;
export interface Detention {

@@ -344,2 +391,3 @@ id: number;

}
export type AttendanceResponse = Array<Record<string, AttendanceDate>>;
export type AttendanceResponse = Record<string, AttendanceDate>[];
export {};
{
"name": "classcharts-api",
"version": "1.6.0",
"description": "A javascript wrapper for getting information from the Classcharts API",
"version": "2.0.0",
"description": "A typescript wrapper for getting information from the Classcharts API",
"keywords": [

@@ -34,19 +34,16 @@ "node",

"devDependencies": {
"@types/jest": "^29.2.3",
"@types/jest": "^29.5.0",
"@types/node": "^18",
"@typescript-eslint/eslint-plugin": "^5.45.0",
"@typescript-eslint/parser": "^5.45.0",
"eslint": "^8.28.0",
"eslint-config-prettier": "^8.5.0",
"jest": "^29.3.1",
"jest-extended": "^3.2.0",
"prettier": "^2.8.0",
"ts-jest": "^29.0.3",
"typedoc": "^0.23.21",
"typescript": "^4.9.3"
"@typescript-eslint/eslint-plugin": "^5.57.1",
"@typescript-eslint/parser": "^5.57.1",
"eslint": "^8.37.0",
"eslint-config-prettier": "^8.8.0",
"jest": "^29.5.0",
"jest-extended": "^3.2.4",
"prettier": "^2.8.7",
"ts-jest": "^29.1.0",
"typedoc": "^0.23.28",
"typescript": "^5.0.3"
},
"types": "./dist/index.d.ts",
"volta": {
"node": "18.12.1"
},
"exports": {

@@ -53,0 +50,0 @@ ".": {

@@ -12,9 +12,8 @@ # Classcharts API

```typescript
import { ClasschartsStudentClient } from "classcharts-api";
import { StudentClient } from "classcharts-api";
async function main() {
const client = new ClasschartsStudentClient("classchartsCode", "01/1/2000");
const client = new StudentClient("classchartsCode", "01/1/2000");
await client.login();
console.log(
await client.getBehaviour({
displayDate: "due_date",
fromDate: "20/01/2000",

@@ -21,0 +20,0 @@ toDate: "01/02/2000",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc