mirror of
https://github.com/classchartsapi/classcharts-api-js.git
synced 2026-05-14 11:58:13 +00:00
Merge branch 'main' into feat/getCode
This commit is contained in:
commit
53a0ed8310
41 changed files with 661 additions and 5110 deletions
|
|
@ -1,8 +0,0 @@
|
||||||
# Changesets
|
|
||||||
|
|
||||||
Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works
|
|
||||||
with multi-package repos, or single-package repos to help you version and publish your code. You can
|
|
||||||
find the full documentation for it [in our repository](https://github.com/changesets/changesets)
|
|
||||||
|
|
||||||
We have a quick list of common questions to get you started engaging with this project in
|
|
||||||
[our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md)
|
|
||||||
|
|
@ -1,11 +0,0 @@
|
||||||
{
|
|
||||||
"$schema": "https://unpkg.com/@changesets/config@2.3.0/schema.json",
|
|
||||||
"changelog": "@changesets/cli/changelog",
|
|
||||||
"commit": false,
|
|
||||||
"fixed": [],
|
|
||||||
"linked": [],
|
|
||||||
"access": "public",
|
|
||||||
"baseBranch": "main",
|
|
||||||
"updateInternalDependencies": "patch",
|
|
||||||
"ignore": []
|
|
||||||
}
|
|
||||||
|
|
@ -1,5 +0,0 @@
|
||||||
---
|
|
||||||
"classcharts-api": patch
|
|
||||||
---
|
|
||||||
|
|
||||||
Export types first
|
|
||||||
|
|
@ -1,5 +0,0 @@
|
||||||
dist/
|
|
||||||
docs/
|
|
||||||
node_modules/
|
|
||||||
.eslintrc.cjs
|
|
||||||
tsconfig.json
|
|
||||||
|
|
@ -1,10 +0,0 @@
|
||||||
module.exports = {
|
|
||||||
root: true,
|
|
||||||
parser: "@typescript-eslint/parser",
|
|
||||||
plugins: ["@typescript-eslint"],
|
|
||||||
extends: [
|
|
||||||
"eslint:recommended",
|
|
||||||
"plugin:@typescript-eslint/recommended",
|
|
||||||
"prettier",
|
|
||||||
],
|
|
||||||
};
|
|
||||||
1
.gitattributes
vendored
Normal file
1
.gitattributes
vendored
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
*.lock text diff=json
|
||||||
43
.github/workflows/docs.yml
vendored
43
.github/workflows/docs.yml
vendored
|
|
@ -1,43 +0,0 @@
|
||||||
name: Docs
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- main
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
build-docs:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- name: Checkout the repository
|
|
||||||
uses: actions/checkout@v3
|
|
||||||
|
|
||||||
- name: Setup Node.js
|
|
||||||
uses: actions/setup-node@v3
|
|
||||||
with:
|
|
||||||
node-version: 18
|
|
||||||
- uses: pnpm/action-setup@v2
|
|
||||||
with:
|
|
||||||
version: 8.2.0
|
|
||||||
- name: Retrieve the cache
|
|
||||||
uses: actions/cache@v3
|
|
||||||
id: node-cache
|
|
||||||
with:
|
|
||||||
path: node_modules
|
|
||||||
key: node-modules-${{ runner.os }}-${{ hashFiles('pnpm-lock.yaml') }}
|
|
||||||
|
|
||||||
- name: Install dependencies
|
|
||||||
if: steps.node-cache.outputs.cache-hit != 'true'
|
|
||||||
run: pnpm install
|
|
||||||
|
|
||||||
- name: Build
|
|
||||||
run: pnpm run build
|
|
||||||
|
|
||||||
- name: Generate typedoc
|
|
||||||
run: pnpm generateDocs
|
|
||||||
|
|
||||||
- name: Deploy 🚀
|
|
||||||
uses: JamesIves/github-pages-deploy-action@v4
|
|
||||||
with:
|
|
||||||
branch: gh-pages
|
|
||||||
folder: docs
|
|
||||||
43
.github/workflows/release.yml
vendored
43
.github/workflows/release.yml
vendored
|
|
@ -2,9 +2,8 @@ name: Release
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
tags:
|
||||||
- main
|
- "*"
|
||||||
|
|
||||||
concurrency: ${{ github.workflow }}-${{ github.ref }}
|
concurrency: ${{ github.workflow }}-${{ github.ref }}
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
|
@ -14,26 +13,24 @@ jobs:
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout Repo
|
- name: Checkout Repo
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
|
- uses: denoland/setup-deno@v1
|
||||||
- name: Setup Node.js 18.x
|
|
||||||
uses: actions/setup-node@v3
|
|
||||||
with:
|
with:
|
||||||
node-version: 18.x
|
deno-version: v1.36.x
|
||||||
|
- name: Get tag version
|
||||||
- name: Install Dependencies
|
if: startsWith(github.ref, 'refs/tags/')
|
||||||
run: npm install -g pnpm && pnpm install
|
id: get_tag_version
|
||||||
|
run: echo TAG_VERSION=${GITHUB_REF/refs\/tags\//} >> $GITHUB_OUTPUT
|
||||||
- name: Create Release Pull Request or Publish to npm
|
- uses: actions/setup-node@v3
|
||||||
id: changesets
|
|
||||||
uses: changesets/action@v1
|
|
||||||
with:
|
with:
|
||||||
# This expects you to have a script called release which does a build for your packages and calls changeset publish
|
node-version: "18.x"
|
||||||
publish: pnpm release
|
registry-url: "https://registry.npmjs.org"
|
||||||
|
- uses: pnpm/action-setup@v2
|
||||||
|
with:
|
||||||
|
version: 8
|
||||||
|
- name: npm build
|
||||||
|
run: deno task npm ${{steps.get_tag_version.outputs.TAG_VERSION}}
|
||||||
|
- name: npm publish
|
||||||
|
if: startsWith(github.ref, 'refs/tags/')
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||||
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
run: cd npm && npm publish
|
||||||
|
|
||||||
# - name: Send a Slack notification if a publish happens
|
|
||||||
# if: steps.changesets.outputs.published == 'true'
|
|
||||||
# # You can do something when a publish happens.
|
|
||||||
# run: my-slack-bot send-notification --message "A new version of ${GITHUB_REPOSITORY} was published!"
|
|
||||||
|
|
|
||||||
124
.gitignore
vendored
124
.gitignore
vendored
|
|
@ -1,122 +1,2 @@
|
||||||
# Logs
|
npm/
|
||||||
logs
|
.cov/
|
||||||
*.log
|
|
||||||
npm-debug.log*
|
|
||||||
yarn-debug.log*
|
|
||||||
yarn-error.log*
|
|
||||||
lerna-debug.log*
|
|
||||||
.pnpm-debug.log*
|
|
||||||
|
|
||||||
# Diagnostic reports (https://nodejs.org/api/report.html)
|
|
||||||
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
|
|
||||||
|
|
||||||
# Runtime data
|
|
||||||
pids
|
|
||||||
*.pid
|
|
||||||
*.seed
|
|
||||||
*.pid.lock
|
|
||||||
|
|
||||||
# Directory for instrumented libs generated by jscoverage/JSCover
|
|
||||||
lib-cov
|
|
||||||
|
|
||||||
# Coverage directory used by tools like istanbul
|
|
||||||
coverage
|
|
||||||
*.lcov
|
|
||||||
|
|
||||||
# nyc test coverage
|
|
||||||
.nyc_output
|
|
||||||
|
|
||||||
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
|
|
||||||
.grunt
|
|
||||||
|
|
||||||
# Bower dependency directory (https://bower.io/)
|
|
||||||
bower_components
|
|
||||||
|
|
||||||
# node-waf configuration
|
|
||||||
.lock-wscript
|
|
||||||
|
|
||||||
# Compiled binary addons (https://nodejs.org/api/addons.html)
|
|
||||||
build/Release
|
|
||||||
|
|
||||||
# Dependency directories
|
|
||||||
node_modules/
|
|
||||||
jspm_packages/
|
|
||||||
|
|
||||||
# Snowpack dependency directory (https://snowpack.dev/)
|
|
||||||
web_modules/
|
|
||||||
|
|
||||||
# TypeScript cache
|
|
||||||
*.tsbuildinfo
|
|
||||||
|
|
||||||
# Optional npm cache directory
|
|
||||||
.npm
|
|
||||||
|
|
||||||
# Optional eslint cache
|
|
||||||
.eslintcache
|
|
||||||
|
|
||||||
# Microbundle cache
|
|
||||||
.rpt2_cache/
|
|
||||||
.rts2_cache_cjs/
|
|
||||||
.rts2_cache_es/
|
|
||||||
.rts2_cache_umd/
|
|
||||||
|
|
||||||
# Optional REPL history
|
|
||||||
.node_repl_history
|
|
||||||
|
|
||||||
# Output of 'npm pack'
|
|
||||||
*.tgz
|
|
||||||
|
|
||||||
# Yarn Integrity file
|
|
||||||
.yarn-integrity
|
|
||||||
|
|
||||||
# dotenv environment variables file
|
|
||||||
.env
|
|
||||||
.env.test
|
|
||||||
.env.production
|
|
||||||
|
|
||||||
# parcel-bundler cache (https://parceljs.org/)
|
|
||||||
.cache
|
|
||||||
.parcel-cache
|
|
||||||
|
|
||||||
# Next.js build output
|
|
||||||
.next
|
|
||||||
out
|
|
||||||
|
|
||||||
# Nuxt.js build / generate output
|
|
||||||
.nuxt
|
|
||||||
dist
|
|
||||||
|
|
||||||
# Gatsby files
|
|
||||||
.cache/
|
|
||||||
# Comment in the public line in if your project uses Gatsby and not Next.js
|
|
||||||
# https://nextjs.org/blog/next-9-1#public-directory-support
|
|
||||||
# public
|
|
||||||
|
|
||||||
# vuepress build output
|
|
||||||
.vuepress/dist
|
|
||||||
|
|
||||||
# Serverless directories
|
|
||||||
.serverless/
|
|
||||||
|
|
||||||
# FuseBox cache
|
|
||||||
.fusebox/
|
|
||||||
|
|
||||||
# DynamoDB Local files
|
|
||||||
.dynamodb/
|
|
||||||
|
|
||||||
# TernJS port file
|
|
||||||
.tern-port
|
|
||||||
|
|
||||||
# Stores VSCode versions used for testing VSCode extensions
|
|
||||||
.vscode-test
|
|
||||||
|
|
||||||
# yarn v2
|
|
||||||
.yarn/cache
|
|
||||||
.yarn/unplugged
|
|
||||||
.yarn/build-state.yml
|
|
||||||
.yarn/install-state.gz
|
|
||||||
.pnp.*
|
|
||||||
|
|
||||||
tests/config.json
|
|
||||||
|
|
||||||
docs/typedoc
|
|
||||||
|
|
@ -1,6 +0,0 @@
|
||||||
dist/
|
|
||||||
node_modules/
|
|
||||||
pnpm-lock.yaml
|
|
||||||
.prettierrc.json
|
|
||||||
.eslint.js
|
|
||||||
CHANGELOG.md
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
{}
|
|
||||||
4
.vscode/extensions.json
vendored
4
.vscode/extensions.json
vendored
|
|
@ -1,3 +1,5 @@
|
||||||
{
|
{
|
||||||
"recommendations": ["dbaeumer.vscode-eslint", "esbenp.prettier-vscode"]
|
"recommendations": [
|
||||||
|
"denoland.vscode-deno"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
|
|
||||||
4
.vscode/settings.json
vendored
Normal file
4
.vscode/settings.json
vendored
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
{
|
||||||
|
"deno.enable": true,
|
||||||
|
"deno.lint": true
|
||||||
|
}
|
||||||
31
CHANGELOG.md
31
CHANGELOG.md
|
|
@ -1,31 +0,0 @@
|
||||||
# classcharts-api
|
|
||||||
|
|
||||||
## 2.3.0
|
|
||||||
|
|
||||||
### Minor Changes
|
|
||||||
|
|
||||||
- 6552c28: Migrate to native fetch
|
|
||||||
|
|
||||||
## 2.2.0
|
|
||||||
|
|
||||||
### Minor Changes
|
|
||||||
|
|
||||||
- a3e078b: Throw more description JSON parsing errors
|
|
||||||
|
|
||||||
### Patch Changes
|
|
||||||
|
|
||||||
- 350878c: Fixed internal typing typo
|
|
||||||
- 451f800: Specify the required node version
|
|
||||||
|
|
||||||
## 2.1.3
|
|
||||||
|
|
||||||
### Patch Changes
|
|
||||||
|
|
||||||
- 9452422: Require getLesson options argument
|
|
||||||
- 9452422: Tidy up code
|
|
||||||
|
|
||||||
## 2.1.2
|
|
||||||
|
|
||||||
### Patch Changes
|
|
||||||
|
|
||||||
- 0d555e8: Improve documentation
|
|
||||||
47
CONTRIBUTING.md
Normal file
47
CONTRIBUTING.md
Normal file
|
|
@ -0,0 +1,47 @@
|
||||||
|
# Contributing
|
||||||
|
|
||||||
|
Thanks for taking the time to contribute to this project! If you'd like to learn
|
||||||
|
how the API works, check out the (unofficial)
|
||||||
|
[documentation](https://classchartsapi.github.io/api-docs/).
|
||||||
|
|
||||||
|
## Dev Setup
|
||||||
|
|
||||||
|
### Requirements
|
||||||
|
|
||||||
|
- [Deno](https://deno.land/) (for the main development)
|
||||||
|
- [Node.js](https://nodejs.org/en/) (for testing the NPM package)
|
||||||
|
- [pnpm](https://pnpm.io/) (for installing dependencies for the NPM package)
|
||||||
|
|
||||||
|
### Instructions
|
||||||
|
|
||||||
|
To contribute to this repo, you will need to fork the repo first. Click the fork
|
||||||
|
button in the top right corner of the repo page.
|
||||||
|
|
||||||
|
1. Clone your forked repo to your local machine
|
||||||
|
|
||||||
|
```bash
|
||||||
|
git clone https://github.com/<your_github_username>/classcharts-api-js.git
|
||||||
|
cd classcharts-api-js
|
||||||
|
```
|
||||||
|
|
||||||
|
### Testing
|
||||||
|
|
||||||
|
When adding a new function, if you can, add a test for it. Tests are located in
|
||||||
|
`[FILENAME]_test.ts`.\
|
||||||
|
To run the tests, run:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
deno test -A
|
||||||
|
```
|
||||||
|
|
||||||
|
The NPM package will automatically be tested when you build it.
|
||||||
|
|
||||||
|
### Building
|
||||||
|
|
||||||
|
The Deno module is already built but to compile and test the NPM package, run:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
deno task npm 1.0.0
|
||||||
|
```
|
||||||
|
|
||||||
|
Make sure to replace `1.0.0` with the version number.
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
<p align="center">
|
<p align="center">
|
||||||
<h1 align="center">ClassCharts API JS</h1>
|
<h1 align="center">ClassCharts API JS</h1>
|
||||||
<p align="center">
|
<p align="center">
|
||||||
A typescript wrapper for getting information from the Classcharts API
|
A Node.js and Deno wrapper for getting information from the Classcharts API.
|
||||||
</p>
|
</p>
|
||||||
</p>
|
</p>
|
||||||
<p align="center">
|
<p align="center">
|
||||||
|
|
@ -10,27 +10,43 @@
|
||||||
<a href="https://github.com/classchartsapi/classcharts-api-js/issues">Issues</a>
|
<a href="https://github.com/classchartsapi/classcharts-api-js/issues">Issues</a>
|
||||||
<span> • </span>
|
<span> • </span>
|
||||||
<a href="https://www.npmjs.com/package/classcharts-api">NPM</a>
|
<a href="https://www.npmjs.com/package/classcharts-api">NPM</a>
|
||||||
|
<span> • </span>
|
||||||
|
<a href="https://deno.land/x/classcharts_api">Deno</a>
|
||||||
<span> • </span>
|
<span> • </span>
|
||||||
<a href="https://discord.gg/DTcwugcgZ2">Discord</a>
|
<a href="https://discord.gg/DTcwugcgZ2">Discord</a>
|
||||||
<span> • </span>
|
<span> • </span>
|
||||||
<a href="https://classchartsapi.github.io/classcharts-api-js/typedoc/">TypeDoc</a>
|
<a href="https://classchartsapi.github.io/classcharts-api-js">Library Docs</a>
|
||||||
<span> • </span>
|
<span> • </span>
|
||||||
<a href="https://classchartsapi.github.io/api-docs/">API Docs</a>
|
<a href="https://classchartsapi.github.io/api-docs/">API Docs</a>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
# Introduction
|
# Introduction
|
||||||
|
|
||||||
The ClassCharts API is a typescript wrapper around the ClassCharts API. It allows you to easily make requests to the ClassCharts API without having to worry about the underlying implementation of making requests.
|
The ClassCharts API is a typescript wrapper around the ClassCharts API. It
|
||||||
|
allows you to easily make requests to the ClassCharts API without having to
|
||||||
|
worry about the underlying implementation of making requests.
|
||||||
|
|
||||||
## Help
|
## Help
|
||||||
|
|
||||||
For any help with the library, please join the [discord](https://discord.gg/DTcwugcgZ2) where you can ask questions and get help from the community.
|
For any help with the library, please join the
|
||||||
|
[discord](https://discord.gg/DTcwugcgZ2) where you can ask questions and get
|
||||||
|
help from the community.
|
||||||
|
|
||||||
|
# Contributing
|
||||||
|
|
||||||
|
Contributions are welcome! There are lots of API endpoints which we simply do
|
||||||
|
not have access to to implement, so if you have access to them, please consider
|
||||||
|
contributing! If you have any questions, feel free to ask in the
|
||||||
|
[discord](https://discord.gg/DTcwugcgZ2).
|
||||||
|
|
||||||
# Installation
|
# Installation
|
||||||
|
|
||||||
## Requirements
|
## Requirements
|
||||||
|
|
||||||
- Node.js 18 or newer
|
- Node.js 18 or newer
|
||||||
|
\
|
||||||
|
OR
|
||||||
|
- Deno
|
||||||
|
|
||||||
## NPM
|
## NPM
|
||||||
|
|
||||||
|
|
@ -38,17 +54,22 @@ For any help with the library, please join the [discord](https://discord.gg/DTcw
|
||||||
npm install classcharts-api # npm
|
npm install classcharts-api # npm
|
||||||
```
|
```
|
||||||
|
|
||||||
```bash
|
## Deno
|
||||||
yarn add classcharts-api # yarn
|
|
||||||
```
|
|
||||||
|
|
||||||
```bash
|
The imports in the examples are for Node.js, but can easily be substituted for
|
||||||
pnpm add classcharts-api # pnpm
|
Deno.
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
import {
|
||||||
|
ParentClient,
|
||||||
|
StudentClient,
|
||||||
|
} from "https://deno.land/x/classcharts_api/mod.ts";
|
||||||
```
|
```
|
||||||
|
|
||||||
# Logging In
|
# Logging In
|
||||||
|
|
||||||
Before making any requests, you must login to the client. This will get you a session ID which will be used for all requests.
|
Before making any requests, you must login to the client. This will get you a
|
||||||
|
session ID which will be used for all requests.
|
||||||
|
|
||||||
## Student Client
|
## Student Client
|
||||||
|
|
||||||
|
|
@ -62,6 +83,9 @@ await client.login();
|
||||||
|
|
||||||
## Parent Client
|
## Parent Client
|
||||||
|
|
||||||
|
?> The parent client is not tested, as I do not have access to a parent account.
|
||||||
|
If you experience any issues, please open an issue or PR.
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
import { ParentClient } from "classcharts-api";
|
import { ParentClient } from "classcharts-api";
|
||||||
|
|
||||||
|
|
@ -71,7 +95,8 @@ await client.login();
|
||||||
|
|
||||||
# Universal Methods
|
# Universal Methods
|
||||||
|
|
||||||
All the following methods can be used on both the student and parent client. Each example expects the client to be already logged in.
|
All the following methods can be used on both the student and parent client.
|
||||||
|
Each example expects the client to be already logged in.
|
||||||
|
|
||||||
## `.getStudentInfo`
|
## `.getStudentInfo`
|
||||||
|
|
||||||
|
|
@ -176,7 +201,6 @@ console.log(homeworks);
|
||||||
...
|
...
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## `.getLessons`
|
## `.getLessons`
|
||||||
|
|
@ -236,18 +260,33 @@ console.log(badges);
|
||||||
|
|
||||||
## `.getAnnouncements`
|
## `.getAnnouncements`
|
||||||
|
|
||||||
?> This method does not include `meta` in the response, since I do not have access to this endpoint to test it. If you have access to this endpoint, please open a PR to add the `meta` response. Thanks!
|
|
||||||
|
|
||||||
Gets all announcements.
|
Gets all announcements.
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
const announcements = await client.getAnnouncements();
|
const announcements = await client.getAnnouncements();
|
||||||
console.log(announcements);
|
console.log(announcements);
|
||||||
|
|
||||||
|
/**
|
||||||
|
{
|
||||||
|
success: 1,
|
||||||
|
data: [
|
||||||
|
{
|
||||||
|
id: 321453,
|
||||||
|
title: "A big announcement",
|
||||||
|
description: "<p>School will be closing early today!</p>",
|
||||||
|
...
|
||||||
|
}
|
||||||
|
],
|
||||||
|
meta: []
|
||||||
|
}
|
||||||
|
*/
|
||||||
```
|
```
|
||||||
|
|
||||||
## `.getDetentions`
|
## `.getDetentions`
|
||||||
|
|
||||||
?> This method does not include `meta` in the response, since I do not have access to this endpoint to test it. If you have access to this endpoint, please open a PR to add the `meta` response. Thanks!
|
?> This method does not include `meta` in the response, since I do not have
|
||||||
|
access to this endpoint to test it. If you have access to this endpoint, please
|
||||||
|
open a PR to add the `meta` response. Thanks!
|
||||||
|
|
||||||
Gets all detentions.
|
Gets all detentions.
|
||||||
|
|
||||||
|
|
@ -258,7 +297,9 @@ console.log(detentions);
|
||||||
|
|
||||||
## `.getAttendance`
|
## `.getAttendance`
|
||||||
|
|
||||||
?> This method does not include `meta` in the response, since I do not have access to this endpoint to test it. If you have access to this endpoint, please open a PR to add the `meta` response. Thanks!
|
?> This method does not include `meta` in the response, since I do not have
|
||||||
|
access to this endpoint to test it. If you have access to this endpoint, please
|
||||||
|
open a PR to add the `meta` response. Thanks!
|
||||||
|
|
||||||
Gets attendance.
|
Gets attendance.
|
||||||
|
|
||||||
6
deno.jsonc
Normal file
6
deno.jsonc
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
"tasks": {
|
||||||
|
"npm": "deno run -A scripts/build_npm.ts"
|
||||||
|
},
|
||||||
|
"exclude": ["npm"]
|
||||||
|
}
|
||||||
153
deno.lock
generated
Normal file
153
deno.lock
generated
Normal file
|
|
@ -0,0 +1,153 @@
|
||||||
|
{
|
||||||
|
"version": "2",
|
||||||
|
"remote": {
|
||||||
|
"https://deno.land/std@0.140.0/_util/assert.ts": "e94f2eb37cebd7f199952e242c77654e43333c1ac4c5c700e929ea3aa5489f74",
|
||||||
|
"https://deno.land/std@0.140.0/_util/os.ts": "3b4c6e27febd119d36a416d7a97bd3b0251b77c88942c8f16ee5953ea13e2e49",
|
||||||
|
"https://deno.land/std@0.140.0/bytes/bytes_list.ts": "67eb118e0b7891d2f389dad4add35856f4ad5faab46318ff99653456c23b025d",
|
||||||
|
"https://deno.land/std@0.140.0/bytes/equals.ts": "fc16dff2090cced02497f16483de123dfa91e591029f985029193dfaa9d894c9",
|
||||||
|
"https://deno.land/std@0.140.0/bytes/mod.ts": "763f97d33051cc3f28af1a688dfe2830841192a9fea0cbaa55f927b49d49d0bf",
|
||||||
|
"https://deno.land/std@0.140.0/fmt/colors.ts": "30455035d6d728394781c10755351742dd731e3db6771b1843f9b9e490104d37",
|
||||||
|
"https://deno.land/std@0.140.0/fs/_util.ts": "0fb24eb4bfebc2c194fb1afdb42b9c3dda12e368f43e8f2321f84fc77d42cb0f",
|
||||||
|
"https://deno.land/std@0.140.0/fs/ensure_dir.ts": "9dc109c27df4098b9fc12d949612ae5c9c7169507660dcf9ad90631833209d9d",
|
||||||
|
"https://deno.land/std@0.140.0/io/buffer.ts": "bd0c4bf53db4b4be916ca5963e454bddfd3fcd45039041ea161dbf826817822b",
|
||||||
|
"https://deno.land/std@0.140.0/path/_constants.ts": "df1db3ffa6dd6d1252cc9617e5d72165cd2483df90e93833e13580687b6083c3",
|
||||||
|
"https://deno.land/std@0.140.0/path/_interface.ts": "ee3b431a336b80cf445441109d089b70d87d5e248f4f90ff906820889ecf8d09",
|
||||||
|
"https://deno.land/std@0.140.0/path/_util.ts": "c1e9686d0164e29f7d880b2158971d805b6e0efc3110d0b3e24e4b8af2190d2b",
|
||||||
|
"https://deno.land/std@0.140.0/path/common.ts": "bee563630abd2d97f99d83c96c2fa0cca7cee103e8cb4e7699ec4d5db7bd2633",
|
||||||
|
"https://deno.land/std@0.140.0/path/glob.ts": "cb5255638de1048973c3e69e420c77dc04f75755524cb3b2e160fe9277d939ee",
|
||||||
|
"https://deno.land/std@0.140.0/path/mod.ts": "d3e68d0abb393fb0bf94a6d07c46ec31dc755b544b13144dee931d8d5f06a52d",
|
||||||
|
"https://deno.land/std@0.140.0/path/posix.ts": "293cdaec3ecccec0a9cc2b534302dfe308adb6f10861fa183275d6695faace44",
|
||||||
|
"https://deno.land/std@0.140.0/path/separator.ts": "fe1816cb765a8068afb3e8f13ad272351c85cbc739af56dacfc7d93d710fe0f9",
|
||||||
|
"https://deno.land/std@0.140.0/path/win32.ts": "31811536855e19ba37a999cd8d1b62078235548d67902ece4aa6b814596dd757",
|
||||||
|
"https://deno.land/std@0.140.0/streams/conversion.ts": "712585bfa0172a97fb68dd46e784ae8ad59d11b88079d6a4ab098ff42e697d21",
|
||||||
|
"https://deno.land/std@0.181.0/_util/asserts.ts": "178dfc49a464aee693a7e285567b3d0b555dc805ff490505a8aae34f9cfb1462",
|
||||||
|
"https://deno.land/std@0.181.0/_util/os.ts": "d932f56d41e4f6a6093d56044e29ce637f8dcc43c5a90af43504a889cf1775e3",
|
||||||
|
"https://deno.land/std@0.181.0/fs/_util.ts": "65381f341af1ff7f40198cee15c20f59951ac26e51ddc651c5293e24f9ce6f32",
|
||||||
|
"https://deno.land/std@0.181.0/fs/ensure_dir.ts": "dc64c4c75c64721d4e3fb681f1382f803ff3d2868f08563ff923fdd20d071c40",
|
||||||
|
"https://deno.land/std@0.181.0/fs/expand_glob.ts": "e4f56259a0a70fe23f05215b00de3ac5e6ba46646ab2a06ebbe9b010f81c972a",
|
||||||
|
"https://deno.land/std@0.181.0/fs/walk.ts": "ea95ffa6500c1eda6b365be488c056edc7c883a1db41ef46ec3bf057b1c0fe32",
|
||||||
|
"https://deno.land/std@0.181.0/path/_constants.ts": "e49961f6f4f48039c0dfed3c3f93e963ca3d92791c9d478ac5b43183413136e0",
|
||||||
|
"https://deno.land/std@0.181.0/path/_interface.ts": "6471159dfbbc357e03882c2266d21ef9afdb1e4aa771b0545e90db58a0ba314b",
|
||||||
|
"https://deno.land/std@0.181.0/path/_util.ts": "d7abb1e0dea065f427b89156e28cdeb32b045870acdf865833ba808a73b576d0",
|
||||||
|
"https://deno.land/std@0.181.0/path/common.ts": "ee7505ab01fd22de3963b64e46cff31f40de34f9f8de1fff6a1bd2fe79380000",
|
||||||
|
"https://deno.land/std@0.181.0/path/glob.ts": "d479e0a695621c94d3fd7fe7abd4f9499caf32a8de13f25073451c6ef420a4e1",
|
||||||
|
"https://deno.land/std@0.181.0/path/mod.ts": "bf718f19a4fdd545aee1b06409ca0805bd1b68ecf876605ce632e932fe54510c",
|
||||||
|
"https://deno.land/std@0.181.0/path/posix.ts": "8b7c67ac338714b30c816079303d0285dd24af6b284f7ad63da5b27372a2c94d",
|
||||||
|
"https://deno.land/std@0.181.0/path/separator.ts": "0fb679739d0d1d7bf45b68dacfb4ec7563597a902edbaf3c59b50d5bcadd93b1",
|
||||||
|
"https://deno.land/std@0.181.0/path/win32.ts": "d186344e5583bcbf8b18af416d13d82b35a317116e6460a5a3953508c3de5bba",
|
||||||
|
"https://deno.land/std@0.182.0/_util/asserts.ts": "178dfc49a464aee693a7e285567b3d0b555dc805ff490505a8aae34f9cfb1462",
|
||||||
|
"https://deno.land/std@0.182.0/_util/os.ts": "d932f56d41e4f6a6093d56044e29ce637f8dcc43c5a90af43504a889cf1775e3",
|
||||||
|
"https://deno.land/std@0.182.0/fmt/colors.ts": "d67e3cd9f472535241a8e410d33423980bec45047e343577554d3356e1f0ef4e",
|
||||||
|
"https://deno.land/std@0.182.0/fs/_util.ts": "65381f341af1ff7f40198cee15c20f59951ac26e51ddc651c5293e24f9ce6f32",
|
||||||
|
"https://deno.land/std@0.182.0/fs/empty_dir.ts": "c3d2da4c7352fab1cf144a1ecfef58090769e8af633678e0f3fabaef98594688",
|
||||||
|
"https://deno.land/std@0.182.0/fs/expand_glob.ts": "e4f56259a0a70fe23f05215b00de3ac5e6ba46646ab2a06ebbe9b010f81c972a",
|
||||||
|
"https://deno.land/std@0.182.0/fs/walk.ts": "920be35a7376db6c0b5b1caf1486fb962925e38c9825f90367f8f26b5e5d0897",
|
||||||
|
"https://deno.land/std@0.182.0/path/_constants.ts": "e49961f6f4f48039c0dfed3c3f93e963ca3d92791c9d478ac5b43183413136e0",
|
||||||
|
"https://deno.land/std@0.182.0/path/_interface.ts": "6471159dfbbc357e03882c2266d21ef9afdb1e4aa771b0545e90db58a0ba314b",
|
||||||
|
"https://deno.land/std@0.182.0/path/_util.ts": "d7abb1e0dea065f427b89156e28cdeb32b045870acdf865833ba808a73b576d0",
|
||||||
|
"https://deno.land/std@0.182.0/path/common.ts": "ee7505ab01fd22de3963b64e46cff31f40de34f9f8de1fff6a1bd2fe79380000",
|
||||||
|
"https://deno.land/std@0.182.0/path/glob.ts": "d479e0a695621c94d3fd7fe7abd4f9499caf32a8de13f25073451c6ef420a4e1",
|
||||||
|
"https://deno.land/std@0.182.0/path/mod.ts": "bf718f19a4fdd545aee1b06409ca0805bd1b68ecf876605ce632e932fe54510c",
|
||||||
|
"https://deno.land/std@0.182.0/path/posix.ts": "8b7c67ac338714b30c816079303d0285dd24af6b284f7ad63da5b27372a2c94d",
|
||||||
|
"https://deno.land/std@0.182.0/path/separator.ts": "0fb679739d0d1d7bf45b68dacfb4ec7563597a902edbaf3c59b50d5bcadd93b1",
|
||||||
|
"https://deno.land/std@0.182.0/path/win32.ts": "d186344e5583bcbf8b18af416d13d82b35a317116e6460a5a3953508c3de5bba",
|
||||||
|
"https://deno.land/std@0.200.0/assert/_constants.ts": "8a9da298c26750b28b326b297316cdde860bc237533b07e1337c021379e6b2a9",
|
||||||
|
"https://deno.land/std@0.200.0/assert/_diff.ts": "1a3c044aedf77647d6cac86b798c6417603361b66b54c53331b312caeb447aea",
|
||||||
|
"https://deno.land/std@0.200.0/assert/_format.ts": "a69126e8a469009adf4cf2a50af889aca364c349797e63174884a52ff75cf4c7",
|
||||||
|
"https://deno.land/std@0.200.0/assert/assert.ts": "9a97dad6d98c238938e7540736b826440ad8c1c1e54430ca4c4e623e585607ee",
|
||||||
|
"https://deno.land/std@0.200.0/assert/assert_almost_equals.ts": "e15ca1f34d0d5e0afae63b3f5d975cbd18335a132e42b0c747d282f62ad2cd6c",
|
||||||
|
"https://deno.land/std@0.200.0/assert/assert_array_includes.ts": "6856d7f2c3544bc6e62fb4646dfefa3d1df5ff14744d1bca19f0cbaf3b0d66c9",
|
||||||
|
"https://deno.land/std@0.200.0/assert/assert_equals.ts": "d8ec8a22447fbaf2fc9d7c3ed2e66790fdb74beae3e482855d75782218d68227",
|
||||||
|
"https://deno.land/std@0.200.0/assert/assert_exists.ts": "407cb6b9fb23a835cd8d5ad804e2e2edbbbf3870e322d53f79e1c7a512e2efd7",
|
||||||
|
"https://deno.land/std@0.200.0/assert/assert_false.ts": "a9962749f4bf5844e3fa494257f1de73d69e4fe0e82c34d0099287552163a2dc",
|
||||||
|
"https://deno.land/std@0.200.0/assert/assert_instance_of.ts": "09fd297352a5b5bbb16da2b5e1a0d8c6c44da5447772648622dcc7df7af1ddb8",
|
||||||
|
"https://deno.land/std@0.200.0/assert/assert_is_error.ts": "b4eae4e5d182272efc172bf28e2e30b86bb1650cd88aea059e5d2586d4160fb9",
|
||||||
|
"https://deno.land/std@0.200.0/assert/assert_match.ts": "c4083f80600bc190309903c95e397a7c9257ff8b5ae5c7ef91e834704e672e9b",
|
||||||
|
"https://deno.land/std@0.200.0/assert/assert_not_equals.ts": "9f1acab95bd1f5fc9a1b17b8027d894509a745d91bac1718fdab51dc76831754",
|
||||||
|
"https://deno.land/std@0.200.0/assert/assert_not_instance_of.ts": "0c14d3dfd9ab7a5276ed8ed0b18c703d79a3d106102077ec437bfe7ed912bd22",
|
||||||
|
"https://deno.land/std@0.200.0/assert/assert_not_match.ts": "3796a5b0c57a1ce6c1c57883dd4286be13a26f715ea662318ab43a8491a13ab0",
|
||||||
|
"https://deno.land/std@0.200.0/assert/assert_not_strict_equals.ts": "ca6c6d645e95fbc873d25320efeb8c4c6089a9a5e09f92d7c1c4b6e935c2a6ad",
|
||||||
|
"https://deno.land/std@0.200.0/assert/assert_object_match.ts": "d8fc2867cfd92eeacf9cea621e10336b666de1874a6767b5ec48988838370b54",
|
||||||
|
"https://deno.land/std@0.200.0/assert/assert_rejects.ts": "45c59724de2701e3b1f67c391d6c71c392363635aad3f68a1b3408f9efca0057",
|
||||||
|
"https://deno.land/std@0.200.0/assert/assert_strict_equals.ts": "b1f538a7ea5f8348aeca261d4f9ca603127c665e0f2bbfeb91fa272787c87265",
|
||||||
|
"https://deno.land/std@0.200.0/assert/assert_string_includes.ts": "b821d39ebf5cb0200a348863c86d8c4c4b398e02012ce74ad15666fc4b631b0c",
|
||||||
|
"https://deno.land/std@0.200.0/assert/assert_throws.ts": "63784e951475cb7bdfd59878cd25a0931e18f6dc32a6077c454b2cd94f4f4bcd",
|
||||||
|
"https://deno.land/std@0.200.0/assert/assertion_error.ts": "4d0bde9b374dfbcbe8ac23f54f567b77024fb67dbb1906a852d67fe050d42f56",
|
||||||
|
"https://deno.land/std@0.200.0/assert/equal.ts": "9f1a46d5993966d2596c44e5858eec821859b45f783a5ee2f7a695dfc12d8ece",
|
||||||
|
"https://deno.land/std@0.200.0/assert/fail.ts": "c36353d7ae6e1f7933d45f8ea51e358c8c4b67d7e7502028598fe1fea062e278",
|
||||||
|
"https://deno.land/std@0.200.0/assert/mod.ts": "08d55a652c22c5da0215054b21085cec25a5da47ce4a6f9de7d9ad36df35bdee",
|
||||||
|
"https://deno.land/std@0.200.0/assert/unimplemented.ts": "d56fbeecb1f108331a380f72e3e010a1f161baa6956fd0f7cf3e095ae1a4c75a",
|
||||||
|
"https://deno.land/std@0.200.0/assert/unreachable.ts": "4600dc0baf7d9c15a7f7d234f00c23bca8f3eba8b140286aaca7aa998cf9a536",
|
||||||
|
"https://deno.land/std@0.200.0/fmt/colors.ts": "a7eecffdf3d1d54db890723b303847b6e0a1ab4b528ba6958b8f2e754cf1b3bc",
|
||||||
|
"https://deno.land/std@0.201.0/assert/_constants.ts": "8a9da298c26750b28b326b297316cdde860bc237533b07e1337c021379e6b2a9",
|
||||||
|
"https://deno.land/std@0.201.0/assert/_diff.ts": "1a3c044aedf77647d6cac86b798c6417603361b66b54c53331b312caeb447aea",
|
||||||
|
"https://deno.land/std@0.201.0/assert/_format.ts": "a69126e8a469009adf4cf2a50af889aca364c349797e63174884a52ff75cf4c7",
|
||||||
|
"https://deno.land/std@0.201.0/assert/assert.ts": "9a97dad6d98c238938e7540736b826440ad8c1c1e54430ca4c4e623e585607ee",
|
||||||
|
"https://deno.land/std@0.201.0/assert/assert_almost_equals.ts": "e15ca1f34d0d5e0afae63b3f5d975cbd18335a132e42b0c747d282f62ad2cd6c",
|
||||||
|
"https://deno.land/std@0.201.0/assert/assert_array_includes.ts": "6856d7f2c3544bc6e62fb4646dfefa3d1df5ff14744d1bca19f0cbaf3b0d66c9",
|
||||||
|
"https://deno.land/std@0.201.0/assert/assert_equals.ts": "d8ec8a22447fbaf2fc9d7c3ed2e66790fdb74beae3e482855d75782218d68227",
|
||||||
|
"https://deno.land/std@0.201.0/assert/assert_exists.ts": "407cb6b9fb23a835cd8d5ad804e2e2edbbbf3870e322d53f79e1c7a512e2efd7",
|
||||||
|
"https://deno.land/std@0.201.0/assert/assert_false.ts": "a9962749f4bf5844e3fa494257f1de73d69e4fe0e82c34d0099287552163a2dc",
|
||||||
|
"https://deno.land/std@0.201.0/assert/assert_greater.ts": "ae2158a2d19313bf675bf7251d31c6dc52973edb12ac64ac8fc7064152af3e63",
|
||||||
|
"https://deno.land/std@0.201.0/assert/assert_greater_or_equal.ts": "1439da5ebbe20855446cac50097ac78b9742abe8e9a43e7de1ce1426d556e89c",
|
||||||
|
"https://deno.land/std@0.201.0/assert/assert_instance_of.ts": "3aedb3d8186e120812d2b3a5dea66a6e42bf8c57a8bd927645770bd21eea554c",
|
||||||
|
"https://deno.land/std@0.201.0/assert/assert_is_error.ts": "c21113094a51a296ffaf036767d616a78a2ae5f9f7bbd464cd0197476498b94b",
|
||||||
|
"https://deno.land/std@0.201.0/assert/assert_less.ts": "aec695db57db42ec3e2b62e97e1e93db0063f5a6ec133326cc290ff4b71b47e4",
|
||||||
|
"https://deno.land/std@0.201.0/assert/assert_less_or_equal.ts": "5fa8b6a3ffa20fd0a05032fe7257bf985d207b85685fdbcd23651b70f928c848",
|
||||||
|
"https://deno.land/std@0.201.0/assert/assert_match.ts": "c4083f80600bc190309903c95e397a7c9257ff8b5ae5c7ef91e834704e672e9b",
|
||||||
|
"https://deno.land/std@0.201.0/assert/assert_not_equals.ts": "9f1acab95bd1f5fc9a1b17b8027d894509a745d91bac1718fdab51dc76831754",
|
||||||
|
"https://deno.land/std@0.201.0/assert/assert_not_instance_of.ts": "0c14d3dfd9ab7a5276ed8ed0b18c703d79a3d106102077ec437bfe7ed912bd22",
|
||||||
|
"https://deno.land/std@0.201.0/assert/assert_not_match.ts": "3796a5b0c57a1ce6c1c57883dd4286be13a26f715ea662318ab43a8491a13ab0",
|
||||||
|
"https://deno.land/std@0.201.0/assert/assert_not_strict_equals.ts": "ca6c6d645e95fbc873d25320efeb8c4c6089a9a5e09f92d7c1c4b6e935c2a6ad",
|
||||||
|
"https://deno.land/std@0.201.0/assert/assert_object_match.ts": "d8fc2867cfd92eeacf9cea621e10336b666de1874a6767b5ec48988838370b54",
|
||||||
|
"https://deno.land/std@0.201.0/assert/assert_rejects.ts": "45c59724de2701e3b1f67c391d6c71c392363635aad3f68a1b3408f9efca0057",
|
||||||
|
"https://deno.land/std@0.201.0/assert/assert_strict_equals.ts": "b1f538a7ea5f8348aeca261d4f9ca603127c665e0f2bbfeb91fa272787c87265",
|
||||||
|
"https://deno.land/std@0.201.0/assert/assert_string_includes.ts": "b821d39ebf5cb0200a348863c86d8c4c4b398e02012ce74ad15666fc4b631b0c",
|
||||||
|
"https://deno.land/std@0.201.0/assert/assert_throws.ts": "63784e951475cb7bdfd59878cd25a0931e18f6dc32a6077c454b2cd94f4f4bcd",
|
||||||
|
"https://deno.land/std@0.201.0/assert/assertion_error.ts": "4d0bde9b374dfbcbe8ac23f54f567b77024fb67dbb1906a852d67fe050d42f56",
|
||||||
|
"https://deno.land/std@0.201.0/assert/equal.ts": "9f1a46d5993966d2596c44e5858eec821859b45f783a5ee2f7a695dfc12d8ece",
|
||||||
|
"https://deno.land/std@0.201.0/assert/fail.ts": "c36353d7ae6e1f7933d45f8ea51e358c8c4b67d7e7502028598fe1fea062e278",
|
||||||
|
"https://deno.land/std@0.201.0/assert/mod.ts": "37c49a26aae2b254bbe25723434dc28cd7532e444cf0b481a97c045d110ec085",
|
||||||
|
"https://deno.land/std@0.201.0/assert/unimplemented.ts": "d56fbeecb1f108331a380f72e3e010a1f161baa6956fd0f7cf3e095ae1a4c75a",
|
||||||
|
"https://deno.land/std@0.201.0/assert/unreachable.ts": "4600dc0baf7d9c15a7f7d234f00c23bca8f3eba8b140286aaca7aa998cf9a536",
|
||||||
|
"https://deno.land/std@0.201.0/fmt/colors.ts": "87544aa2bc91087bb37f9c077970c85bfb041b48e4c37356129d7b450a415b6f",
|
||||||
|
"https://deno.land/x/code_block_writer@12.0.0/mod.ts": "2c3448060e47c9d08604c8f40dee34343f553f33edcdfebbf648442be33205e5",
|
||||||
|
"https://deno.land/x/code_block_writer@12.0.0/utils/string_utils.ts": "60cb4ec8bd335bf241ef785ccec51e809d576ff8e8d29da43d2273b69ce2a6ff",
|
||||||
|
"https://deno.land/x/deno_cache@0.5.2/auth_tokens.ts": "5d1d56474c54a9d152e44d43ea17c2e6a398dd1e9682c69811a313567c01ee1e",
|
||||||
|
"https://deno.land/x/deno_cache@0.5.2/cache.ts": "92ce8511e1e5c00fdf53a41619aa77d632ea8e0fc711324322e4d5ebf8133911",
|
||||||
|
"https://deno.land/x/deno_cache@0.5.2/deno_dir.ts": "1ea355b8ba11c630d076b222b197cfc937dd81e5a4a260938997da99e8ff93a0",
|
||||||
|
"https://deno.land/x/deno_cache@0.5.2/deps.ts": "26a75905652510b76e54b6d5ef3cf824d1062031e00782efcd768978419224e7",
|
||||||
|
"https://deno.land/x/deno_cache@0.5.2/dirs.ts": "009c6f54e0b610914d6ce9f72f6f6ccfffd2d47a79a19061e0a9eb4253836069",
|
||||||
|
"https://deno.land/x/deno_cache@0.5.2/disk_cache.ts": "66a1e604a8d564b6dd0500326cac33d08b561d331036bf7272def80f2f7952aa",
|
||||||
|
"https://deno.land/x/deno_cache@0.5.2/file_fetcher.ts": "89616c50b6df73fb04e73d0b7cd99e5f2ed7967386913d65b9e8baa4238501f7",
|
||||||
|
"https://deno.land/x/deno_cache@0.5.2/http_cache.ts": "407135eaf2802809ed373c230d57da7ef8dff923c4abf205410b9b99886491fd",
|
||||||
|
"https://deno.land/x/deno_cache@0.5.2/lib/deno_cache_dir.generated.js": "18b6526d0c50791a73dd0eb894e99de1ac05ee79dcbd53298ff5b5b6b0757fe6",
|
||||||
|
"https://deno.land/x/deno_cache@0.5.2/lib/snippets/deno_cache_dir-77bed54ace8005e0/fs.js": "cbe3a976ed63c72c7cb34ef845c27013033a3b11f9d8d3e2c4aa5dda2c0c7af6",
|
||||||
|
"https://deno.land/x/deno_cache@0.5.2/mod.ts": "0b4d071ad095128bdc2b1bc6e5d2095222dcbae08287261690ee9757e6300db6",
|
||||||
|
"https://deno.land/x/deno_cache@0.5.2/util.ts": "f3f5a0cfc60051f09162942fb0ee87a0e27b11a12aec4c22076e3006be4cc1e2",
|
||||||
|
"https://deno.land/x/dir@1.5.1/data_local_dir/mod.ts": "91eb1c4bfadfbeda30171007bac6d85aadacd43224a5ed721bbe56bc64e9eb66",
|
||||||
|
"https://deno.land/x/dnt@0.38.1/lib/compiler.ts": "209ad2e1b294f93f87ec02ade9a0821f942d2e524104552d0aa8ff87021050a5",
|
||||||
|
"https://deno.land/x/dnt@0.38.1/lib/compiler_transforms.ts": "f21aba052f5dcf0b0595c734450842855c7f572e96165d3d34f8fed2fc1f7ba1",
|
||||||
|
"https://deno.land/x/dnt@0.38.1/lib/mod.deps.ts": "30367fc68bcd2acf3b7020cf5cdd26f817f7ac9ac35c4bfb6c4551475f91bc3e",
|
||||||
|
"https://deno.land/x/dnt@0.38.1/lib/npm_ignore.ts": "57fbb7e7b935417d225eec586c6aa240288905eb095847d3f6a88e290209df4e",
|
||||||
|
"https://deno.land/x/dnt@0.38.1/lib/package_json.ts": "61f35b06e374ed39ca776d29d67df4be7ee809d0bca29a8239687556c6d027c2",
|
||||||
|
"https://deno.land/x/dnt@0.38.1/lib/pkg/dnt_wasm.generated.js": "cfb352ae839865f5698c9b35099d4c783510195a1e3c9f9b04d94fac86394ed9",
|
||||||
|
"https://deno.land/x/dnt@0.38.1/lib/pkg/snippets/dnt-wasm-a15ef721fa5290c5/helpers.js": "45f74f00472b3a399bc16e5dc056966b55dcdd8fa2bd61505c6dfd2f5d33b9f4",
|
||||||
|
"https://deno.land/x/dnt@0.38.1/lib/shims.ts": "df1bd4d9a196dca4b2d512b1564fff64ac6c945189a273d706391f87f210d7e6",
|
||||||
|
"https://deno.land/x/dnt@0.38.1/lib/test_runner/get_test_runner_code.ts": "4dc7a73a13b027341c0688df2b29a4ef102f287c126f134c33f69f0339b46968",
|
||||||
|
"https://deno.land/x/dnt@0.38.1/lib/test_runner/test_runner.ts": "4d0da0500ec427d5f390d9a8d42fb882fbeccc92c92d66b6f2e758606dbd40e6",
|
||||||
|
"https://deno.land/x/dnt@0.38.1/lib/transform.deps.ts": "e42f2bdef46d098453bdba19261a67cf90b583f5d868f7fe83113c1380d9b85c",
|
||||||
|
"https://deno.land/x/dnt@0.38.1/lib/types.ts": "b8e228b2fac44c2ae902fbb73b1689f6ab889915bd66486c8a85c0c24255f5fb",
|
||||||
|
"https://deno.land/x/dnt@0.38.1/lib/utils.ts": "878b7ac7003a10c16e6061aa49dbef9b42bd43174853ebffc9b67ea47eeb11d8",
|
||||||
|
"https://deno.land/x/dnt@0.38.1/mod.ts": "b13349fe77847cf58e26b40bcd58797a8cec5d71b31a1ca567071329c8489de1",
|
||||||
|
"https://deno.land/x/dnt@0.38.1/transform.ts": "f68743a14cf9bf53bfc9c81073871d69d447a7f9e3453e0447ca2fb78926bb1d",
|
||||||
|
"https://deno.land/x/ts_morph@18.0.0/bootstrap/mod.ts": "b53aad517f106c4079971fcd4a81ab79fadc40b50061a3ab2b741a09119d51e9",
|
||||||
|
"https://deno.land/x/ts_morph@18.0.0/bootstrap/ts_morph_bootstrap.js": "6645ac03c5e6687dfa8c78109dc5df0250b811ecb3aea2d97c504c35e8401c06",
|
||||||
|
"https://deno.land/x/ts_morph@18.0.0/common/DenoRuntime.ts": "6a7180f0c6e90dcf23ccffc86aa8271c20b1c4f34c570588d08a45880b7e172d",
|
||||||
|
"https://deno.land/x/ts_morph@18.0.0/common/mod.ts": "01985d2ee7da8d1caee318a9d07664774fbee4e31602bc2bb6bb62c3489555ed",
|
||||||
|
"https://deno.land/x/ts_morph@18.0.0/common/ts_morph_common.js": "845671ca951073400ce142f8acefa2d39ea9a51e29ca80928642f3f8cf2b7700",
|
||||||
|
"https://deno.land/x/ts_morph@18.0.0/common/typescript.js": "d5c598b6a2db2202d0428fca5fd79fc9a301a71880831a805d778797d2413c59",
|
||||||
|
"https://deno.land/x/wasmbuild@0.15.0/cache.ts": "89eea5f3ce6035a1164b3e655c95f21300498920575ade23161421f5b01967f4",
|
||||||
|
"https://deno.land/x/wasmbuild@0.15.0/loader.ts": "d98d195a715f823151cbc8baa3f32127337628379a02d9eb2a3c5902dbccfc02"
|
||||||
|
}
|
||||||
|
}
|
||||||
5
deps_dev.ts
Normal file
5
deps_dev.ts
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
export {
|
||||||
|
assertEquals,
|
||||||
|
assertExists,
|
||||||
|
assertRejects,
|
||||||
|
} from "https://deno.land/std@0.201.0/assert/mod.ts";
|
||||||
|
|
@ -4,7 +4,10 @@
|
||||||
<meta charset="UTF-8" />
|
<meta charset="UTF-8" />
|
||||||
<title>ClassCharts-API</title>
|
<title>ClassCharts-API</title>
|
||||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
|
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
|
||||||
<!-- <meta name="description" content="Description"> -->
|
<meta
|
||||||
|
name="description"
|
||||||
|
content="Documentation for classcharts-api javascript package. A library for interacting with the ClassCharts API."
|
||||||
|
/>
|
||||||
<meta
|
<meta
|
||||||
name="viewport"
|
name="viewport"
|
||||||
content="width=device-width, initial-scale=1.0, minimum-scale=1.0"
|
content="width=device-width, initial-scale=1.0, minimum-scale=1.0"
|
||||||
|
|
@ -13,12 +16,6 @@
|
||||||
rel="stylesheet"
|
rel="stylesheet"
|
||||||
href="//cdn.jsdelivr.net/npm/docsify@4/lib/themes/vue.css"
|
href="//cdn.jsdelivr.net/npm/docsify@4/lib/themes/vue.css"
|
||||||
/>
|
/>
|
||||||
<script
|
|
||||||
async
|
|
||||||
src="https://umami.jaminit.co.uk/script.js"
|
|
||||||
data-website-id="3f01674a-5c63-47a2-962b-43d0c62c7c6c"
|
|
||||||
data-domains="classchartsapi.github.io"
|
|
||||||
></script>
|
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="app"></div>
|
<div id="app"></div>
|
||||||
199
jest.config.cjs
199
jest.config.cjs
|
|
@ -1,199 +0,0 @@
|
||||||
/*
|
|
||||||
* For a detailed explanation regarding each configuration property and type check, visit:
|
|
||||||
* https://jestjs.io/docs/configuration
|
|
||||||
*/
|
|
||||||
|
|
||||||
// eslint-disable-next-line no-undef
|
|
||||||
module.exports = {
|
|
||||||
// All imported modules in your tests should be mocked automatically
|
|
||||||
// automock: false,
|
|
||||||
|
|
||||||
// Stop running tests after `n` failures
|
|
||||||
// bail: 0,
|
|
||||||
|
|
||||||
// The directory where Jest should store its cached dependency information
|
|
||||||
// cacheDirectory: "C:\\Users\\User\\AppData\\Local\\Temp\\jest",
|
|
||||||
|
|
||||||
// Automatically clear mock calls, instances and results before every test
|
|
||||||
// clearMocks: false,
|
|
||||||
|
|
||||||
// Indicates whether the coverage information should be collected while executing the test
|
|
||||||
collectCoverage: false,
|
|
||||||
|
|
||||||
// An array of glob patterns indicating a set of files for which coverage information should be collected
|
|
||||||
// collectCoverageFrom: undefined,
|
|
||||||
|
|
||||||
// The directory where Jest should output its coverage files
|
|
||||||
coverageDirectory: "coverage",
|
|
||||||
|
|
||||||
// An array of regexp pattern strings used to skip coverage collection
|
|
||||||
// coveragePathIgnorePatterns: [
|
|
||||||
// "\\\\node_modules\\\\"
|
|
||||||
// ],
|
|
||||||
|
|
||||||
// Indicates which provider should be used to instrument code for coverage
|
|
||||||
coverageProvider: "v8",
|
|
||||||
|
|
||||||
// A list of reporter names that Jest uses when writing coverage reports
|
|
||||||
// coverageReporters: [
|
|
||||||
// "json",
|
|
||||||
// "text",
|
|
||||||
// "lcov",
|
|
||||||
// "clover"
|
|
||||||
// ],
|
|
||||||
|
|
||||||
// An object that configures minimum threshold enforcement for coverage results
|
|
||||||
// coverageThreshold: undefined,
|
|
||||||
|
|
||||||
// A path to a custom dependency extractor
|
|
||||||
// dependencyExtractor: undefined,
|
|
||||||
|
|
||||||
// Make calling deprecated APIs throw helpful error messages
|
|
||||||
// errorOnDeprecated: false,
|
|
||||||
|
|
||||||
// Force coverage collection from ignored files using an array of glob patterns
|
|
||||||
// forceCoverageMatch: [],
|
|
||||||
|
|
||||||
// A path to a module which exports an async function that is triggered once before all test suites
|
|
||||||
// globalSetup: undefined,
|
|
||||||
|
|
||||||
// A path to a module which exports an async function that is triggered once after all test suites
|
|
||||||
// globalTeardown: undefined,
|
|
||||||
|
|
||||||
// A set of global variables that need to be available in all test environments
|
|
||||||
// globals: {},
|
|
||||||
|
|
||||||
// The maximum amount of workers used to run your tests. Can be specified as % or a number. E.g. maxWorkers: 10% will use 10% of your CPU amount + 1 as the maximum worker number. maxWorkers: 2 will use a maximum of 2 workers.
|
|
||||||
// maxWorkers: "50%",
|
|
||||||
|
|
||||||
// An array of directory names to be searched recursively up from the requiring module's location
|
|
||||||
// moduleDirectories: [
|
|
||||||
// "node_modules"
|
|
||||||
// ],
|
|
||||||
|
|
||||||
// An array of file extensions your modules use
|
|
||||||
// moduleFileExtensions: [
|
|
||||||
// "js",
|
|
||||||
// "jsx",
|
|
||||||
// "ts",
|
|
||||||
// "tsx",
|
|
||||||
// "json",
|
|
||||||
// "node"
|
|
||||||
// ],
|
|
||||||
|
|
||||||
// A map from regular expressions to module names or to arrays of module names that allow to stub out resources with a single module
|
|
||||||
// moduleNameMapper: {},
|
|
||||||
|
|
||||||
// An array of regexp pattern strings, matched against all module paths before considered 'visible' to the module loader
|
|
||||||
// modulePathIgnorePatterns: [],
|
|
||||||
|
|
||||||
// Activates notifications for test results
|
|
||||||
// notify: false,
|
|
||||||
|
|
||||||
// An enum that specifies notification mode. Requires { notify: true }
|
|
||||||
// notifyMode: "failure-change",
|
|
||||||
|
|
||||||
// A preset that is used as a base for Jest's configuration
|
|
||||||
// preset: undefined,
|
|
||||||
|
|
||||||
// Run tests from one or more projects
|
|
||||||
// projects: undefined,
|
|
||||||
|
|
||||||
// Use this configuration option to add custom reporters to Jest
|
|
||||||
// reporters: undefined,
|
|
||||||
|
|
||||||
// Automatically reset mock state before every test
|
|
||||||
// resetMocks: false,
|
|
||||||
|
|
||||||
// Reset the module registry before running each individual test
|
|
||||||
// resetModules: false,
|
|
||||||
|
|
||||||
// A path to a custom resolver
|
|
||||||
// resolver: undefined,
|
|
||||||
|
|
||||||
// Automatically restore mock state and implementation before every test
|
|
||||||
// restoreMocks: false,
|
|
||||||
|
|
||||||
// The root directory that Jest should scan for tests and modules within
|
|
||||||
// rootDir: undefined,
|
|
||||||
|
|
||||||
// A list of paths to directories that Jest should use to search for files in
|
|
||||||
// roots: [
|
|
||||||
// "<rootDir>"
|
|
||||||
// ],
|
|
||||||
|
|
||||||
// Allows you to use a custom runner instead of Jest's default test runner
|
|
||||||
// runner: "jest-runner",
|
|
||||||
|
|
||||||
// The paths to modules that run some code to configure or set up the testing environment before each test
|
|
||||||
// setupFiles: [],
|
|
||||||
|
|
||||||
// A list of paths to modules that run some code to configure or set up the testing framework before each test
|
|
||||||
// setupFilesAfterEnv: [],
|
|
||||||
|
|
||||||
// The number of seconds after which a test is considered as slow and reported as such in the results.
|
|
||||||
// slowTestThreshold: 5,
|
|
||||||
|
|
||||||
// A list of paths to snapshot serializer modules Jest should use for snapshot testing
|
|
||||||
// snapshotSerializers: [],
|
|
||||||
|
|
||||||
// The test environment that will be used for testing
|
|
||||||
// testEnvironment: "jest-environment-node",
|
|
||||||
|
|
||||||
// Options that will be passed to the testEnvironment
|
|
||||||
// testEnvironmentOptions: {},
|
|
||||||
|
|
||||||
// Adds a location field to test results
|
|
||||||
// testLocationInResults: false,
|
|
||||||
|
|
||||||
// The glob patterns Jest uses to detect test files
|
|
||||||
// testMatch: [
|
|
||||||
// "**/__tests__/**/*.[jt]s?(x)",
|
|
||||||
// "**/?(*.)+(spec|test).[tj]s?(x)"
|
|
||||||
// ],
|
|
||||||
|
|
||||||
// An array of regexp pattern strings that are matched against all test paths, matched tests are skipped
|
|
||||||
// testPathIgnorePatterns: [
|
|
||||||
// "\\\\node_modules\\\\"
|
|
||||||
// ],
|
|
||||||
|
|
||||||
// The regexp pattern or array of patterns that Jest uses to detect test files
|
|
||||||
// testRegex: [],
|
|
||||||
|
|
||||||
// This option allows the use of a custom results processor
|
|
||||||
// testResultsProcessor: undefined,
|
|
||||||
|
|
||||||
// This option allows use of a custom test runner
|
|
||||||
// testRunner: "jest-circus/runner",
|
|
||||||
|
|
||||||
// This option sets the URL for the jsdom environment. It is reflected in properties such as location.href
|
|
||||||
// testURL: "http://localhost",
|
|
||||||
|
|
||||||
// Setting this value to "fake" allows the use of fake timers for functions such as "setTimeout"
|
|
||||||
// timers: "real",
|
|
||||||
|
|
||||||
// A map from regular expressions to paths to transformers
|
|
||||||
// transform: undefined,
|
|
||||||
|
|
||||||
// An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation
|
|
||||||
// transformIgnorePatterns: [
|
|
||||||
// "\\\\node_modules\\\\",
|
|
||||||
// "\\.pnp\\.[^\\\\]+$"
|
|
||||||
// ],
|
|
||||||
|
|
||||||
// An array of regexp pattern strings that are matched against all modules before the module loader will automatically return a mock for them
|
|
||||||
// unmockedModulePathPatterns: undefined,
|
|
||||||
|
|
||||||
// Indicates whether each individual test should be reported during the run
|
|
||||||
// verbose: undefined,
|
|
||||||
|
|
||||||
// An array of regexp patterns that are matched against all source file paths before re-running tests in watch mode
|
|
||||||
// watchPathIgnorePatterns: [],
|
|
||||||
|
|
||||||
// Whether to use watchman for file crawling
|
|
||||||
// watchman: true,
|
|
||||||
transform: {
|
|
||||||
"^.+\\.(ts|tsx)$": "ts-jest",
|
|
||||||
},
|
|
||||||
setupFilesAfterEnv: ["jest-extended/all"],
|
|
||||||
};
|
|
||||||
2
mod.ts
Normal file
2
mod.ts
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
export * from "./src/core/studentClient.ts";
|
||||||
|
export * from "./src/core/parentClient.ts";
|
||||||
64
package.json
64
package.json
|
|
@ -1,64 +0,0 @@
|
||||||
{
|
|
||||||
"name": "classcharts-api",
|
|
||||||
"type": "module",
|
|
||||||
"version": "2.3.0",
|
|
||||||
"license": "ISC",
|
|
||||||
"author": {
|
|
||||||
"name": "James Cook",
|
|
||||||
"email": "james@jaminit.co.uk"
|
|
||||||
},
|
|
||||||
"description": "A Typescript wrapper for getting information from the ClassCharts API",
|
|
||||||
"keywords": [
|
|
||||||
"node",
|
|
||||||
"typescript",
|
|
||||||
"classcharts",
|
|
||||||
"class charts"
|
|
||||||
],
|
|
||||||
"bugs": {
|
|
||||||
"url": "https://github.com/classchartsapi/classcharts-api-js/issues"
|
|
||||||
},
|
|
||||||
"repository": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "https://github.com/classchartsapi/classcharts-api-js.git"
|
|
||||||
},
|
|
||||||
"homepage": "https://classchartsapi.github.io/classcharts-api-js/",
|
|
||||||
"scripts": {
|
|
||||||
"build": "tsc",
|
|
||||||
"generateDocs": "typedoc --options typedoc.config.cjs",
|
|
||||||
"test": "jest",
|
|
||||||
"release": "pnpm run build && changeset publish"
|
|
||||||
},
|
|
||||||
"devDependencies": {
|
|
||||||
"@changesets/cli": "^2.26.1",
|
|
||||||
"@types/jest": "^29.5.1",
|
|
||||||
"@types/node": "^18.16.3",
|
|
||||||
"@typescript-eslint/eslint-plugin": "^5.59.1",
|
|
||||||
"@typescript-eslint/parser": "^5.59.1",
|
|
||||||
"eslint": "^8.39.0",
|
|
||||||
"eslint-config-prettier": "^8.8.0",
|
|
||||||
"jest": "^29.5.0",
|
|
||||||
"jest-extended": "^3.2.4",
|
|
||||||
"prettier": "^2.8.8",
|
|
||||||
"ts-jest": "^29.1.0",
|
|
||||||
"typedoc": "^0.24.6",
|
|
||||||
"typedoc-plugin-umami": "^1.2.0",
|
|
||||||
"typescript": "^5.0.4"
|
|
||||||
},
|
|
||||||
"main": "./dist/index.js",
|
|
||||||
"types": "./dist/index.d.ts",
|
|
||||||
"exports": {
|
|
||||||
".": {
|
|
||||||
"types": "./dist/index.d.ts",
|
|
||||||
"import": "./dist/index.js",
|
|
||||||
"require": "./dist/index.js"
|
|
||||||
},
|
|
||||||
"./types": "./dist/index.d.ts",
|
|
||||||
"./package.json": "./package.json"
|
|
||||||
},
|
|
||||||
"files": [
|
|
||||||
"dist/**"
|
|
||||||
],
|
|
||||||
"engines": {
|
|
||||||
"node": ">=18"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
4274
pnpm-lock.yaml
generated
4274
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load diff
23
readme.md
23
readme.md
|
|
@ -1,23 +0,0 @@
|
||||||
<h1 align="center">Classcharts API JS</h1>
|
|
||||||
<div align="center">
|
|
||||||
<img alt="Discord" src="https://img.shields.io/discord/918103752068726855">
|
|
||||||
<img alt="npm" src="https://img.shields.io/npm/dm/classcharts-api">
|
|
||||||
<img alt="NPM" src="https://img.shields.io/npm/l/classcharts-api">
|
|
||||||
<img alt="npm" src="https://img.shields.io/npm/v/classcharts-api">
|
|
||||||
<img alt="node-current" src="https://img.shields.io/node/v/classcharts-api">
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<p align="center">A typescript wrapper for getting information from the Classcharts API.</p>
|
|
||||||
|
|
||||||
# Links
|
|
||||||
|
|
||||||
- [Documentation](https://classchartsapi.github.io/classcharts-api-js/)
|
|
||||||
- [Discord](https://discord.gg/DTcwugcgZ2)
|
|
||||||
|
|
||||||
# Contributing
|
|
||||||
|
|
||||||
Contributions are welcome! There are lots of API endpoints which we simply do not have access to to implement, so if you have access to them, please consider contributing! If you have any questions, feel free to ask in the [discord](https://discord.gg/DTcwugcgZ2).
|
|
||||||
|
|
||||||
# Help
|
|
||||||
|
|
||||||
For any help with the library, please join the [discord](https://discord.gg/DTcwugcgZ2) where you can ask questions and get help from the community.
|
|
||||||
54
scripts/build_npm.ts
Normal file
54
scripts/build_npm.ts
Normal file
|
|
@ -0,0 +1,54 @@
|
||||||
|
// This dependancy cannot be moved to dev_deps.ts since dnt complains about a top-level await
|
||||||
|
import { build, emptyDir } from "https://deno.land/x/dnt@0.38.1/mod.ts";
|
||||||
|
|
||||||
|
if (!Deno.args[0]) throw new Error("No version specified");
|
||||||
|
|
||||||
|
await emptyDir("./npm");
|
||||||
|
|
||||||
|
await build({
|
||||||
|
entryPoints: [{
|
||||||
|
name: ".",
|
||||||
|
path: "./mod.ts",
|
||||||
|
}, {
|
||||||
|
name: "./types",
|
||||||
|
path: "./src/types.ts",
|
||||||
|
}],
|
||||||
|
outDir: "./npm",
|
||||||
|
importMap: "./deno.jsonc",
|
||||||
|
shims: {
|
||||||
|
deno: true,
|
||||||
|
},
|
||||||
|
packageManager: "pnpm",
|
||||||
|
compilerOptions: {
|
||||||
|
lib: ["DOM", "ESNext"],
|
||||||
|
},
|
||||||
|
typeCheck: "both",
|
||||||
|
package: {
|
||||||
|
name: "classcharts-api",
|
||||||
|
version: String(Deno.args[0]).replace("v", ""),
|
||||||
|
author: {
|
||||||
|
name: "James Cook",
|
||||||
|
email: "james@jaminit.co.uk",
|
||||||
|
},
|
||||||
|
description:
|
||||||
|
"A Typescript wrapper for getting information from the ClassCharts API",
|
||||||
|
license: "ISC",
|
||||||
|
keywords: ["node", "typescript", "classcharts", "class charts"],
|
||||||
|
bugs: {
|
||||||
|
url: "https://github.com/classchartsapi/classcharts-api-js/issues",
|
||||||
|
},
|
||||||
|
repository: {
|
||||||
|
type: "git",
|
||||||
|
url: "https://github.com/classchartsapi/classcharts-api-js.git",
|
||||||
|
},
|
||||||
|
homepage: "https://classchartsapi.github.io/classcharts-api-js/",
|
||||||
|
engines: {
|
||||||
|
node: ">=18",
|
||||||
|
},
|
||||||
|
sideEffects: false,
|
||||||
|
},
|
||||||
|
postBuild() {
|
||||||
|
Deno.copyFileSync("LICENSE", "npm/LICENSE");
|
||||||
|
Deno.copyFileSync("README.md", "npm/README.md");
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
@ -17,12 +17,12 @@ import type {
|
||||||
GetStudentInfoResponse,
|
GetStudentInfoResponse,
|
||||||
HomeworksResponse,
|
HomeworksResponse,
|
||||||
LessonsResponse,
|
LessonsResponse,
|
||||||
} from "../types.js";
|
PupilFieldsResponse,
|
||||||
import { PING_INTERVAL } from "../utils/consts.js";
|
} from "../types.ts";
|
||||||
|
import { PING_INTERVAL } from "../utils/consts.ts";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Shared client for both parent and student. This is not exported and should not be used directly
|
* Shared client for both parent and student. This is not exported and should not be used directly
|
||||||
* @internal
|
|
||||||
*/
|
*/
|
||||||
export class BaseClient {
|
export class BaseClient {
|
||||||
/**
|
/**
|
||||||
|
|
@ -30,7 +30,6 @@ export class BaseClient {
|
||||||
*/
|
*/
|
||||||
public studentId = 0;
|
public studentId = 0;
|
||||||
/**
|
/**
|
||||||
* @internal
|
|
||||||
* @property authCookies Cookies used for authentication (set during login and can be empty)
|
* @property authCookies Cookies used for authentication (set during login and can be empty)
|
||||||
*/
|
*/
|
||||||
public authCookies: Array<string>;
|
public authCookies: Array<string>;
|
||||||
|
|
@ -44,11 +43,9 @@ export class BaseClient {
|
||||||
public lastPing = 0;
|
public lastPing = 0;
|
||||||
/**
|
/**
|
||||||
* @property API_BASE Base API URL, this is different depending on if its called as a parent or student
|
* @property API_BASE Base API URL, this is different depending on if its called as a parent or student
|
||||||
* @internal
|
|
||||||
*/
|
*/
|
||||||
protected API_BASE = "";
|
protected API_BASE = "";
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @param API_BASE Base API URL, this is different depending on if its called as a parent or student
|
* @param API_BASE Base API URL, this is different depending on if its called as a parent or student
|
||||||
*/
|
*/
|
||||||
constructor(API_BASE: string) {
|
constructor(API_BASE: string) {
|
||||||
|
|
@ -59,7 +56,6 @@ export class BaseClient {
|
||||||
* Revalidates the session ID.
|
* Revalidates the session ID.
|
||||||
*
|
*
|
||||||
* This is called automatically when the session ID is older than 3 minutes or when initially using the .login() method
|
* This is called automatically when the session ID is older than 3 minutes or when initially using the .login() method
|
||||||
* @internal
|
|
||||||
*/
|
*/
|
||||||
public async getNewSessionId() {
|
public async getNewSessionId() {
|
||||||
const pingFormData = new URLSearchParams();
|
const pingFormData = new URLSearchParams();
|
||||||
|
|
@ -70,7 +66,7 @@ export class BaseClient {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
body: pingFormData,
|
body: pingFormData,
|
||||||
},
|
},
|
||||||
{ revalidateToken: false }
|
{ revalidateToken: false },
|
||||||
);
|
);
|
||||||
this.sessionId = pingData.meta.session_id;
|
this.sessionId = pingData.meta.session_id;
|
||||||
this.lastPing = Date.now();
|
this.lastPing = Date.now();
|
||||||
|
|
@ -79,17 +75,16 @@ export class BaseClient {
|
||||||
* Makes a request to the ClassCharts API with the required authentication headers
|
* Makes a request to the ClassCharts API with the required authentication headers
|
||||||
*
|
*
|
||||||
* @param path Path to the API endpoint
|
* @param path Path to the API endpoint
|
||||||
* @param kyOptions Ky (fetch library) request options
|
* @param fetchOptions Request Options
|
||||||
* @param options
|
* @param options
|
||||||
* @param options.revalidateToken Whether to revalidate the session ID if it is older than 3 minutes
|
* @param options.revalidateToken Whether to revalidate the session ID if it is older than 3 minutes
|
||||||
*
|
*
|
||||||
* @returns Response
|
* @returns Response
|
||||||
* @internal
|
|
||||||
*/
|
*/
|
||||||
public async makeAuthedRequest(
|
public async makeAuthedRequest(
|
||||||
path: string,
|
path: string,
|
||||||
fetchOptions: RequestInit,
|
fetchOptions: RequestInit,
|
||||||
options?: { revalidateToken?: boolean }
|
options?: { revalidateToken?: boolean },
|
||||||
) {
|
) {
|
||||||
if (!this.sessionId) throw new Error("No session ID");
|
if (!this.sessionId) throw new Error("No session ID");
|
||||||
if (!options) {
|
if (!options) {
|
||||||
|
|
@ -112,19 +107,19 @@ export class BaseClient {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const request = await fetch(path, requestOptions);
|
const request = await fetch(path, requestOptions);
|
||||||
let responseJSON: ClassChartsResponse<unknown, unknown>;
|
// deno-lint-ignore no-explicit-any
|
||||||
|
let responseJSON: ClassChartsResponse<any, any>;
|
||||||
try {
|
try {
|
||||||
responseJSON = await request.json();
|
responseJSON = await request.json();
|
||||||
} catch (err) {
|
} catch {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
"Error parsing JSON. Returned response: " + (await request.text())
|
"Error parsing JSON. Returned response: " + (await request.text()),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (responseJSON.success == 0) {
|
if (responseJSON.success == 0) {
|
||||||
throw new Error(responseJSON.error);
|
throw new Error(responseJSON.error);
|
||||||
}
|
}
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
return responseJSON;
|
||||||
return responseJSON as any;
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Gets general information about the current student
|
* Gets general information about the current student
|
||||||
|
|
@ -133,11 +128,10 @@ export class BaseClient {
|
||||||
async getStudentInfo(): Promise<GetStudentInfoResponse> {
|
async getStudentInfo(): Promise<GetStudentInfoResponse> {
|
||||||
const body = new URLSearchParams();
|
const body = new URLSearchParams();
|
||||||
body.append("include_data", "true");
|
body.append("include_data", "true");
|
||||||
const data = await this.makeAuthedRequest(this.API_BASE + "/ping", {
|
return await this.makeAuthedRequest(this.API_BASE + "/ping", {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
body: body,
|
body: body,
|
||||||
});
|
});
|
||||||
return data;
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Gets the current student's activity
|
* Gets the current student's activity
|
||||||
|
|
@ -152,11 +146,11 @@ export class BaseClient {
|
||||||
options?.from && params.append("from", options?.from);
|
options?.from && params.append("from", options?.from);
|
||||||
options?.to && params.append("to", options?.to);
|
options?.to && params.append("to", options?.to);
|
||||||
options?.last_id && params.append("last_id", options?.last_id);
|
options?.last_id && params.append("last_id", options?.last_id);
|
||||||
return this.makeAuthedRequest(
|
return await this.makeAuthedRequest(
|
||||||
this.API_BASE + "/activity/" + this.studentId + "?" + params.toString(),
|
this.API_BASE + "/activity/" + this.studentId + "?" + params.toString(),
|
||||||
{
|
{
|
||||||
method: "GET",
|
method: "GET",
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
|
@ -168,7 +162,7 @@ export class BaseClient {
|
||||||
* @see getActivity
|
* @see getActivity
|
||||||
*/
|
*/
|
||||||
async getFullActivity(
|
async getFullActivity(
|
||||||
options: GetFullActivityOptions
|
options: GetFullActivityOptions,
|
||||||
): Promise<ActivityResponse["data"]> {
|
): Promise<ActivityResponse["data"]> {
|
||||||
let data: ActivityResponse["data"] = [];
|
let data: ActivityResponse["data"] = [];
|
||||||
let prevLast: number | undefined;
|
let prevLast: number | undefined;
|
||||||
|
|
@ -197,7 +191,7 @@ export class BaseClient {
|
||||||
* @returns Array of behaviour points
|
* @returns Array of behaviour points
|
||||||
*/
|
*/
|
||||||
async getBehaviour(
|
async getBehaviour(
|
||||||
options?: GetBehaviourOptions
|
options?: GetBehaviourOptions,
|
||||||
): Promise<BehaviourResponse> {
|
): Promise<BehaviourResponse> {
|
||||||
const params = new URLSearchParams();
|
const params = new URLSearchParams();
|
||||||
options?.from && params.append("from", options?.from);
|
options?.from && params.append("from", options?.from);
|
||||||
|
|
@ -206,7 +200,7 @@ export class BaseClient {
|
||||||
this.API_BASE + "/behaviour/" + this.studentId + "?" + params.toString(),
|
this.API_BASE + "/behaviour/" + this.studentId + "?" + params.toString(),
|
||||||
{
|
{
|
||||||
method: "GET",
|
method: "GET",
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
|
@ -216,32 +210,18 @@ export class BaseClient {
|
||||||
*/
|
*/
|
||||||
async getHomeworks(options?: GetHomeworkOptions): Promise<HomeworksResponse> {
|
async getHomeworks(options?: GetHomeworkOptions): Promise<HomeworksResponse> {
|
||||||
const params = new URLSearchParams();
|
const params = new URLSearchParams();
|
||||||
if (options?.displayDate)
|
if (options?.displayDate) {
|
||||||
params.append("display_date", String(options?.displayDate));
|
params.append("display_date", String(options?.displayDate));
|
||||||
|
}
|
||||||
|
|
||||||
options?.from && params.append("from", String(options?.from));
|
options?.from && params.append("from", String(options?.from));
|
||||||
options?.to && params.append("to", String(options?.to));
|
options?.to && params.append("to", String(options?.to));
|
||||||
const data: HomeworksResponse = await this.makeAuthedRequest(
|
return await this.makeAuthedRequest(
|
||||||
this.API_BASE + "/homeworks/" + this.studentId + "?" + params.toString(),
|
this.API_BASE + "/homeworks/" + this.studentId + "?" + params.toString(),
|
||||||
{
|
{
|
||||||
method: "GET",
|
method: "GET",
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
for (let i = 0; i < data.data.length; i++) {
|
|
||||||
data.data[i].description_raw = data.data[i].description;
|
|
||||||
// homework.lesson.replace(/\\/g, '')
|
|
||||||
data.data[i].description = data.data[i].description.replace(
|
|
||||||
/(<([^>]+)>)/gi,
|
|
||||||
""
|
|
||||||
);
|
|
||||||
data.data[i].description = data.data[i].description.replace(
|
|
||||||
/ /g,
|
|
||||||
""
|
|
||||||
);
|
|
||||||
data.data[i].description = data.data[i].description.trim();
|
|
||||||
}
|
|
||||||
return data;
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Gets the current student's lessons for a given date
|
* Gets the current student's lessons for a given date
|
||||||
|
|
@ -256,7 +236,7 @@ export class BaseClient {
|
||||||
this.API_BASE + "/timetable/" + this.studentId + "?" + params.toString(),
|
this.API_BASE + "/timetable/" + this.studentId + "?" + params.toString(),
|
||||||
{
|
{
|
||||||
method: "GET",
|
method: "GET",
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
|
@ -268,7 +248,7 @@ export class BaseClient {
|
||||||
this.API_BASE + "/eventbadges/" + this.studentId,
|
this.API_BASE + "/eventbadges/" + this.studentId,
|
||||||
{
|
{
|
||||||
method: "GET",
|
method: "GET",
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
|
@ -276,28 +256,24 @@ export class BaseClient {
|
||||||
* @returns Array of announcements
|
* @returns Array of announcements
|
||||||
*/
|
*/
|
||||||
async getAnnouncements(): Promise<AnnouncementsResponse> {
|
async getAnnouncements(): Promise<AnnouncementsResponse> {
|
||||||
return (
|
return await this.makeAuthedRequest(
|
||||||
await this.makeAuthedRequest(
|
|
||||||
this.API_BASE + "/announcements/" + this.studentId,
|
this.API_BASE + "/announcements/" + this.studentId,
|
||||||
{
|
{
|
||||||
method: "GET",
|
method: "GET",
|
||||||
}
|
},
|
||||||
)
|
);
|
||||||
).data;
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Gets the current student's detentions
|
* Gets the current student's detentions
|
||||||
* @returns Array of detentions
|
* @returns Array of detentions
|
||||||
*/
|
*/
|
||||||
async getDetentions(): Promise<DetentionsResponse> {
|
async getDetentions(): Promise<DetentionsResponse> {
|
||||||
return (
|
return await this.makeAuthedRequest(
|
||||||
await this.makeAuthedRequest(
|
|
||||||
this.API_BASE + "/detentions/" + this.studentId,
|
this.API_BASE + "/detentions/" + this.studentId,
|
||||||
{
|
{
|
||||||
method: "GET",
|
method: "GET",
|
||||||
}
|
},
|
||||||
)
|
);
|
||||||
).data;
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Gets the current student's attendance
|
* Gets the current student's attendance
|
||||||
|
|
@ -305,13 +281,12 @@ export class BaseClient {
|
||||||
* @returns Array of dates of attendance
|
* @returns Array of dates of attendance
|
||||||
*/
|
*/
|
||||||
async getAttendance(
|
async getAttendance(
|
||||||
options?: GetAttendanceOptions
|
options?: GetAttendanceOptions,
|
||||||
): Promise<AttendanceResponse> {
|
): Promise<AttendanceResponse> {
|
||||||
const params = new URLSearchParams();
|
const params = new URLSearchParams();
|
||||||
options?.from && params.append("from", options?.from);
|
options?.from && params.append("from", options?.from);
|
||||||
options?.to && params.append("to", options?.to);
|
options?.to && params.append("to", options?.to);
|
||||||
return (
|
return await this.makeAuthedRequest(
|
||||||
await this.makeAuthedRequest(
|
|
||||||
this.API_BASE +
|
this.API_BASE +
|
||||||
"/attendance/" +
|
"/attendance/" +
|
||||||
this.studentId +
|
this.studentId +
|
||||||
|
|
@ -319,9 +294,20 @@ export class BaseClient {
|
||||||
params.toString(),
|
params.toString(),
|
||||||
{
|
{
|
||||||
method: "GET",
|
method: "GET",
|
||||||
|
},
|
||||||
|
);
|
||||||
}
|
}
|
||||||
)
|
/**
|
||||||
).data;
|
* Gets the current student's pupil fields
|
||||||
|
* @returns Array of stats
|
||||||
|
*/
|
||||||
|
async getPupilFields(): Promise<PupilFieldsResponse> {
|
||||||
|
return await this.makeAuthedRequest(
|
||||||
|
this.API_BASE + "/customfields/" + this.studentId,
|
||||||
|
{
|
||||||
|
method: "GET",
|
||||||
|
},
|
||||||
|
);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Gets the current student's code
|
* Gets the current student's code
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
import type { GetPupilsResponse } from "../types.js";
|
import type { GetPupilsResponse } from "../types.ts";
|
||||||
|
|
||||||
import { BaseClient } from "./baseClient.js";
|
import { BaseClient } from "../core/baseClient.ts";
|
||||||
import { API_BASE_PARENT, BASE_URL } from "../utils/consts.js";
|
import { API_BASE_PARENT, BASE_URL } from "../utils/consts.ts";
|
||||||
import { parseCookies } from "../utils/utils.js";
|
import { parseCookies } from "../utils/utils.ts";
|
||||||
/**
|
/**
|
||||||
* Parent Client
|
* Parent Client
|
||||||
*/
|
*/
|
||||||
|
|
@ -12,7 +12,6 @@ export class ParentClient extends BaseClient {
|
||||||
// @ts-expect-error Init in .login
|
// @ts-expect-error Init in .login
|
||||||
public pupils: GetPupilsResponse;
|
public pupils: GetPupilsResponse;
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @param email Parent's email address
|
* @param email Parent's email address
|
||||||
* @param password Parent's password
|
* @param password Parent's password
|
||||||
*/
|
*/
|
||||||
|
|
@ -26,7 +25,8 @@ export class ParentClient extends BaseClient {
|
||||||
* Authenticates with ClassCharts
|
* Authenticates with ClassCharts
|
||||||
*/
|
*/
|
||||||
async login(): Promise<void> {
|
async login(): Promise<void> {
|
||||||
if (!this.email) throw new Error("Email not inputted");
|
if (!this.email) throw new Error("Email not provided");
|
||||||
|
if (!this.password) throw new Error("Password not provided");
|
||||||
const formData = new URLSearchParams();
|
const formData = new URLSearchParams();
|
||||||
formData.append("_method", "POST");
|
formData.append("_method", "POST");
|
||||||
formData.append("email", this.email);
|
formData.append("email", this.email);
|
||||||
|
|
@ -40,35 +40,35 @@ export class ParentClient extends BaseClient {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
body: formData,
|
body: formData,
|
||||||
headers: headers,
|
headers: headers,
|
||||||
credentials: undefined,
|
redirect: "manual",
|
||||||
});
|
});
|
||||||
if (response.status != 302 || !response.headers.get("set-cookie"))
|
if (response.status != 302 || !response.headers.has("set-cookie")) {
|
||||||
|
await response.body?.cancel(); // Make deno tests happy by closing the body, unsure whether this is needed for the actual library
|
||||||
throw new Error(
|
throw new Error(
|
||||||
"Unauthenticated: ClassCharts returned an error: " +
|
"Unauthenticated: ClassCharts didn't return authentication cookies",
|
||||||
response.status +
|
|
||||||
" " +
|
|
||||||
response.statusText
|
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
const cookies = String(response.headers.get("set-cookie"));
|
const cookies = String(response.headers.get("set-cookie"));
|
||||||
// this.authCookies = cookies.split(";");
|
// this.authCookies = cookies.split(";");
|
||||||
const sessionCookies = parseCookies(cookies);
|
const sessionCookies = parseCookies(cookies);
|
||||||
const sessionID = JSON.parse(
|
const sessionID = JSON.parse(
|
||||||
String(sessionCookies["parent_session_credentials"])
|
String(sessionCookies["parent_session_credentials"]),
|
||||||
);
|
);
|
||||||
super.sessionId = sessionID.session_id;
|
this.sessionId = sessionID.session_id;
|
||||||
this.pupils = await this.getPupils();
|
this.pupils = await this.getPupils();
|
||||||
if (!this.pupils) throw new Error("Account has no pupils attached");
|
if (!this.pupils) throw new Error("Account has no pupils attached");
|
||||||
super.studentId = this.pupils[0].id;
|
this.studentId = this.pupils[0].id;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Get a list of pupils connected to this parent's account
|
* Get a list of pupils connected to this parent's account
|
||||||
* @returns an array of Pupils connected to this parent's account
|
* @returns an array of Pupils connected to this parent's account
|
||||||
*/
|
*/
|
||||||
async getPupils(): Promise<GetPupilsResponse> {
|
async getPupils(): Promise<GetPupilsResponse> {
|
||||||
return super.makeAuthedRequest(super.API_BASE + "/pupils", {
|
const response = await this.makeAuthedRequest(this.API_BASE + "/pupils", {
|
||||||
method: "GET",
|
method: "GET",
|
||||||
});
|
});
|
||||||
|
return response.data;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Selects a pupil to be used with API requests
|
* Selects a pupil to be used with API requests
|
||||||
|
|
@ -76,13 +76,13 @@ export class ParentClient extends BaseClient {
|
||||||
*
|
*
|
||||||
* @see getPupils
|
* @see getPupils
|
||||||
*/
|
*/
|
||||||
async selectPupil(pupilId: number): Promise<void> {
|
selectPupil(pupilId: number) {
|
||||||
if (!pupilId) throw new Error("No pupil ID specified");
|
if (!pupilId) throw new Error("No pupil ID specified");
|
||||||
const pupils = this.pupils;
|
const pupils = this.pupils;
|
||||||
for (let i = 0; i < pupils.length; i++) {
|
for (let i = 0; i < pupils.length; i++) {
|
||||||
const pupil = pupils[i];
|
const pupil = pupils[i];
|
||||||
if (pupil.id == pupilId) {
|
if (pupil.id == pupilId) {
|
||||||
super.studentId = pupil.id;
|
this.studentId = pupil.id;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
35
src/core/parentClient_test.ts
Normal file
35
src/core/parentClient_test.ts
Normal file
|
|
@ -0,0 +1,35 @@
|
||||||
|
import { assertRejects } from "../../deps_dev.ts";
|
||||||
|
import { ParentClient } from "../core/parentClient.ts";
|
||||||
|
|
||||||
|
Deno.test("Throws when no email is provided", async () => {
|
||||||
|
const client = new ParentClient("", "password");
|
||||||
|
await assertRejects(
|
||||||
|
async () => {
|
||||||
|
await client.login();
|
||||||
|
},
|
||||||
|
Error,
|
||||||
|
"Email not provided",
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
Deno.test("Throws when no password is provided", async () => {
|
||||||
|
const client = new ParentClient("email", "");
|
||||||
|
await assertRejects(
|
||||||
|
async () => {
|
||||||
|
await client.login();
|
||||||
|
},
|
||||||
|
Error,
|
||||||
|
"Password not provided",
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
Deno.test("Throws with invalid username and password", async () => {
|
||||||
|
const client = new ParentClient("invalid", "invalid");
|
||||||
|
await assertRejects(
|
||||||
|
async () => {
|
||||||
|
await client.login();
|
||||||
|
},
|
||||||
|
Error,
|
||||||
|
"Unauthenticated: ClassCharts didn't return authentication cookies",
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
import { API_BASE_STUDENT, BASE_URL } from "../utils/consts.js";
|
import { API_BASE_STUDENT, BASE_URL } from "../utils/consts.ts";
|
||||||
import { BaseClient } from "./baseClient.js";
|
import { BaseClient } from "../core/baseClient.ts";
|
||||||
import { parseCookies } from "../utils/utils.js";
|
import { parseCookies } from "../utils/utils.ts";
|
||||||
|
import { RewardPurchaseResponse, RewardsResponse } from "../types.ts";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Student Client
|
* Student Client
|
||||||
|
|
@ -8,17 +9,14 @@ import { parseCookies } from "../utils/utils.js";
|
||||||
export class StudentClient extends BaseClient {
|
export class StudentClient extends BaseClient {
|
||||||
/**
|
/**
|
||||||
* @property studentCode ClassCharts student code
|
* @property studentCode ClassCharts student code
|
||||||
* @internal
|
|
||||||
*/
|
*/
|
||||||
private studentCode = "";
|
private studentCode = "";
|
||||||
/**
|
/**
|
||||||
* @property dateOfBirth Student's date of birth
|
* @property dateOfBirth Student's date of birth
|
||||||
* @internal
|
|
||||||
*/
|
*/
|
||||||
private dateOfBirth = "";
|
private dateOfBirth = "";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @param studentCode ClassCharts student code
|
* @param studentCode ClassCharts student code
|
||||||
* @param dateOfBirth Student's date of birth
|
* @param dateOfBirth Student's date of birth
|
||||||
*/
|
*/
|
||||||
|
|
@ -32,7 +30,7 @@ export class StudentClient extends BaseClient {
|
||||||
* Authenticates with ClassCharts
|
* Authenticates with ClassCharts
|
||||||
*/
|
*/
|
||||||
async login(): Promise<void> {
|
async login(): Promise<void> {
|
||||||
if (!this.studentCode) throw new Error("Student Code not inputted");
|
if (!this.studentCode) throw new Error("Student Code not provided");
|
||||||
const formData = new URLSearchParams();
|
const formData = new URLSearchParams();
|
||||||
formData.append("_method", "POST");
|
formData.append("_method", "POST");
|
||||||
formData.append("code", this.studentCode.toUpperCase());
|
formData.append("code", this.studentCode.toUpperCase());
|
||||||
|
|
@ -43,25 +41,54 @@ export class StudentClient extends BaseClient {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
body: formData,
|
body: formData,
|
||||||
redirect: "manual",
|
redirect: "manual",
|
||||||
credentials: undefined,
|
|
||||||
});
|
});
|
||||||
if (request.status != 302 || !request.headers.get("set-cookie")) {
|
if (request.status != 302 || !request.headers.has("set-cookie")) {
|
||||||
|
await request.body?.cancel(); // Make deno tests happy by closing the body, unsure whether this is needed for the actual library
|
||||||
throw new Error(
|
throw new Error(
|
||||||
"Unauthenticated: ClassCharts returned an error: " +
|
"Unauthenticated: ClassCharts didn't return authentication cookies",
|
||||||
request.status +
|
|
||||||
" " +
|
|
||||||
request.statusText
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
const cookies = String(request.headers.get("set-cookie"));
|
const cookies = String(request.headers.get("set-cookie"));
|
||||||
this.authCookies = cookies.split(",");
|
this.authCookies = cookies.split(",");
|
||||||
const sessionCookies = parseCookies(cookies);
|
const sessionCookies = parseCookies(cookies);
|
||||||
const sessionID = JSON.parse(
|
const sessionID = JSON.parse(
|
||||||
String(sessionCookies["student_session_credentials"])
|
String(sessionCookies["student_session_credentials"]),
|
||||||
);
|
);
|
||||||
this.sessionId = sessionID.session_id;
|
this.sessionId = sessionID.session_id;
|
||||||
await this.getNewSessionId();
|
await this.getNewSessionId();
|
||||||
const user = await this.getStudentInfo();
|
const user = await this.getStudentInfo();
|
||||||
this.studentId = user.data.user.id;
|
this.studentId = user.data.user.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the available items in the current student's rewards shop
|
||||||
|
* @returns Array of purchasable items
|
||||||
|
*/
|
||||||
|
async getRewards(): Promise<RewardsResponse> {
|
||||||
|
return (
|
||||||
|
await this.makeAuthedRequest(
|
||||||
|
this.API_BASE + "/rewards/" + this.studentId,
|
||||||
|
{
|
||||||
|
method: "GET",
|
||||||
|
},
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Purchase a reward item from the current student's rewards shop
|
||||||
|
* @param itemId number
|
||||||
|
* @returns An object containing the current student's balance and item ID purchased
|
||||||
|
*/
|
||||||
|
async purchaseReward(itemId: number): Promise<RewardPurchaseResponse> {
|
||||||
|
return (
|
||||||
|
await this.makeAuthedRequest(
|
||||||
|
this.API_BASE + "/purchase/" + itemId,
|
||||||
|
{
|
||||||
|
method: "POST",
|
||||||
|
body: `pupil_id=${this.studentId}`,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
24
src/core/studentClient_test.ts
Normal file
24
src/core/studentClient_test.ts
Normal file
|
|
@ -0,0 +1,24 @@
|
||||||
|
import { assertRejects } from "../../deps_dev.ts";
|
||||||
|
import { StudentClient } from "../core/studentClient.ts";
|
||||||
|
|
||||||
|
Deno.test("Throws when no student code is provided", async () => {
|
||||||
|
const client = new StudentClient("");
|
||||||
|
await assertRejects(
|
||||||
|
async () => {
|
||||||
|
await client.login();
|
||||||
|
},
|
||||||
|
Error,
|
||||||
|
"Student Code not provided",
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
Deno.test("Throws with invalid student code", async () => {
|
||||||
|
const client = new StudentClient("invalid");
|
||||||
|
await assertRejects(
|
||||||
|
async () => {
|
||||||
|
await client.login();
|
||||||
|
},
|
||||||
|
Error,
|
||||||
|
"Unauthenticated: ClassCharts didn't return authentication cookies",
|
||||||
|
);
|
||||||
|
});
|
||||||
13
src/index.ts
13
src/index.ts
|
|
@ -1,13 +0,0 @@
|
||||||
export * from "./core/studentClient.js";
|
|
||||||
export * from "./core/parentClient.js";
|
|
||||||
export type {
|
|
||||||
Student,
|
|
||||||
ActivityPoint,
|
|
||||||
BehaviourTimelinePoint,
|
|
||||||
Homework,
|
|
||||||
Lesson,
|
|
||||||
Badge,
|
|
||||||
Announcement,
|
|
||||||
Detention,
|
|
||||||
AttendanceDate,
|
|
||||||
} from "./types.js";
|
|
||||||
121
src/types.ts
121
src/types.ts
|
|
@ -1,8 +1,5 @@
|
||||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper type to define response from ClassCharts
|
* Helper type to define response from ClassCharts
|
||||||
* @internal
|
|
||||||
*/
|
*/
|
||||||
export type ClassChartsResponse<Data, Meta> = {
|
export type ClassChartsResponse<Data, Meta> = {
|
||||||
data: Data;
|
data: Data;
|
||||||
|
|
@ -157,7 +154,6 @@ export interface GetHomeworkOptions {
|
||||||
*
|
*
|
||||||
* Used to sort homeworks by when they are due or when they were issued
|
* Used to sort homeworks by when they are due or when they were issued
|
||||||
* @default "issue_date"
|
* @default "issue_date"
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
displayDate?: DisplayDate;
|
displayDate?: DisplayDate;
|
||||||
/**
|
/**
|
||||||
|
|
@ -184,7 +180,6 @@ export interface Homework {
|
||||||
title: string;
|
title: string;
|
||||||
meta_title: string;
|
meta_title: string;
|
||||||
description: string;
|
description: string;
|
||||||
description_raw: string;
|
|
||||||
issue_date: string;
|
issue_date: string;
|
||||||
due_date: string;
|
due_date: string;
|
||||||
completion_time_unit: string;
|
completion_time_unit: string;
|
||||||
|
|
@ -193,16 +188,16 @@ export interface Homework {
|
||||||
status: {
|
status: {
|
||||||
id: number;
|
id: number;
|
||||||
state: "not_completed" | "late" | "completed" | null;
|
state: "not_completed" | "late" | "completed" | null;
|
||||||
mark: any | null;
|
mark: unknown | null;
|
||||||
mark_relative: number;
|
mark_relative: number;
|
||||||
ticked: "yes" | "no";
|
ticked: "yes" | "no";
|
||||||
allow_attachments: "yes" | "no";
|
allow_attachments: boolean;
|
||||||
first_seen_date: string;
|
first_seen_date: string;
|
||||||
last_seen_date: string;
|
last_seen_date: string;
|
||||||
attachments: Array<any>;
|
attachments: Array<unknown>;
|
||||||
has_feedback: boolean;
|
has_feedback: boolean;
|
||||||
};
|
};
|
||||||
validated_links: Array<any>;
|
validated_links: Array<unknown>;
|
||||||
validated_attachments: Array<ValidatedHomeworkAttachment>;
|
validated_attachments: Array<ValidatedHomeworkAttachment>;
|
||||||
}
|
}
|
||||||
export type HomeworksResponseData = Array<Homework>;
|
export type HomeworksResponseData = Array<Homework>;
|
||||||
|
|
@ -340,8 +335,17 @@ export interface Detention {
|
||||||
name: string;
|
name: string;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
// TODO: Update typings to include meta response. Currently not possible since I don't have access
|
|
||||||
export type DetentionsResponse = Array<Detention>;
|
export type DetentionsData = Array<Detention>;
|
||||||
|
|
||||||
|
export interface DetentionsMeta {
|
||||||
|
detention_alias_plural: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export type DetentionsResponse = ClassChartsResponse<
|
||||||
|
DetentionsData,
|
||||||
|
DetentionsMeta
|
||||||
|
>;
|
||||||
|
|
||||||
export interface Announcement {
|
export interface Announcement {
|
||||||
id: number;
|
id: number;
|
||||||
|
|
@ -357,7 +361,7 @@ export interface Announcement {
|
||||||
filename: string;
|
filename: string;
|
||||||
url: string;
|
url: string;
|
||||||
}>;
|
}>;
|
||||||
for_pupils: Array<any>;
|
for_pupils: Array<unknown>;
|
||||||
comment_visibility: string;
|
comment_visibility: string;
|
||||||
allow_comments: "yes" | "no";
|
allow_comments: "yes" | "no";
|
||||||
allow_reactions: "yes" | "no";
|
allow_reactions: "yes" | "no";
|
||||||
|
|
@ -365,12 +369,14 @@ export interface Announcement {
|
||||||
priority_pinned: "yes" | "no";
|
priority_pinned: "yes" | "no";
|
||||||
requires_consent: "yes" | "no";
|
requires_consent: "yes" | "no";
|
||||||
can_change_consent: boolean;
|
can_change_consent: boolean;
|
||||||
consent: string | null;
|
consent: unknown | null;
|
||||||
pupil_consents: Array<any>;
|
pupil_consents: Array<unknown>;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Update typings to include meta response. Currently not possible since I don't have access
|
export type AnnouncementsResponse = ClassChartsResponse<
|
||||||
export type AnnouncementsResponse = Array<Announcement>;
|
Array<Announcement>,
|
||||||
|
[]
|
||||||
|
>;
|
||||||
|
|
||||||
export interface Pupil extends Student {
|
export interface Pupil extends Student {
|
||||||
school_name: string;
|
school_name: string;
|
||||||
|
|
@ -415,34 +421,71 @@ export interface GetAttendanceOptions {
|
||||||
to: string;
|
to: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface AttendanceDate {
|
export interface AttendancePeriod {
|
||||||
AM: {
|
|
||||||
code: string;
|
code: string;
|
||||||
status: "present" | "ignore";
|
status: "present" | "ignore";
|
||||||
late_minutes: number;
|
late_minutes: number;
|
||||||
};
|
lesson_name?: string;
|
||||||
PM: {
|
room_name?: string;
|
||||||
code: string;
|
|
||||||
status: "present" | "ignore";
|
|
||||||
late_minutes: number;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
// TODO: Update typings to include meta response. Currently not possible since I don't have access
|
|
||||||
export type AttendanceResponse = Record<string, AttendanceDate>[];
|
|
||||||
|
|
||||||
export interface GetCodeOptions {
|
|
||||||
/**
|
|
||||||
* Date of birth, in format YYYY-MM-DD
|
|
||||||
*/
|
|
||||||
dateOfBirth: string;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface GetCodeResponseData {
|
export interface AttendanceMeta {
|
||||||
code: string;
|
dates: Array<string>;
|
||||||
|
sessions: Array<string>;
|
||||||
|
start_date: string;
|
||||||
|
end_date: string;
|
||||||
|
percentage: string;
|
||||||
|
percentage_since_august: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type GetCodeResponseMeta = [];
|
export type AttendanceData = Record<string, Record<string, AttendancePeriod>>;
|
||||||
export type GetCodeResponse = ClassChartsResponse<
|
|
||||||
GetCodeResponseData,
|
export type AttendanceResponse = ClassChartsResponse<
|
||||||
GetCodeResponseMeta
|
AttendanceData,
|
||||||
|
AttendanceMeta
|
||||||
>;
|
>;
|
||||||
|
|
||||||
|
export type RewardsData = {
|
||||||
|
id: number;
|
||||||
|
name: string;
|
||||||
|
description: string;
|
||||||
|
photo: string;
|
||||||
|
price: number;
|
||||||
|
stock_control: boolean;
|
||||||
|
stock: number;
|
||||||
|
can_purchase: boolean;
|
||||||
|
unable_to_purchase_reason: string;
|
||||||
|
once_per_pupil: boolean;
|
||||||
|
purchased: boolean;
|
||||||
|
purchased_count: string;
|
||||||
|
price_balance_difference: number;
|
||||||
|
}[];
|
||||||
|
|
||||||
|
export interface RewardsMeta {
|
||||||
|
pupil_score_balance: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export type RewardsResponse = ClassChartsResponse<RewardsData, RewardsMeta>;
|
||||||
|
|
||||||
|
export interface RewardPurchaseData {
|
||||||
|
single_purchase: "yes" | "no";
|
||||||
|
order_id: number;
|
||||||
|
balance: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export type RewardPurchaseResponse = ClassChartsResponse<
|
||||||
|
RewardPurchaseData,
|
||||||
|
[]
|
||||||
|
>;
|
||||||
|
|
||||||
|
export interface PupilFieldsData {
|
||||||
|
note: string;
|
||||||
|
fields: Array<{
|
||||||
|
id: number;
|
||||||
|
name: string;
|
||||||
|
graphic: string;
|
||||||
|
value: string;
|
||||||
|
}>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export type PupilFieldsResponse = ClassChartsResponse<PupilFieldsData, []>;
|
||||||
|
|
|
||||||
|
|
@ -2,4 +2,4 @@ export const BASE_URL = "https://www.classcharts.com";
|
||||||
export const API_BASE_STUDENT = `${BASE_URL}/apiv2student`;
|
export const API_BASE_STUDENT = `${BASE_URL}/apiv2student`;
|
||||||
export const API_BASE_PARENT = `${BASE_URL}/apiv2parent`;
|
export const API_BASE_PARENT = `${BASE_URL}/apiv2parent`;
|
||||||
|
|
||||||
export const PING_INTERVAL = 180 * 1000; // 3 minutes
|
export const PING_INTERVAL = 60 * 3 * 1000; // 3 minutes
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@
|
||||||
* Parse cookies from string
|
* Parse cookies from string
|
||||||
* @param input Input string
|
* @param input Input string
|
||||||
* @returns Object of cookies
|
* @returns Object of cookies
|
||||||
* @internal
|
|
||||||
*/
|
*/
|
||||||
export function parseCookies(input: string) {
|
export function parseCookies(input: string) {
|
||||||
const output: Record<string, unknown> = {};
|
const output: Record<string, unknown> = {};
|
||||||
|
|
@ -10,13 +9,11 @@ export function parseCookies(input: string) {
|
||||||
for (const cookie of cookies) {
|
for (const cookie of cookies) {
|
||||||
const cookieSplit = cookie.split(";")[0].split("=");
|
const cookieSplit = cookie.split(";")[0].split("=");
|
||||||
output[leftTrim(decodeURIComponent(cookieSplit[0]))] = decodeURIComponent(
|
output[leftTrim(decodeURIComponent(cookieSplit[0]))] = decodeURIComponent(
|
||||||
cookieSplit[1]
|
cookieSplit[1],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
export function leftTrim(str: string) {
|
||||||
function leftTrim(str: string) {
|
|
||||||
if (!str) return str;
|
|
||||||
return str.replace(/^\s+/g, "");
|
return str.replace(/^\s+/g, "");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
37
src/utils/utils_test.ts
Normal file
37
src/utils/utils_test.ts
Normal file
|
|
@ -0,0 +1,37 @@
|
||||||
|
import { assertEquals, assertExists } from "../../deps_dev.ts";
|
||||||
|
import { parseCookies } from "./utils.ts";
|
||||||
|
Deno.test("Parses simple cookie", () => {
|
||||||
|
const cookie =
|
||||||
|
"testCookie=Hello%20world!; expires=Tue, 28-Nov-2023 10:28:45 GMT; Max-Age=7776000; path=/";
|
||||||
|
const parsed = parseCookies(cookie);
|
||||||
|
assertEquals(parsed.testCookie, "Hello world!");
|
||||||
|
});
|
||||||
|
|
||||||
|
Deno.test("Parses multiple cookies", () => {
|
||||||
|
const cookies =
|
||||||
|
"firstCookie=I'm%20the%20first%20cookie; expires=Tue, 28-Nov-2023 10:28:45 GMT; Max-Age=7776000; path=/, secondCookie=I'm%20the%20second%20cookie; expires=Tue, 28-Nov-2023 10:28:45 GMT; Max-Age=7776000; path=/";
|
||||||
|
const parsed = parseCookies(cookies);
|
||||||
|
assertEquals(parsed.firstCookie, "I'm the first cookie");
|
||||||
|
assertEquals(parsed.secondCookie, "I'm the second cookie");
|
||||||
|
});
|
||||||
|
|
||||||
|
Deno.test("Parses cookie with no value", () => {
|
||||||
|
const cookie =
|
||||||
|
"cookieWithNoValue=; expires=Tue, 28-Nov-2023 10:28:45 GMT; Max-Age=7776000; path=/";
|
||||||
|
const parsed = parseCookies(cookie);
|
||||||
|
assertExists(parsed.cookieWithNoValue);
|
||||||
|
assertEquals(parsed.cookieWithNoValue, "");
|
||||||
|
});
|
||||||
|
|
||||||
|
import { leftTrim } from "./utils.ts";
|
||||||
|
Deno.test("Trims left with spaces", () => {
|
||||||
|
const input = " Hello world!";
|
||||||
|
const output = leftTrim(input);
|
||||||
|
assertEquals(output, "Hello world!");
|
||||||
|
});
|
||||||
|
|
||||||
|
Deno.test("Trims left with no spaces", () => {
|
||||||
|
const input = "Hello world!";
|
||||||
|
const output = leftTrim(input);
|
||||||
|
assertEquals(output, "Hello world!");
|
||||||
|
});
|
||||||
|
|
@ -1,46 +0,0 @@
|
||||||
import { StudentClient } from "../src";
|
|
||||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
||||||
// @ts-ignore
|
|
||||||
import { code, dob } from "./config.json";
|
|
||||||
import "jest-extended";
|
|
||||||
const client = new StudentClient(code, dob);
|
|
||||||
jest.setTimeout(10000);
|
|
||||||
|
|
||||||
test("client logs in with correct credentials", () => {
|
|
||||||
return expect(client.login()).resolves.not.toThrow();
|
|
||||||
});
|
|
||||||
|
|
||||||
test("client fails to login with incorrect credentials", () => {
|
|
||||||
const fakeClient = new StudentClient("rewrew", "123");
|
|
||||||
return expect(fakeClient.login()).rejects.toThrowError();
|
|
||||||
});
|
|
||||||
|
|
||||||
test("client returns student data", () => {
|
|
||||||
return expect(client.getStudentInfo()).resolves.toBeObject();
|
|
||||||
});
|
|
||||||
|
|
||||||
test("client returns activity data", () => {
|
|
||||||
return expect(client.getActivity()).resolves.toBeObject();
|
|
||||||
});
|
|
||||||
|
|
||||||
test("client returns full activity", () => {
|
|
||||||
return client
|
|
||||||
.getFullActivity({ from: "2022-01-01", to: "2022-09-01" })
|
|
||||||
.then((data) => {
|
|
||||||
let valid = false;
|
|
||||||
if (data.length > 0) valid = true;
|
|
||||||
expect(valid).toBeTrue();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
test("client returns behaviour data", () => {
|
|
||||||
return expect(client.getBehaviour()).resolves.toBeObject();
|
|
||||||
});
|
|
||||||
|
|
||||||
test("client returns homework data", () => {
|
|
||||||
return expect(client.getHomeworks()).resolves.toBeObject();
|
|
||||||
});
|
|
||||||
|
|
||||||
test("client returns badges", () => {
|
|
||||||
expect(client.getBadges()).resolves.toBeObject();
|
|
||||||
});
|
|
||||||
|
|
@ -1,4 +0,0 @@
|
||||||
{
|
|
||||||
"code": "",
|
|
||||||
"dob": ""
|
|
||||||
}
|
|
||||||
|
|
@ -1,22 +0,0 @@
|
||||||
{
|
|
||||||
"compilerOptions": {
|
|
||||||
"target": "es2021",
|
|
||||||
"module": "ES2020",
|
|
||||||
"moduleResolution": "node",
|
|
||||||
"declaration": true,
|
|
||||||
"sourceMap": true,
|
|
||||||
"outDir": "dist",
|
|
||||||
"allowSyntheticDefaultImports": true,
|
|
||||||
"esModuleInterop": true,
|
|
||||||
"forceConsistentCasingInFileNames": true,
|
|
||||||
"strict": true,
|
|
||||||
"noImplicitAny": true,
|
|
||||||
"noImplicitReturns": true,
|
|
||||||
"noImplicitThis": true,
|
|
||||||
"noUnusedLocals": true,
|
|
||||||
"noUnusedParameters": true,
|
|
||||||
"skipLibCheck": true,
|
|
||||||
"isolatedModules": true,
|
|
||||||
},
|
|
||||||
"include": ["./src/**/*"]
|
|
||||||
}
|
|
||||||
|
|
@ -1,22 +0,0 @@
|
||||||
/** @type {import('typedoc-plugin-umami').TypeDocOptions} */
|
|
||||||
module.exports = {
|
|
||||||
entryPointStrategy: "resolve",
|
|
||||||
plugin: ["typedoc-plugin-umami"],
|
|
||||||
entryPoints: [
|
|
||||||
"src/core/studentClient.ts",
|
|
||||||
"src/core/parentClient.ts",
|
|
||||||
"src/core/baseClient.ts",
|
|
||||||
"src/types.ts",
|
|
||||||
],
|
|
||||||
navigationLinks: {
|
|
||||||
Discord: "https://discord.gg/DTcwugcgZ2",
|
|
||||||
Github: "https://github.com/classchartsapi/classcharts-api-js",
|
|
||||||
},
|
|
||||||
includeVersion: true,
|
|
||||||
out: "docs/typedoc",
|
|
||||||
sort: "required-first",
|
|
||||||
umamiOptions: {
|
|
||||||
src: "https://umami.jaminit.co.uk/script.js",
|
|
||||||
websiteId: "dd8c53b8-dc99-484c-911d-b08c898498a8",
|
|
||||||
},
|
|
||||||
};
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue