Skip to content

Commit

Permalink
Merge pull request #438 from zikeji/dev
Browse files Browse the repository at this point in the history
v4.0.0 / Hypixel v2 endpoints experimental release
  • Loading branch information
zikeji authored Sep 11, 2024
2 parents d169503 + 4b10d8d commit 10dc121
Show file tree
Hide file tree
Showing 80 changed files with 3,482 additions and 43,363 deletions.
3 changes: 0 additions & 3 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
dist/
docs/
tests/
deno_dist/
src/**/*.deno.ts
src/**/*.deno.tsx
33 changes: 10 additions & 23 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,44 +9,32 @@ jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
token: ${{ secrets.GH_TOKEN }}
- name: Use Node.js 14.x
uses: actions/setup-node@v2.1.5
- uses: actions/setup-node@v4
with:
node-version: 14.x
node-version: latest
- name: Install dependencies
run: npm ci
- name: Build
run: npm run build
- name: Disable deno_dist gitignore
run: sed -i 's/\/deno_dist/#\/deno_dist/' .gitignore
- uses: papeloto/action-zip@v1
- uses: vimtor/action-zip@v1
with:
files: package.json package-lock.json dist/ deno_dist/
files: package.json package-lock.json dist/
dest: dist.zip
- name: Semantic Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
run: npx semantic-release
- name: enable deno_dist gitignore
run: sed -i 's/#\/deno_dist/\/deno_dist/' .gitignore
- name: Commit removal of deno_dist
run: |
git rm --cached `git ls-files -i --exclude-from=.gitignore`
git config --local user.email "ci@github.com"
git config --local user.name "ci"
git add -A
git commit -am "remove deno_dist [skip-ci]"
- run: git push origin main
merge:
needs: [release]
runs-on: ubuntu-latest
steps:
- name: Merge main back into dev
uses: devmasx/merge-branch@v1.3.1
uses: devmasx/merge-branch@v1.4.0
with:
type: now
head_to_merge: main
Expand All @@ -56,21 +44,20 @@ jobs:
needs: [release]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
ref: main
- name: Use Node.js 14.x
uses: actions/setup-node@v2.1.5
- uses: actions/setup-node@v4
with:
node-version: 14.x
node-version: latest
- run: npm ci
- name: Build documentation
env:
NODE_ENV: production
NODE_OPTIONS: --max-old-space-size=4096
run: npm run docs:build
- name: Deploy
uses: peaceiris/actions-gh-pages@v3.8.0
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./docs/.vuepress/dist
Expand Down
45 changes: 6 additions & 39 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,10 @@ jobs:
runs-on: ubuntu-latest
if: "! contains(toJSON(github.event.commits.*.message), '[skip ci]')"
steps:
- uses: actions/checkout@v2
- name: Use Node.js 14.x
uses: actions/setup-node@v2.1.4
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 14.x
node-version: latest
- run: npm ci
- name: Don't continue if lint fails.
run: npm run test:lint
Expand All @@ -23,11 +22,10 @@ jobs:
strategy:
max-parallel: 1
matrix:
node-version: [10.x, 12.x, 14.x]
node-version: [20.x, 22.x]
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2.1.4
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- name: Install dependencies
Expand All @@ -38,42 +36,12 @@ jobs:
run: npm run coverage:ci
env:
CI: true
HYPIXEL_KEY: ${{ secrets.HYPIXEL_KEY }}
- name: Coveralls Parallel
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
flag-name: run-${{ matrix.test_number }}
parallel: true
test_deno:
runs-on: ubuntu-latest
needs: test_lint
steps:
- uses: actions/checkout@v2
- name: Use Node.js 14.x
uses: actions/setup-node@v2.1.4
with:
node-version: 14.x
- name: Install dependencies
run: npm ci
- name: Deno Cache
uses: actions/cache@v2.1.4
with:
path: ~/.cache/deno
key: deno-${{ runner.os }}-${{ hashFiles('deno-lock.json') }}
restore-keys: |
deno-${{ runner.os }}-${{ hashFiles('deno-lock.json') }}
deno-${{ runner.os }}-
deno-
- name: Setup Deno
uses: denolib/setup-deno@master
with:
deno-version: v1.x
- run: deno --version
- name: Run build to generate denoify'd output
run: npm run build
- name: Run tests
run: npm run test:deno
finish:
needs: test_node
runs-on: ubuntu-latest
Expand All @@ -86,7 +54,6 @@ jobs:
trigger_release:
needs:
- finish
- test_deno
runs-on: ubuntu-latest
if: github.event_name == 'push' && github.ref == 'refs/heads/main' && !contains(toJSON(github.event.commits.*.message), '[skip ci]')
steps:
Expand Down
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ coverage/
dist/
node_modules/
*.tgz
*.zip
tests/**/*.ts
!tests/**/*.test.ts
!tests/**/*.test.deno.ts
!tests/structures/*.ts
/deno_dist
/swagger.json
29 changes: 12 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,31 +1,29 @@
# @zikeji/hypixel

[![npm](https://img.shields.io/npm/v/@zikeji/hypixel)][npm]
[![Deno](https://img.shields.io/badge/dynamic/json?color=black&label=Deno&prefix=v&query=%24.version&url=https%3A%2F%2Fraw.githubusercontent.com%2Fzikeji%2Fnode-hypixel%2Fmain%2Fpackage.json&style=flat&logo=Deno)](https://deno.land/x/hypixel)
[![npm bundle size](https://img.shields.io/bundlephobia/min/@zikeji/hypixel)][npm]
[![visit docs](https://img.shields.io/badge/docs-VuePress-green)][docs]
[![Visit our Discord server.](https://img.shields.io/badge/support-Discord-green)](https://discord.gg/QkcGHwG)
[![Snyk Vulnerabilities for npm package version](https://img.shields.io/snyk/vulnerabilities/npm/@zikeji/hypixel)][npm]
[![Libraries.io dependency status for latest release](https://img.shields.io/librariesio/release/npm/@zikeji/hypixel)][npm]
[![GitHub license](https://img.shields.io/github/license/zikeji/node-hypixel)](https://github.com/zikeji/node-hypixel/blob/master/LICENSE)
[![GitHub last commit](https://img.shields.io/github/last-commit/zikeji/node-hypixel)][github]
[![GitHub code size in bytes](https://img.shields.io/github/languages/code-size/zikeji/node-hypixel)][github]
[![GitHub issues](https://img.shields.io/github/issues/zikeji/node-hypixel)](https://github.com/zikeji/node-hypixel/issues)
[![Coveralls](https://img.shields.io/coveralls/github/zikeji/node-hypixel)](https://coveralls.io/github/zikeji/node-hypixel)
[![GitHub Workflow Status](https://img.shields.io/github/workflow/status/zikeji/node-hypixel/release)][github]
[![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/zikeji/node-hypixel/release.yml?branch=main)][github]

[npm]: https://www.npmjs.com/package/@zikeji/hypixel
[github]: https://github.com/zikeji/node-hypixel
[docs]: https://node-hypixel.zikeji.com
[hypixel]: https://api.hypixel.net/

With thorough **[IntelliSense](https://code.visualstudio.com/docs/editor/intellisense)** support & **[100% test coverage](https://coveralls.io/github/zikeji/node-hypixel)**, this is an unopinionated async/await API wrapper for [Hypixel's Public API][hypixel]. It is developed in TypeScript complete with [documentation][docs], [typed interfaces](https://node-hypixel.zikeji.com/ts-api/) for all API responses (and an [OpenAPI.yaml](https://node-hypixel.zikeji.com/api/)!), built-in rate-limit handling, [flexible cache support](https://node-hypixel.zikeji.com/guide/advanced/cache/), [helper functions](https://node-hypixel.zikeji.com/guide/helpers/player-ranks/), and support for undocumented endpoints.
With **[IntelliSense](https://code.visualstudio.com/docs/editor/intellisense)** support, this is an unopinionated async/await API wrapper for [Hypixel's Public API][hypixel]. It is developed in TypeScript complete with [documentation][docs], [typed interfaces](https://node-hypixel.zikeji.com/ts-api/) for all API responses, built-in rate-limit handling, [flexible cache support](https://node-hypixel.zikeji.com/guide/advanced/cache/), and some [helper functions](https://node-hypixel.zikeji.com/guide/helpers/player-ranks/).

This library aims to replicate the API paths in it's method usage. As such, the general scheme would be to change the path of an API call by simply replacing the `/` with a `.`, and if the endpoint takes multiple parameters, those are added on the end. For example, `api.hypixel.net/skyblock/profiles?uuid=1234` would simply become `client.skyblock.profiles.uuid('1234')`. Of course, with everything being fully typed if you are using an IDE that supports [IntelliSense](https://code.visualstudio.com/docs/editor/intellisense) you should rarely need to reference documentation.
## 4.0.0 Information

## 2.0 to 3.0 Migration
4.0 is a major breaking version, where I've rebased types on the v2 endpoints published by Hypixel and removed my previous OpenAPI.yaml.

This library follows semver. As backwards incompatible changes were introduced while making this Deno compatible. Most likely nothing you use has changed, and you should be able to update without issue. The only breaking change is that the Client class no longer accepts agent as a parameter, as Deno does not support this.
I've added `AugmentedTypes.ts` to "augment" their typings, but they are very barebones in the current state. Pull requests augmenting types are welcome, I will more than likely not be exploring the typings like I did in the past, and merely add what I want/need.

## Installation

Expand All @@ -37,14 +35,6 @@ Use [npm](https://www.npmjs.com) to install this library.
npm i --save @zikeji/hypixel
```

### Deno

As Deno does not require installation, you would simply follow their convention for imports.

```typescript
import { Client as HypixelClient } from "https://deno.land/x/hypixel/v3.1.0/mod.ts";
```

## Usage

```javascript
Expand All @@ -54,7 +44,7 @@ const client = new Client("API_KEY");
const status = await client.status.uuid("20934ef9488c465180a78f861586b4cf"); // Minikloon
console.log(status);
// {"online": false}
const stats = await client.watchdogstats();
const stats = await client.punishmentstats();
console.log(stats);
// {watchdog_lastMinute: 1, staff_rollingDaily: 2609, watchdog_total: 5591714, watchdog_rollingDaily: 4213, …}
})();
Expand All @@ -65,9 +55,14 @@ const client = new Client("API_KEY");
This library adds multiple helpers to facilitate using the Hypixel API. You can find documentation on each helper [here](https://node-hypixel.zikeji.com/guide/helpers/player-ranks/). If you would like to request a helper that doesn't exist, please open an issue. Otherwise if you would like to contribute one refer to the below section.

## Contributing

If some API result isn't documented / typed out fully, please open an issue and I can see about adding it. However some data is too exhaustive to provide typings to in a reasonable manner, as exhibited [here](https://github.com/zikeji/node-hypixel/issues/119), where it isn't reasonable to add 19.5 thousand lines of code to document the entire dataset.

Otherwise, pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change. All changes must ensure they pass eslint, tests, and that testing is updated to meet or exceed the previous coverage.
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change. All changes must ensure they pass eslint, tests, and that testing is updated to meet or exceed the previous coverage.

### New Typings

If Hypixel updates their API documentation, you can navigate to https://api.hypixel.net and click "Download", place it in the root folder of this project, and do `npm run types:openapi` to regenerate the `./src/types/api.ts`.

## Licenses

Expand Down
Binary file removed dist.zip
Binary file not shown.
97 changes: 0 additions & 97 deletions docs/.vuepress/components/OpenAPI.vue

This file was deleted.

9 changes: 3 additions & 6 deletions docs/.vuepress/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,12 @@ module.exports = config({
nav: [
{ text: "Home", link: "/", icon: "home" },
{ text: "Guide", link: "/guide/", icon: "guide" },
{ text: "API", link: "/api/", icon: "api" },
{ text: "Typescript API", link: "/ts-api/", icon: "typescript" },
{
text: "Info",
icon: "info",
items: [
{ text: "Changelog", link: "/changelog/", icon: "changelog" },
{ text: "Discord Server", link: "https://discord.gg/QkcGHwG", icon: "discord" },
{ text: "NPM Package", link: `https://www.npmjs.com/package/${name}`, icon: "npm" },
{ text: "GitHub Repo", link: `https://github.com/${repo}`, icon: "github" },
]
Expand Down Expand Up @@ -130,8 +128,7 @@ module.exports = config({
addThis: process.env.NODE_ENV === "production" ? "ra-5f8d724d4c77d215" : null,
},
extraWatchFiles: [
"../../README.md",
"../../openapi.yaml"
"../../README.md"
],
configureWebpack: {
module: {
Expand All @@ -147,7 +144,7 @@ module.exports = config({
["@mr-hope/vuepress-plugin-last-update", {
transformer: (timestamp) => {
return new Date(timestamp).toLocaleString('en-US', { year: "numeric", month: "long", weekday: "long", day: "numeric", hour: "numeric", minute: "2-digit", timeZone: 'America/New_York' })
.match(/^(\w+,\s\w+\s)(\d{1,2})(,\s\d{4}),(\s\d{1,2}:\d{1,2}\s[AP]M)/)
.match(/^(\w+,\s\w+\s)(\d{1,2})(,\s\d{4})(\sat\s\d{1,2}:\d{1,2}\s[AP]M)/)
.map((m, i) => {
if (i === 2) {
let day = parseInt(m);
Expand All @@ -157,7 +154,7 @@ module.exports = config({
return `${day}th`;
}
if (i === 4) {
return ` at${m} EST`;
return ` ${m} EST`;
}
return m;
})
Expand Down
Loading

0 comments on commit 10dc121

Please sign in to comment.