npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@thu-info/lib

v3.12.0

Published

The JavaScript library that provides a program-friendly interface to Tsinghua web portal

Downloads

25

Readme

@thu-info/lib

Build Status NPM Version

This is a JavaScript library aimed to provide a program-friendly interface to Tsinghua web portal, and is licensed under Business Source License 1.1.

Installation

yarn add @thu-info/lib

Usage

We support a wide range of APIs:

  • getUserInfo
  • getReport
  • Teaching evaluation (getAssessmentList, getAssessmentForm, postAssessmentForm)
  • getPhysicalExamResult
  • getExpenditures
  • Classroom (getClassroomList, getClassroomState)
  • getCalendarImageUrl
  • Invoice (getInvoiceList, getInvoicePDF)
  • loseCard
  • getBankPayment
  • getCalendar
  • getDormScore
  • Electricity (getEleRechargePayCode, getElePayRecord, getEleRemainder)
  • resetDormPassword
  • Library (getLibraryList, getLibrarySectionList, getLibraryFloorList, getLibrarySeatList, bookLibrarySeat, getBookingRecords, cancelBooking)
  • Library room(getLibraryRoomAccNo, loginLibraryRoomBooking, getLibraryRoomBookingResourceList, fuzzySearchLibraryId, bookLibraryRoom, getLibraryRoomBookingRecord, cancelLibraryRoomBooking, updateLibraryRoomEmail)
  • News (getNewsList, searchNewsList, getNewsSubscriptionList, getNewsSourceList, getNewsChannelList, addNewsSubscription, removeNewsSubscription, getNewsListBySubscription, getNewsDetail, addNewsToFavor, removeNewsFromFavor, getFavorNewsList)
  • getSchedule
  • Course Registration (getCrTimetable, getCrCaptchaUrl, loginCr, getCrAvailableSemesters, getCrCoursePlan, searchCrRemaining, searchCrPrimaryOpen, searchCrCourses, selectCourse, deleteCourse, getSelectedCourses, changeCourseWill, getCrCurrentStage, searchCoursePriorityMeta, searchCoursePriorityInformation, getQueueInfo, cancelCoursePF, setCoursePF)
  • Sports (getSportsResources, updateSportsPhoneNumber, getSportsCaptchaUrl, makeSportsReservation, getSportsReservationRecords, paySportsReservation, unsubscribeSportsReservation)
  • Reserves Lib (searchReservesLib, getReservesLibBookDetail, reservesLibDownloadChapters)
  • Network (getNetworkDetail, getOnlineDevices, getNetworkBalance, loginNetworkDevice, logoutNetworkDevice)
  • THOS (getScoreByCourseId)
  • New Campus Card (loginCampusCard, getCampusCardInfo, getCampusCardPhotoUrl, getCampusCardTransactions, changeCampusCardPassword, modifyCampusCardMaxTransactionAmount, reportCampusCardLoss, cancelCampusCardLoss, rechargeCampusCard)

Usages are documented in dist/index and also between the codes.

Quick demo

Download demo.zip from the latest release, and unzip it.

After that, install the unpacked directory demo/ as an unpacked extension in Chrome.

Note: you should have developer-mode enabled in Chrome.

Click on the installed extension thu-info-lib-test and you will see a blank page.

After that, you can open the console of Chrome Developer Tool and execute anything you want in it. The helper class is attached as window.InfoHelper.

Here is a typical example of what you will execute in the browser console.

helper = new InfoHelper.InfoHelper()
helper.login({userId: "", password: ""})

Playground

Before you start

It is recommended that you have Yarn installed.

npm install -g yarn  # Skip this step if you have already used yarn before.

After that, install the dependencies that this project requires.

yarn install

Go on to the corresponding section depending on the JS environment you will be using.

Note that due to various reasons, some operations might fail from time to time. Retrying might solve the problem.

Browsers

Run the following command.

yarn build-dist

You will find a bundled index.js generated in directory demo/.

Follow the steps in section Quick demo and play.

Node.js

Run the following command.

yarn build

You can find the build output in directory dist/.

After that, run command

yarn demo

This will execute script demo.js at the root directory.

You can modify demo.js to perform more requests.

You can also run command

yarn play

to start an interactive JS environment (Node REPL).

A typical example of what you will execute will be

import {InfoHelper} from "./dist";
const helper = new InfoHelper();
await helper.login({userId: "", password: ""});

React Native

See thu-info-app for an example.

Testing

Run yarn test for testing. It requires your personal credential since we don't have mocks for these APIs. To do this, you must create a secrets.json under the root folder, with userId and password as keys.

It's ok if you meet Timeout * Async callback was not invoked within the xxx-ms timeout... error when running tests. Adjusting the third argument timeout of the failing testcase it("xxx", async () => void, timeout) might solve the problem.

Due to various reasons, some test cases might fail. Re-running them might solve the problem.

Acknowledgement

Great thanks to Harry-Chen and his thu-learn-lib!