mivax-sdk 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 +90 -0
- package/dist/client.d.ts +77 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +240 -0
- package/dist/index.mjs +203 -0
- package/dist/types.d.ts +53 -0
- package/dist/types.d.ts.map +1 -0
- package/package.json +42 -0
package/README.md
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
# MivaX SDK
|
|
2
|
+
|
|
3
|
+
A comprehensive Node.js & Browser SDK for the MivaX API. Connect your applications to the Miva Open University ecosystem with ease.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install mivax-sdk
|
|
9
|
+
# or
|
|
10
|
+
yarn add mivax-sdk
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Features
|
|
14
|
+
|
|
15
|
+
- **Cross-Platform**: Works in both Node.js and the browser.
|
|
16
|
+
- **Type-Safe**: Full TypeScript support with detailed types and interfaces.
|
|
17
|
+
- **Authentication**: Easy session management and login handling.
|
|
18
|
+
- **Comprehensive coverage**: SIS, LMS, and Student Dashboard support.
|
|
19
|
+
|
|
20
|
+
## Usage
|
|
21
|
+
|
|
22
|
+
### Simple Initialization
|
|
23
|
+
|
|
24
|
+
```typescript
|
|
25
|
+
import { MivaX } from 'mivax-sdk';
|
|
26
|
+
|
|
27
|
+
const mivax = new MivaX({
|
|
28
|
+
baseUrl: 'https://mivax.marvelly.com.ng' // (optional, defaults to this)
|
|
29
|
+
});
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
### Authentication
|
|
33
|
+
|
|
34
|
+
```typescript
|
|
35
|
+
// Login to get a session ID
|
|
36
|
+
const loginRes = await mivax.login('your.email@miva.edu.ng', 'your_password');
|
|
37
|
+
console.log('LoggedIn Session:', mivax.getSessionId());
|
|
38
|
+
|
|
39
|
+
// Or set an existing session ID manually
|
|
40
|
+
mivax.setSessionId('your_existing_session_id');
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### Student Profile & Academics (SIS)
|
|
44
|
+
|
|
45
|
+
```typescript
|
|
46
|
+
// Get User Profile
|
|
47
|
+
const profile = await mivax.getUserProfile();
|
|
48
|
+
console.log(`Welcome, ${profile.first_name}`);
|
|
49
|
+
|
|
50
|
+
// Academic summary (CGPA, etc)
|
|
51
|
+
const summary = await mivax.getAcademicSummary();
|
|
52
|
+
console.log(`Current CGPA: ${summary.cgpa}`);
|
|
53
|
+
|
|
54
|
+
// Get results for specific level
|
|
55
|
+
const results = await mivax.getTranscriptByLevel('200_LEVEL');
|
|
56
|
+
|
|
57
|
+
// List current courses
|
|
58
|
+
const currentCourses = await mivax.getCurrentCourses();
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### LMS & Course Content
|
|
62
|
+
|
|
63
|
+
```typescript
|
|
64
|
+
// List courses from the LMS
|
|
65
|
+
const courses = await mivax.getLmsCourses();
|
|
66
|
+
|
|
67
|
+
// Get content for a specific course
|
|
68
|
+
const content = await mivax.getCourseContent('course_id_here');
|
|
69
|
+
|
|
70
|
+
// Get module specific details
|
|
71
|
+
const mod = await mivax.getModuleDetail('page', 'module_id_here');
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### Dashboards & Payments
|
|
75
|
+
|
|
76
|
+
```typescript
|
|
77
|
+
// Fetch recent payment records
|
|
78
|
+
const payments = await mivax.getPaymentRecords(1, 10);
|
|
79
|
+
|
|
80
|
+
// Get recent notifications
|
|
81
|
+
const notifications = await mivax.getNotifications();
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## Related Links
|
|
85
|
+
|
|
86
|
+
- [Official MivaX API Base](https://mivax.marvelly.com.ng/)
|
|
87
|
+
|
|
88
|
+
## License
|
|
89
|
+
|
|
90
|
+
MIT
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { MivaXOptions, LoginResponse, UserProfile, AcademicSummary, AcademicLevel, Transcript, Course, RegistrationStatus, PaginatedResponse, PaymentRecord, Notification, ModuleDetail } from './types';
|
|
2
|
+
export declare class MivaX {
|
|
3
|
+
private client;
|
|
4
|
+
private sessionId;
|
|
5
|
+
constructor(options?: MivaXOptions);
|
|
6
|
+
/**
|
|
7
|
+
* Set the session ID manually if already authenticated.
|
|
8
|
+
*/
|
|
9
|
+
setSessionId(sessionId: string): void;
|
|
10
|
+
/**
|
|
11
|
+
* Get the current session ID.
|
|
12
|
+
*/
|
|
13
|
+
getSessionId(): string | null;
|
|
14
|
+
private request;
|
|
15
|
+
/**
|
|
16
|
+
* Login to MivaX and set the session ID.
|
|
17
|
+
*/
|
|
18
|
+
login(email: string, password: string): Promise<LoginResponse>;
|
|
19
|
+
private ensureSessionId;
|
|
20
|
+
/**
|
|
21
|
+
* Fetch basic student profile from SIS.
|
|
22
|
+
*/
|
|
23
|
+
getUserProfile(sessionId?: string): Promise<UserProfile>;
|
|
24
|
+
/**
|
|
25
|
+
* Get overall CGPA and degree status.
|
|
26
|
+
*/
|
|
27
|
+
getAcademicSummary(sessionId?: string): Promise<AcademicSummary>;
|
|
28
|
+
/**
|
|
29
|
+
* List all study years (100L, 200L, etc) with completion summaries.
|
|
30
|
+
*/
|
|
31
|
+
getAcademicLevels(sessionId?: string): Promise<AcademicLevel[]>;
|
|
32
|
+
/**
|
|
33
|
+
* Returns results for all academic levels at once.
|
|
34
|
+
*/
|
|
35
|
+
getFullTranscript(sessionId?: string): Promise<Transcript>;
|
|
36
|
+
/**
|
|
37
|
+
* Detailed results and GPA for a specific level (e.g., 200_LEVEL).
|
|
38
|
+
*/
|
|
39
|
+
getTranscriptByLevel(level: string, sessionId?: string): Promise<Transcript>;
|
|
40
|
+
/**
|
|
41
|
+
* List only the courses currently being taken in the active semester.
|
|
42
|
+
*/
|
|
43
|
+
getCurrentCourses(sessionId?: string): Promise<Course[]>;
|
|
44
|
+
/**
|
|
45
|
+
* Check enrollment windows and pending status.
|
|
46
|
+
*/
|
|
47
|
+
getRegistrationStatus(sessionId?: string): Promise<RegistrationStatus>;
|
|
48
|
+
/**
|
|
49
|
+
* Get payment records with pagination.
|
|
50
|
+
*/
|
|
51
|
+
getPaymentRecords(page?: number, perPage?: number, sessionId?: string): Promise<PaginatedResponse<PaymentRecord>>;
|
|
52
|
+
/**
|
|
53
|
+
* Get notifications with pagination.
|
|
54
|
+
*/
|
|
55
|
+
getNotifications(page?: number, perPage?: number, sessionId?: string): Promise<PaginatedResponse<Notification>>;
|
|
56
|
+
/**
|
|
57
|
+
* Fetch the entire SIS dashboard JSON (heavy).
|
|
58
|
+
*/
|
|
59
|
+
getFullDashboard(sessionId?: string): Promise<any>;
|
|
60
|
+
/**
|
|
61
|
+
* List all LMS courses.
|
|
62
|
+
*/
|
|
63
|
+
getLmsCourses(sessionId?: string): Promise<Course[]>;
|
|
64
|
+
/**
|
|
65
|
+
* Get details of a specific course.
|
|
66
|
+
*/
|
|
67
|
+
getCourseContent(courseId: string | number, sessionId?: string): Promise<any>;
|
|
68
|
+
/**
|
|
69
|
+
* Get details of a module within a course.
|
|
70
|
+
*/
|
|
71
|
+
getModuleDetail(modType: string, modId: string | number, sessionId?: string): Promise<ModuleDetail>;
|
|
72
|
+
/**
|
|
73
|
+
* Proxy image URL and return it through MivaX.
|
|
74
|
+
*/
|
|
75
|
+
getProxyImageUrl(encodedUrl: string, sessionId?: string): Promise<string>;
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AACA,OAAO,EACL,YAAY,EACZ,aAAa,EACb,WAAW,EACX,eAAe,EACf,aAAa,EACb,UAAU,EACV,MAAM,EACN,kBAAkB,EAClB,iBAAiB,EACjB,aAAa,EACb,YAAY,EACZ,YAAY,EACb,MAAM,SAAS,CAAC;AAEjB,qBAAa,KAAK;IAChB,OAAO,CAAC,MAAM,CAAgB;IAC9B,OAAO,CAAC,SAAS,CAAuB;gBAE5B,OAAO,CAAC,EAAE,YAAY;IASlC;;OAEG;IACH,YAAY,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI;IAIrC;;OAEG;IACH,YAAY,IAAI,MAAM,GAAG,IAAI;YAIf,OAAO;IAcrB;;OAEG;IACG,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC;IAsBpE,OAAO,CAAC,eAAe;IAOvB;;OAEG;IACG,cAAc,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC;IAQ9D;;OAEG;IACG,kBAAkB,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC;IAQtE;;OAEG;IACG,iBAAiB,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC;IAQrE;;OAEG;IACG,iBAAiB,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;IAQhE;;OAEG;IACG,oBAAoB,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;IAQlF;;OAEG;IACG,iBAAiB,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAQ9D;;OAEG;IACG,qBAAqB,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAQ5E;;OAEG;IACG,iBAAiB,CAAC,IAAI,SAAI,EAAE,OAAO,SAAK,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC,aAAa,CAAC,CAAC;IAS9G;;OAEG;IACG,gBAAgB,CAAC,IAAI,SAAI,EAAE,OAAO,SAAI,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC,YAAY,CAAC,CAAC;IAS3G;;OAEG;IACG,gBAAgB,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC;IAUxD;;OAEG;IACG,aAAa,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAQ1D;;OAEG;IACG,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC;IAQnF;;OAEG;IACG,eAAe,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC;IAQzG;;OAEG;IACG,gBAAgB,CAAC,UAAU,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;CAKhF"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/index.ts
|
|
31
|
+
var index_exports = {};
|
|
32
|
+
__export(index_exports, {
|
|
33
|
+
MivaX: () => MivaX
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(index_exports);
|
|
36
|
+
|
|
37
|
+
// src/client.ts
|
|
38
|
+
var import_axios = __toESM(require("axios"));
|
|
39
|
+
var MivaX = class {
|
|
40
|
+
constructor(options) {
|
|
41
|
+
this.sessionId = null;
|
|
42
|
+
this.client = import_axios.default.create({
|
|
43
|
+
baseURL: (options == null ? void 0 : options.baseUrl) || "https://mivax.marvelly.com.ng",
|
|
44
|
+
headers: {
|
|
45
|
+
"Content-Type": "application/json"
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Set the session ID manually if already authenticated.
|
|
51
|
+
*/
|
|
52
|
+
setSessionId(sessionId) {
|
|
53
|
+
this.sessionId = sessionId;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Get the current session ID.
|
|
57
|
+
*/
|
|
58
|
+
getSessionId() {
|
|
59
|
+
return this.sessionId;
|
|
60
|
+
}
|
|
61
|
+
async request(config) {
|
|
62
|
+
try {
|
|
63
|
+
const response = await this.client.request(config);
|
|
64
|
+
return response.data;
|
|
65
|
+
} catch (error) {
|
|
66
|
+
if (error.response) {
|
|
67
|
+
throw new Error(`MivaX API Error: ${error.response.status} - ${JSON.stringify(error.response.data)}`);
|
|
68
|
+
}
|
|
69
|
+
throw error;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
// Auth Methods
|
|
73
|
+
/**
|
|
74
|
+
* Login to MivaX and set the session ID.
|
|
75
|
+
*/
|
|
76
|
+
async login(email, password) {
|
|
77
|
+
const data = await this.request({
|
|
78
|
+
url: "/login",
|
|
79
|
+
method: "POST",
|
|
80
|
+
data: { email, password }
|
|
81
|
+
});
|
|
82
|
+
if (data.sessionId) {
|
|
83
|
+
this.sessionId = data.sessionId;
|
|
84
|
+
} else if (data.token) {
|
|
85
|
+
this.sessionId = data.token;
|
|
86
|
+
}
|
|
87
|
+
return data;
|
|
88
|
+
}
|
|
89
|
+
// Student (SIS) Methods
|
|
90
|
+
ensureSessionId() {
|
|
91
|
+
if (!this.sessionId) {
|
|
92
|
+
throw new Error("Session ID is required. Please login first or set it manually using setSessionId().");
|
|
93
|
+
}
|
|
94
|
+
return this.sessionId;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Fetch basic student profile from SIS.
|
|
98
|
+
*/
|
|
99
|
+
async getUserProfile(sessionId) {
|
|
100
|
+
const sid = sessionId || this.ensureSessionId();
|
|
101
|
+
return this.request({
|
|
102
|
+
url: `/user/${sid}`,
|
|
103
|
+
method: "GET"
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Get overall CGPA and degree status.
|
|
108
|
+
*/
|
|
109
|
+
async getAcademicSummary(sessionId) {
|
|
110
|
+
const sid = sessionId || this.ensureSessionId();
|
|
111
|
+
return this.request({
|
|
112
|
+
url: `/student/academic-summary/${sid}`,
|
|
113
|
+
method: "GET"
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* List all study years (100L, 200L, etc) with completion summaries.
|
|
118
|
+
*/
|
|
119
|
+
async getAcademicLevels(sessionId) {
|
|
120
|
+
const sid = sessionId || this.ensureSessionId();
|
|
121
|
+
return this.request({
|
|
122
|
+
url: `/student/academic-levels/${sid}`,
|
|
123
|
+
method: "GET"
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Returns results for all academic levels at once.
|
|
128
|
+
*/
|
|
129
|
+
async getFullTranscript(sessionId) {
|
|
130
|
+
const sid = sessionId || this.ensureSessionId();
|
|
131
|
+
return this.request({
|
|
132
|
+
url: `/student/transcript/${sid}`,
|
|
133
|
+
method: "GET"
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Detailed results and GPA for a specific level (e.g., 200_LEVEL).
|
|
138
|
+
*/
|
|
139
|
+
async getTranscriptByLevel(level, sessionId) {
|
|
140
|
+
const sid = sessionId || this.ensureSessionId();
|
|
141
|
+
return this.request({
|
|
142
|
+
url: `/student/transcript/${level}/${sid}`,
|
|
143
|
+
method: "GET"
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* List only the courses currently being taken in the active semester.
|
|
148
|
+
*/
|
|
149
|
+
async getCurrentCourses(sessionId) {
|
|
150
|
+
const sid = sessionId || this.ensureSessionId();
|
|
151
|
+
return this.request({
|
|
152
|
+
url: `/student/current-courses/${sid}`,
|
|
153
|
+
method: "GET"
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Check enrollment windows and pending status.
|
|
158
|
+
*/
|
|
159
|
+
async getRegistrationStatus(sessionId) {
|
|
160
|
+
const sid = sessionId || this.ensureSessionId();
|
|
161
|
+
return this.request({
|
|
162
|
+
url: `/student/registration-status/${sid}`,
|
|
163
|
+
method: "GET"
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Get payment records with pagination.
|
|
168
|
+
*/
|
|
169
|
+
async getPaymentRecords(page = 1, perPage = 10, sessionId) {
|
|
170
|
+
const sid = sessionId || this.ensureSessionId();
|
|
171
|
+
return this.request({
|
|
172
|
+
url: `/payment-records/${sid}`,
|
|
173
|
+
method: "GET",
|
|
174
|
+
params: { page, perPage }
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Get notifications with pagination.
|
|
179
|
+
*/
|
|
180
|
+
async getNotifications(page = 1, perPage = 5, sessionId) {
|
|
181
|
+
const sid = sessionId || this.ensureSessionId();
|
|
182
|
+
return this.request({
|
|
183
|
+
url: `/notifications/${sid}`,
|
|
184
|
+
method: "GET",
|
|
185
|
+
params: { page, perPage }
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Fetch the entire SIS dashboard JSON (heavy).
|
|
190
|
+
*/
|
|
191
|
+
async getFullDashboard(sessionId) {
|
|
192
|
+
const sid = sessionId || this.ensureSessionId();
|
|
193
|
+
return this.request({
|
|
194
|
+
url: `/dashboard/${sid}`,
|
|
195
|
+
method: "GET"
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
// LMS Methods
|
|
199
|
+
/**
|
|
200
|
+
* List all LMS courses.
|
|
201
|
+
*/
|
|
202
|
+
async getLmsCourses(sessionId) {
|
|
203
|
+
const sid = sessionId || this.ensureSessionId();
|
|
204
|
+
return this.request({
|
|
205
|
+
url: `/courses/${sid}`,
|
|
206
|
+
method: "GET"
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* Get details of a specific course.
|
|
211
|
+
*/
|
|
212
|
+
async getCourseContent(courseId, sessionId) {
|
|
213
|
+
const sid = sessionId || this.ensureSessionId();
|
|
214
|
+
return this.request({
|
|
215
|
+
url: `/course/${courseId}/${sid}`,
|
|
216
|
+
method: "GET"
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* Get details of a module within a course.
|
|
221
|
+
*/
|
|
222
|
+
async getModuleDetail(modType, modId, sessionId) {
|
|
223
|
+
const sid = sessionId || this.ensureSessionId();
|
|
224
|
+
return this.request({
|
|
225
|
+
url: `/mod/${modType}/${modId}/${sid}`,
|
|
226
|
+
method: "GET"
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* Proxy image URL and return it through MivaX.
|
|
231
|
+
*/
|
|
232
|
+
async getProxyImageUrl(encodedUrl, sessionId) {
|
|
233
|
+
const sid = sessionId || this.ensureSessionId();
|
|
234
|
+
return `${this.client.defaults.baseURL}/img/${encodedUrl}/${sid}`;
|
|
235
|
+
}
|
|
236
|
+
};
|
|
237
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
238
|
+
0 && (module.exports = {
|
|
239
|
+
MivaX
|
|
240
|
+
});
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
// src/client.ts
|
|
2
|
+
import axios from "axios";
|
|
3
|
+
var MivaX = class {
|
|
4
|
+
constructor(options) {
|
|
5
|
+
this.sessionId = null;
|
|
6
|
+
this.client = axios.create({
|
|
7
|
+
baseURL: (options == null ? void 0 : options.baseUrl) || "https://mivax.marvelly.com.ng",
|
|
8
|
+
headers: {
|
|
9
|
+
"Content-Type": "application/json"
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Set the session ID manually if already authenticated.
|
|
15
|
+
*/
|
|
16
|
+
setSessionId(sessionId) {
|
|
17
|
+
this.sessionId = sessionId;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Get the current session ID.
|
|
21
|
+
*/
|
|
22
|
+
getSessionId() {
|
|
23
|
+
return this.sessionId;
|
|
24
|
+
}
|
|
25
|
+
async request(config) {
|
|
26
|
+
try {
|
|
27
|
+
const response = await this.client.request(config);
|
|
28
|
+
return response.data;
|
|
29
|
+
} catch (error) {
|
|
30
|
+
if (error.response) {
|
|
31
|
+
throw new Error(`MivaX API Error: ${error.response.status} - ${JSON.stringify(error.response.data)}`);
|
|
32
|
+
}
|
|
33
|
+
throw error;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
// Auth Methods
|
|
37
|
+
/**
|
|
38
|
+
* Login to MivaX and set the session ID.
|
|
39
|
+
*/
|
|
40
|
+
async login(email, password) {
|
|
41
|
+
const data = await this.request({
|
|
42
|
+
url: "/login",
|
|
43
|
+
method: "POST",
|
|
44
|
+
data: { email, password }
|
|
45
|
+
});
|
|
46
|
+
if (data.sessionId) {
|
|
47
|
+
this.sessionId = data.sessionId;
|
|
48
|
+
} else if (data.token) {
|
|
49
|
+
this.sessionId = data.token;
|
|
50
|
+
}
|
|
51
|
+
return data;
|
|
52
|
+
}
|
|
53
|
+
// Student (SIS) Methods
|
|
54
|
+
ensureSessionId() {
|
|
55
|
+
if (!this.sessionId) {
|
|
56
|
+
throw new Error("Session ID is required. Please login first or set it manually using setSessionId().");
|
|
57
|
+
}
|
|
58
|
+
return this.sessionId;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Fetch basic student profile from SIS.
|
|
62
|
+
*/
|
|
63
|
+
async getUserProfile(sessionId) {
|
|
64
|
+
const sid = sessionId || this.ensureSessionId();
|
|
65
|
+
return this.request({
|
|
66
|
+
url: `/user/${sid}`,
|
|
67
|
+
method: "GET"
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Get overall CGPA and degree status.
|
|
72
|
+
*/
|
|
73
|
+
async getAcademicSummary(sessionId) {
|
|
74
|
+
const sid = sessionId || this.ensureSessionId();
|
|
75
|
+
return this.request({
|
|
76
|
+
url: `/student/academic-summary/${sid}`,
|
|
77
|
+
method: "GET"
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* List all study years (100L, 200L, etc) with completion summaries.
|
|
82
|
+
*/
|
|
83
|
+
async getAcademicLevels(sessionId) {
|
|
84
|
+
const sid = sessionId || this.ensureSessionId();
|
|
85
|
+
return this.request({
|
|
86
|
+
url: `/student/academic-levels/${sid}`,
|
|
87
|
+
method: "GET"
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Returns results for all academic levels at once.
|
|
92
|
+
*/
|
|
93
|
+
async getFullTranscript(sessionId) {
|
|
94
|
+
const sid = sessionId || this.ensureSessionId();
|
|
95
|
+
return this.request({
|
|
96
|
+
url: `/student/transcript/${sid}`,
|
|
97
|
+
method: "GET"
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Detailed results and GPA for a specific level (e.g., 200_LEVEL).
|
|
102
|
+
*/
|
|
103
|
+
async getTranscriptByLevel(level, sessionId) {
|
|
104
|
+
const sid = sessionId || this.ensureSessionId();
|
|
105
|
+
return this.request({
|
|
106
|
+
url: `/student/transcript/${level}/${sid}`,
|
|
107
|
+
method: "GET"
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* List only the courses currently being taken in the active semester.
|
|
112
|
+
*/
|
|
113
|
+
async getCurrentCourses(sessionId) {
|
|
114
|
+
const sid = sessionId || this.ensureSessionId();
|
|
115
|
+
return this.request({
|
|
116
|
+
url: `/student/current-courses/${sid}`,
|
|
117
|
+
method: "GET"
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Check enrollment windows and pending status.
|
|
122
|
+
*/
|
|
123
|
+
async getRegistrationStatus(sessionId) {
|
|
124
|
+
const sid = sessionId || this.ensureSessionId();
|
|
125
|
+
return this.request({
|
|
126
|
+
url: `/student/registration-status/${sid}`,
|
|
127
|
+
method: "GET"
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Get payment records with pagination.
|
|
132
|
+
*/
|
|
133
|
+
async getPaymentRecords(page = 1, perPage = 10, sessionId) {
|
|
134
|
+
const sid = sessionId || this.ensureSessionId();
|
|
135
|
+
return this.request({
|
|
136
|
+
url: `/payment-records/${sid}`,
|
|
137
|
+
method: "GET",
|
|
138
|
+
params: { page, perPage }
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Get notifications with pagination.
|
|
143
|
+
*/
|
|
144
|
+
async getNotifications(page = 1, perPage = 5, sessionId) {
|
|
145
|
+
const sid = sessionId || this.ensureSessionId();
|
|
146
|
+
return this.request({
|
|
147
|
+
url: `/notifications/${sid}`,
|
|
148
|
+
method: "GET",
|
|
149
|
+
params: { page, perPage }
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Fetch the entire SIS dashboard JSON (heavy).
|
|
154
|
+
*/
|
|
155
|
+
async getFullDashboard(sessionId) {
|
|
156
|
+
const sid = sessionId || this.ensureSessionId();
|
|
157
|
+
return this.request({
|
|
158
|
+
url: `/dashboard/${sid}`,
|
|
159
|
+
method: "GET"
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
// LMS Methods
|
|
163
|
+
/**
|
|
164
|
+
* List all LMS courses.
|
|
165
|
+
*/
|
|
166
|
+
async getLmsCourses(sessionId) {
|
|
167
|
+
const sid = sessionId || this.ensureSessionId();
|
|
168
|
+
return this.request({
|
|
169
|
+
url: `/courses/${sid}`,
|
|
170
|
+
method: "GET"
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Get details of a specific course.
|
|
175
|
+
*/
|
|
176
|
+
async getCourseContent(courseId, sessionId) {
|
|
177
|
+
const sid = sessionId || this.ensureSessionId();
|
|
178
|
+
return this.request({
|
|
179
|
+
url: `/course/${courseId}/${sid}`,
|
|
180
|
+
method: "GET"
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Get details of a module within a course.
|
|
185
|
+
*/
|
|
186
|
+
async getModuleDetail(modType, modId, sessionId) {
|
|
187
|
+
const sid = sessionId || this.ensureSessionId();
|
|
188
|
+
return this.request({
|
|
189
|
+
url: `/mod/${modType}/${modId}/${sid}`,
|
|
190
|
+
method: "GET"
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Proxy image URL and return it through MivaX.
|
|
195
|
+
*/
|
|
196
|
+
async getProxyImageUrl(encodedUrl, sessionId) {
|
|
197
|
+
const sid = sessionId || this.ensureSessionId();
|
|
198
|
+
return `${this.client.defaults.baseURL}/img/${encodedUrl}/${sid}`;
|
|
199
|
+
}
|
|
200
|
+
};
|
|
201
|
+
export {
|
|
202
|
+
MivaX
|
|
203
|
+
};
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
export interface MivaXOptions {
|
|
2
|
+
baseUrl?: string;
|
|
3
|
+
}
|
|
4
|
+
export interface LoginResponse {
|
|
5
|
+
sessionId: string;
|
|
6
|
+
[key: string]: any;
|
|
7
|
+
}
|
|
8
|
+
export interface UserProfile {
|
|
9
|
+
[key: string]: any;
|
|
10
|
+
}
|
|
11
|
+
export interface AcademicSummary {
|
|
12
|
+
cgpa: string | number;
|
|
13
|
+
degreeStatus: string;
|
|
14
|
+
[key: string]: any;
|
|
15
|
+
}
|
|
16
|
+
export interface AcademicLevel {
|
|
17
|
+
level: string;
|
|
18
|
+
completed: boolean;
|
|
19
|
+
[key: string]: any;
|
|
20
|
+
}
|
|
21
|
+
export interface Transcript {
|
|
22
|
+
[key: string]: any;
|
|
23
|
+
}
|
|
24
|
+
export interface Course {
|
|
25
|
+
id: string | number;
|
|
26
|
+
name: string;
|
|
27
|
+
[key: string]: any;
|
|
28
|
+
}
|
|
29
|
+
export interface RegistrationStatus {
|
|
30
|
+
enrolled: boolean;
|
|
31
|
+
[key: string]: any;
|
|
32
|
+
}
|
|
33
|
+
export interface PaymentRecord {
|
|
34
|
+
id: string | number;
|
|
35
|
+
amount: number;
|
|
36
|
+
date: string;
|
|
37
|
+
[key: string]: any;
|
|
38
|
+
}
|
|
39
|
+
export interface Notification {
|
|
40
|
+
id: string | number;
|
|
41
|
+
message: string;
|
|
42
|
+
[key: string]: any;
|
|
43
|
+
}
|
|
44
|
+
export interface ModuleDetail {
|
|
45
|
+
[key: string]: any;
|
|
46
|
+
}
|
|
47
|
+
export interface PaginatedResponse<T> {
|
|
48
|
+
data: T[];
|
|
49
|
+
total?: number;
|
|
50
|
+
page?: number;
|
|
51
|
+
perPage?: number;
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,YAAY;IAC3B,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,aAAa;IAC5B,SAAS,EAAE,MAAM,CAAC;IAClB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB;AAED,MAAM,WAAW,WAAW;IAC1B,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB;AAED,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;IACtB,YAAY,EAAE,MAAM,CAAC;IACrB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB;AAED,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,OAAO,CAAC;IACnB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB;AAED,MAAM,WAAW,UAAU;IACzB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB;AAED,MAAM,WAAW,MAAM;IACrB,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB;AAED,MAAM,WAAW,kBAAkB;IACjC,QAAQ,EAAE,OAAO,CAAC;IAClB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB;AAED,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB;AAED,MAAM,WAAW,YAAY;IAC3B,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB;AAED,MAAM,WAAW,YAAY;IAC3B,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB;AAED,MAAM,WAAW,iBAAiB,CAAC,CAAC;IAClC,IAAI,EAAE,CAAC,EAAE,CAAC;IACV,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB"}
|
package/package.json
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "mivax-sdk",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Node.js SDK for MivaX API",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"module": "./dist/index.mjs",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"files": [
|
|
9
|
+
"dist"
|
|
10
|
+
],
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"types": "./dist/index.d.ts",
|
|
14
|
+
"require": "./dist/index.js",
|
|
15
|
+
"import": "./dist/index.mjs"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
"scripts": {
|
|
19
|
+
"build": "tsup src/index.ts --format cjs,esm --clean && tsc --emitDeclarationOnly --outDir dist",
|
|
20
|
+
"dev": "tsup src/index.ts --format cjs,esm --watch --dts",
|
|
21
|
+
"lint": "tsc",
|
|
22
|
+
"test": "vitest run"
|
|
23
|
+
},
|
|
24
|
+
"keywords": [
|
|
25
|
+
"miva",
|
|
26
|
+
"mivax",
|
|
27
|
+
"sdk",
|
|
28
|
+
"api",
|
|
29
|
+
"education"
|
|
30
|
+
],
|
|
31
|
+
"author": "",
|
|
32
|
+
"license": "MIT",
|
|
33
|
+
"dependencies": {
|
|
34
|
+
"axios": "^1.14.0"
|
|
35
|
+
},
|
|
36
|
+
"devDependencies": {
|
|
37
|
+
"@types/node": "^25.5.0",
|
|
38
|
+
"tsup": "^8.5.1",
|
|
39
|
+
"typescript": "^6.0.2",
|
|
40
|
+
"vitest": "^4.1.2"
|
|
41
|
+
}
|
|
42
|
+
}
|