@lime1/esprit-ts 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,148 @@
1
+ # @lime1/esprit-ts
2
+
3
+ A TypeScript client library for the ESPRIT student portal. Scrape grades, absences, credits, schedules, and student information with full type safety.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @lime1/esprit-ts
9
+ # or
10
+ pnpm add @lime1/esprit-ts
11
+ # or
12
+ yarn add @lime1/esprit-ts
13
+ ```
14
+
15
+ ## Usage
16
+
17
+ ```typescript
18
+ import { EspritClient } from '@lime1/esprit-ts';
19
+
20
+
21
+ async function main() {
22
+ // Create client (optionally enable debug mode)
23
+ const client = new EspritClient({ debug: false });
24
+
25
+ // Login with your ESPRIT credentials
26
+ const result = await client.login('your-student-id', 'your-password');
27
+
28
+ if (!result.success) {
29
+ console.error('Login failed:', result.message);
30
+ return;
31
+ }
32
+
33
+ console.log('Login successful!');
34
+
35
+ // Get student info
36
+ const info = await client.getStudentInfo();
37
+ console.log(`Name: ${info.name}`);
38
+ console.log(`Class: ${info.className}`);
39
+
40
+ // Get grades
41
+ const grades = await client.getGrades();
42
+ console.log('Grades:', grades);
43
+
44
+ // Get grades with calculated averages
45
+ const summary = await client.getGradesWithAverage();
46
+ if (summary) {
47
+ console.log(`Total Average: ${summary.totalAverage?.toFixed(2)}`);
48
+ }
49
+
50
+ // Get absences
51
+ const absences = await client.getAbsences();
52
+ console.log('Absences:', absences);
53
+
54
+ // Get credit history
55
+ const credits = await client.getCredits();
56
+ console.log('Credits:', credits);
57
+
58
+ // Get schedules
59
+ const schedules = await client.getSchedules();
60
+ console.log('Schedules:', schedules);
61
+
62
+ // Logout when done
63
+ await client.logout();
64
+ }
65
+
66
+ main().catch(console.error);
67
+ ```
68
+
69
+ ## API Reference
70
+
71
+ ### `EspritClient`
72
+
73
+ #### Constructor
74
+
75
+ ```typescript
76
+ new EspritClient(config?: EspritClientConfig)
77
+ ```
78
+
79
+ | Option | Type | Default | Description |
80
+ |--------|------|---------|-------------|
81
+ | `debug` | `boolean` | `false` | Enable debug logging |
82
+ | `userAgent` | `string` | Chrome UA | Custom user agent string |
83
+ | `timeout` | `number` | `30000` | Request timeout in ms |
84
+
85
+ #### Methods
86
+
87
+ | Method | Returns | Description |
88
+ |--------|---------|-------------|
89
+ | `login(id, password)` | `Promise<LoginResult>` | Login to the portal |
90
+ | `logout()` | `Promise<boolean>` | Logout from the portal |
91
+ | `getGrades()` | `Promise<Grade[] \| null>` | Get student grades |
92
+ | `getGradesWithAverage()` | `Promise<GradeSummary \| null>` | Get grades with calculated averages |
93
+ | `getAbsences()` | `Promise<Absence[] \| null>` | Get student absences |
94
+ | `getCredits()` | `Promise<Credit[] \| null>` | Get credit history |
95
+ | `getSchedules()` | `Promise<Schedule[] \| null>` | Get available schedules |
96
+ | `getStudentName()` | `Promise<string \| null>` | Get student name |
97
+ | `getStudentClass()` | `Promise<string \| null>` | Get student class |
98
+ | `getStudentInfo()` | `Promise<StudentInfo>` | Get name and class |
99
+ | `getCookies()` | `Promise<Cookie[]>` | Get session cookies |
100
+
101
+ ### Types
102
+
103
+ ```typescript
104
+ interface Grade {
105
+ designation: string;
106
+ coefficient: number | null;
107
+ noteCC: number | null;
108
+ noteTP: number | null;
109
+ noteExam: number | null;
110
+ }
111
+
112
+ interface GradeSummary {
113
+ grades: GradeWithAverage[];
114
+ totalAverage: number | null;
115
+ totalCoefficient: number;
116
+ }
117
+
118
+ interface LoginResult {
119
+ success: boolean;
120
+ cookies: Cookie[];
121
+ message?: string;
122
+ }
123
+
124
+ interface StudentInfo {
125
+ name: string | null;
126
+ className: string | null;
127
+ }
128
+ ```
129
+
130
+ ## Development
131
+
132
+ ```bash
133
+ # Install dependencies
134
+ npm install
135
+
136
+ # Build the package
137
+ npm run build
138
+
139
+ # Type check
140
+ npm run typecheck
141
+
142
+ # Watch mode
143
+ npm run dev
144
+ ```
145
+
146
+ ## License
147
+
148
+ MIT