mirror of
https://github.com/classchartsapi/classcharts-api-js.git
synced 2026-05-14 11:58:13 +00:00
feat: denoify (#33)
This commit is contained in:
parent
f2981dd167
commit
f86ded2ae3
31 changed files with 331 additions and 4940 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 @@
|
|||
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",
|
||||
],
|
||||
};
|
||||
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
|
||||
40
.github/workflows/release.yml
vendored
40
.github/workflows/release.yml
vendored
|
|
@ -2,9 +2,8 @@ name: Release
|
|||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
|
||||
tags:
|
||||
- "*"
|
||||
concurrency: ${{ github.workflow }}-${{ github.ref }}
|
||||
|
||||
jobs:
|
||||
|
|
@ -14,26 +13,21 @@ jobs:
|
|||
steps:
|
||||
- name: Checkout Repo
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Setup Node.js 18.x
|
||||
uses: actions/setup-node@v3
|
||||
- uses: denoland/setup-deno@v1
|
||||
with:
|
||||
node-version: 18.x
|
||||
|
||||
- name: Install Dependencies
|
||||
run: npm install -g pnpm && pnpm install
|
||||
|
||||
- name: Create Release Pull Request or Publish to npm
|
||||
id: changesets
|
||||
uses: changesets/action@v1
|
||||
deno-version: v1.36.x
|
||||
- name: Get tag version
|
||||
if: startsWith(github.ref, 'refs/tags/')
|
||||
id: get_tag_version
|
||||
run: echo TAG_VERSION=${GITHUB_REF/refs\/tags\//} >> $GITHUB_OUTPUT
|
||||
- uses: actions/setup-node@v3
|
||||
with:
|
||||
# This expects you to have a script called release which does a build for your packages and calls changeset publish
|
||||
publish: pnpm release
|
||||
node-version: "18.x"
|
||||
registry-url: "https://registry.npmjs.org"
|
||||
- name: npm build
|
||||
run: deno run -A npm ${{steps.get_tag_version.outputs.TAG_VERSION}}
|
||||
- name: npm publish
|
||||
if: startsWith(github.ref, 'refs/tags/')
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||
|
||||
# - 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!"
|
||||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||
run: cd npm && npm publish
|
||||
|
|
|
|||
124
.gitignore
vendored
124
.gitignore
vendored
|
|
@ -1,122 +1,2 @@
|
|||
# Logs
|
||||
logs
|
||||
*.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
|
||||
npm/
|
||||
.cov/
|
||||
|
|
@ -1,6 +0,0 @@
|
|||
dist/
|
||||
node_modules/
|
||||
pnpm-lock.yaml
|
||||
.prettierrc.json
|
||||
.eslint.js
|
||||
CHANGELOG.md
|
||||
|
|
@ -1 +0,0 @@
|
|||
{}
|
||||
3
.vscode/extensions.json
vendored
3
.vscode/extensions.json
vendored
|
|
@ -1,3 +0,0 @@
|
|||
{
|
||||
"recommendations": ["dbaeumer.vscode-eslint", "esbenp.prettier-vscode"]
|
||||
}
|
||||
4
.vscode/settings.json
vendored
Normal file
4
.vscode/settings.json
vendored
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
"deno.enable": true,
|
||||
"deno.lint": true
|
||||
}
|
||||
38
CHANGELOG.md
38
CHANGELOG.md
|
|
@ -1,38 +0,0 @@
|
|||
# classcharts-api
|
||||
|
||||
## 2.3.1
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 40b1683: Export types first
|
||||
- 3d0e7aa: Declare no side effects
|
||||
|
||||
## 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
|
||||
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"]
|
||||
}
|
||||
121
deno.lock
generated
Normal file
121
deno.lock
generated
Normal file
|
|
@ -0,0 +1,121 @@
|
|||
{
|
||||
"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/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"
|
||||
}
|
||||
}
|
||||
|
|
@ -13,18 +13,20 @@
|
|||
<span> • </span>
|
||||
<a href="https://discord.gg/DTcwugcgZ2">Discord</a>
|
||||
<span> • </span>
|
||||
<a href="https://classchartsapi.github.io/classcharts-api-js/typedoc/">TypeDoc</a>
|
||||
<span> • </span>
|
||||
<a href="https://classchartsapi.github.io/api-docs/">API Docs</a>
|
||||
</p>
|
||||
|
||||
# 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
|
||||
|
||||
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.
|
||||
|
||||
# Installation
|
||||
|
||||
|
|
@ -48,7 +50,8 @@ pnpm add classcharts-api # pnpm
|
|||
|
||||
# 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
|
||||
|
||||
|
|
@ -71,7 +74,8 @@ await client.login();
|
|||
|
||||
# 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`
|
||||
|
||||
|
|
@ -176,7 +180,6 @@ console.log(homeworks);
|
|||
...
|
||||
}
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
## `.getLessons`
|
||||
|
|
@ -236,7 +239,9 @@ console.log(badges);
|
|||
|
||||
## `.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!
|
||||
?> 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.
|
||||
|
||||
|
|
@ -247,7 +252,9 @@ console.log(announcements);
|
|||
|
||||
## `.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.
|
||||
|
||||
|
|
@ -258,7 +265,9 @@ console.log(detentions);
|
|||
|
||||
## `.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.
|
||||
|
||||
|
|
|
|||
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"],
|
||||
};
|
||||
|
|
@ -1,13 +1,13 @@
|
|||
export * from "./core/studentClient.js";
|
||||
export * from "./core/parentClient.js";
|
||||
export * from "./src/core/studentClient.ts";
|
||||
export * from "./src/core/parentClient.ts";
|
||||
export type {
|
||||
Student,
|
||||
ActivityPoint,
|
||||
Announcement,
|
||||
AttendanceDate,
|
||||
Badge,
|
||||
BehaviourTimelinePoint,
|
||||
Detention,
|
||||
Homework,
|
||||
Lesson,
|
||||
Badge,
|
||||
Announcement,
|
||||
Detention,
|
||||
AttendanceDate,
|
||||
} from "./types.js";
|
||||
Student,
|
||||
} from "./src/types.ts";
|
||||
65
package.json
65
package.json
|
|
@ -1,65 +0,0 @@
|
|||
{
|
||||
"name": "classcharts-api",
|
||||
"type": "module",
|
||||
"version": "2.3.1",
|
||||
"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"
|
||||
},
|
||||
"sideEffects": false
|
||||
}
|
||||
4274
pnpm-lock.yaml
generated
4274
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load diff
|
|
@ -16,8 +16,13 @@
|
|||
|
||||
# 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).
|
||||
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.
|
||||
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.
|
||||
|
|
|
|||
49
scripts/build_npm.ts
Normal file
49
scripts/build_npm.ts
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
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: ["./mod.ts"],
|
||||
outDir: "./npm",
|
||||
shims: {
|
||||
deno: true,
|
||||
},
|
||||
packageManager: "pnpm",
|
||||
compilerOptions: {
|
||||
lib: ["DOM", "ESNext"],
|
||||
},
|
||||
typeCheck: "both",
|
||||
package: {
|
||||
// package.json properties
|
||||
name: "classcharts-api",
|
||||
author: {
|
||||
name: "James Cook",
|
||||
email: "james@jaminit.co.uk",
|
||||
},
|
||||
version: Deno.args[0],
|
||||
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/",
|
||||
types: "./mod.ts",
|
||||
engines: {
|
||||
node: ">=18",
|
||||
},
|
||||
sideEffects: false,
|
||||
},
|
||||
postBuild() {
|
||||
// steps to run after building and before running the tests
|
||||
Deno.copyFileSync("LICENSE", "npm/LICENSE");
|
||||
Deno.copyFileSync("readme.md", "npm/README.md");
|
||||
},
|
||||
});
|
||||
|
|
@ -15,8 +15,8 @@ import type {
|
|||
GetStudentInfoResponse,
|
||||
HomeworksResponse,
|
||||
LessonsResponse,
|
||||
} from "../types.js";
|
||||
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
|
||||
|
|
@ -46,7 +46,6 @@ export class BaseClient {
|
|||
*/
|
||||
protected API_BASE = "";
|
||||
/**
|
||||
*
|
||||
* @param API_BASE Base API URL, this is different depending on if its called as a parent or student
|
||||
*/
|
||||
constructor(API_BASE: string) {
|
||||
|
|
@ -113,7 +112,7 @@ export class BaseClient {
|
|||
let responseJSON: ClassChartsResponse<unknown, unknown>;
|
||||
try {
|
||||
responseJSON = await request.json();
|
||||
} catch (err) {
|
||||
} catch {
|
||||
throw new Error(
|
||||
"Error parsing JSON. Returned response: " + (await request.text())
|
||||
);
|
||||
|
|
@ -121,8 +120,8 @@ export class BaseClient {
|
|||
if (responseJSON.success == 0) {
|
||||
throw new Error(responseJSON.error);
|
||||
}
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
return responseJSON as any;
|
||||
// deno-lint-ignore no-explicit-any
|
||||
return responseJSON as unknown as any;
|
||||
}
|
||||
/**
|
||||
* Gets general information about the current student
|
||||
|
|
@ -150,7 +149,7 @@ export class BaseClient {
|
|||
options?.from && params.append("from", options?.from);
|
||||
options?.to && params.append("to", options?.to);
|
||||
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(),
|
||||
{
|
||||
method: "GET",
|
||||
|
|
@ -214,8 +213,9 @@ export class BaseClient {
|
|||
*/
|
||||
async getHomeworks(options?: GetHomeworkOptions): Promise<HomeworksResponse> {
|
||||
const params = new URLSearchParams();
|
||||
if (options?.displayDate)
|
||||
if (options?.displayDate) {
|
||||
params.append("display_date", String(options?.displayDate));
|
||||
}
|
||||
|
||||
options?.from && params.append("from", String(options?.from));
|
||||
options?.to && params.append("to", String(options?.to));
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
import type { GetPupilsResponse } from "../types.js";
|
||||
import type { GetPupilsResponse } from "../types.ts";
|
||||
|
||||
import { BaseClient } from "./baseClient.js";
|
||||
import { API_BASE_PARENT, BASE_URL } from "../utils/consts.js";
|
||||
import { parseCookies } from "../utils/utils.js";
|
||||
import { BaseClient } from "./baseClient.ts";
|
||||
import { API_BASE_PARENT, BASE_URL } from "../utils/consts.ts";
|
||||
import { parseCookies } from "../utils/utils.ts";
|
||||
/**
|
||||
* Parent Client
|
||||
*/
|
||||
|
|
@ -12,7 +12,6 @@ export class ParentClient extends BaseClient {
|
|||
// @ts-expect-error Init in .login
|
||||
public pupils: GetPupilsResponse;
|
||||
/**
|
||||
*
|
||||
* @param email Parent's email address
|
||||
* @param password Parent's password
|
||||
*/
|
||||
|
|
@ -26,7 +25,7 @@ export class ParentClient extends BaseClient {
|
|||
* Authenticates with ClassCharts
|
||||
*/
|
||||
async login(): Promise<void> {
|
||||
if (!this.email) throw new Error("Email not inputted");
|
||||
if (!this.email) throw new Error("Email not provided");
|
||||
const formData = new URLSearchParams();
|
||||
formData.append("_method", "POST");
|
||||
formData.append("email", this.email);
|
||||
|
|
@ -42,13 +41,14 @@ export class ParentClient extends BaseClient {
|
|||
headers: headers,
|
||||
credentials: undefined,
|
||||
});
|
||||
if (response.status != 302 || !response.headers.get("set-cookie"))
|
||||
if (response.status != 302 || !response.headers.get("set-cookie")) {
|
||||
throw new Error(
|
||||
"Unauthenticated: ClassCharts returned an error: " +
|
||||
response.status +
|
||||
" " +
|
||||
response.statusText
|
||||
);
|
||||
}
|
||||
|
||||
const cookies = String(response.headers.get("set-cookie"));
|
||||
// this.authCookies = cookies.split(";");
|
||||
|
|
@ -66,7 +66,7 @@ export class ParentClient extends BaseClient {
|
|||
* @returns an array of Pupils connected to this parent's account
|
||||
*/
|
||||
async getPupils(): Promise<GetPupilsResponse> {
|
||||
return super.makeAuthedRequest(super.API_BASE + "/pupils", {
|
||||
return await super.makeAuthedRequest(super.API_BASE + "/pupils", {
|
||||
method: "GET",
|
||||
});
|
||||
}
|
||||
|
|
@ -76,7 +76,7 @@ export class ParentClient extends BaseClient {
|
|||
*
|
||||
* @see getPupils
|
||||
*/
|
||||
async selectPupil(pupilId: number): Promise<void> {
|
||||
selectPupil(pupilId: number) {
|
||||
if (!pupilId) throw new Error("No pupil ID specified");
|
||||
const pupils = this.pupils;
|
||||
for (let i = 0; i < pupils.length; i++) {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import { API_BASE_STUDENT, BASE_URL } from "../utils/consts.js";
|
||||
import { BaseClient } from "./baseClient.js";
|
||||
import { parseCookies } from "../utils/utils.js";
|
||||
import { API_BASE_STUDENT, BASE_URL } from "../utils/consts.ts";
|
||||
import { BaseClient } from "./baseClient.ts";
|
||||
import { parseCookies } from "../utils/utils.ts";
|
||||
|
||||
/**
|
||||
* Student Client
|
||||
|
|
@ -18,7 +18,6 @@ export class StudentClient extends BaseClient {
|
|||
private dateOfBirth = "";
|
||||
|
||||
/**
|
||||
*
|
||||
* @param studentCode ClassCharts student code
|
||||
* @param dateOfBirth Student's date of birth
|
||||
*/
|
||||
|
|
@ -32,7 +31,7 @@ export class StudentClient extends BaseClient {
|
|||
* Authenticates with ClassCharts
|
||||
*/
|
||||
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();
|
||||
formData.append("_method", "POST");
|
||||
formData.append("code", this.studentCode.toUpperCase());
|
||||
|
|
@ -43,14 +42,11 @@ export class StudentClient extends BaseClient {
|
|||
method: "POST",
|
||||
body: formData,
|
||||
redirect: "manual",
|
||||
credentials: undefined,
|
||||
});
|
||||
if (request.status != 302 || !request.headers.get("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(
|
||||
"Unauthenticated: ClassCharts returned an error: " +
|
||||
request.status +
|
||||
" " +
|
||||
request.statusText
|
||||
"Unauthenticated: ClassCharts didn't return authentication cookies"
|
||||
);
|
||||
}
|
||||
const cookies = String(request.headers.get("set-cookie"));
|
||||
|
|
|
|||
25
src/core/studentClient_test.ts
Normal file
25
src/core/studentClient_test.ts
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
import { assertRejects } from "https://deno.land/std@0.200.0/assert/mod.ts";
|
||||
|
||||
import { StudentClient } from "./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/types.ts
13
src/types.ts
|
|
@ -1,5 +1,3 @@
|
|||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||
|
||||
/**
|
||||
* Helper type to define response from ClassCharts
|
||||
* @internal
|
||||
|
|
@ -157,7 +155,6 @@ export interface GetHomeworkOptions {
|
|||
*
|
||||
* Used to sort homeworks by when they are due or when they were issued
|
||||
* @default "issue_date"
|
||||
*
|
||||
*/
|
||||
displayDate?: DisplayDate;
|
||||
/**
|
||||
|
|
@ -193,16 +190,16 @@ export interface Homework {
|
|||
status: {
|
||||
id: number;
|
||||
state: "not_completed" | "late" | "completed" | null;
|
||||
mark: any | null;
|
||||
mark: unknown | null;
|
||||
mark_relative: number;
|
||||
ticked: "yes" | "no";
|
||||
allow_attachments: "yes" | "no";
|
||||
first_seen_date: string;
|
||||
last_seen_date: string;
|
||||
attachments: Array<any>;
|
||||
attachments: Array<unknown>;
|
||||
has_feedback: boolean;
|
||||
};
|
||||
validated_links: Array<any>;
|
||||
validated_links: Array<unknown>;
|
||||
validated_attachments: Array<ValidatedHomeworkAttachment>;
|
||||
}
|
||||
export type HomeworksResponseData = Array<Homework>;
|
||||
|
|
@ -357,7 +354,7 @@ export interface Announcement {
|
|||
filename: string;
|
||||
url: string;
|
||||
}>;
|
||||
for_pupils: Array<any>;
|
||||
for_pupils: Array<unknown>;
|
||||
comment_visibility: string;
|
||||
allow_comments: "yes" | "no";
|
||||
allow_reactions: "yes" | "no";
|
||||
|
|
@ -366,7 +363,7 @@ export interface Announcement {
|
|||
requires_consent: "yes" | "no";
|
||||
can_change_consent: boolean;
|
||||
consent: string | 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
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@ export function parseCookies(input: string) {
|
|||
return output;
|
||||
}
|
||||
|
||||
function leftTrim(str: string) {
|
||||
if (!str) return str;
|
||||
export function leftTrim(str: string) {
|
||||
return str.replace(/^\s+/g, "");
|
||||
}
|
||||
|
|
|
|||
41
src/utils/utils_test.ts
Normal file
41
src/utils/utils_test.ts
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
import {
|
||||
assertEquals,
|
||||
assertExists,
|
||||
} from "https://deno.land/std@0.200.0/assert/mod.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/**/*"]
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue