├── .devcontainer ├── Dockerfile └── devcontainer.json ├── .editorconfig ├── .github ├── AUTHORS.md ├── CODEOWNERS ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── FUNDING.yml ├── ISSUE_TEMPLATE │ ├── bug_report.yml │ ├── config.yml │ └── feature_request.yml ├── LICENSE ├── SECURITY.md ├── dependabot.yml ├── issue_label_bot.yml ├── lock.yml ├── pull_request_template.md ├── stale.yml └── workflows │ ├── build.yml │ ├── coverage.yml │ ├── lint.yml │ ├── stable.yml │ └── test.yml ├── .husky ├── commit-msg └── pre-commit ├── .lintstagedrc ├── .nvmrc ├── .releaserc ├── .vscode ├── extensions.json ├── settings.json └── tasks.json ├── README.md ├── biome.json ├── commitlint.config.js ├── docs ├── .vitepress │ ├── assets │ │ ├── bundlephobia-icon.svg │ │ ├── jsdelivr-icon.svg │ │ ├── npm-icon.svg │ │ └── packagephobia-icon.svg │ ├── config.ts │ ├── meta │ │ ├── head-config.ts │ │ ├── routes.ts │ │ └── social-links.ts │ └── theme │ │ ├── custom.css │ │ └── index.ts └── src │ ├── clients │ ├── berry-client.md │ ├── contest-client.md │ ├── encounter-client.md │ ├── evolution-client.md │ ├── game-client.md │ ├── item-client.md │ ├── location-client.md │ ├── machine-client.md │ ├── main-client.md │ ├── move-client.md │ ├── pokemon-client.md │ └── utility-client.md │ ├── guides │ ├── cache.md │ ├── contributing.md │ ├── getting-started.md │ └── logging.md │ ├── index.md │ ├── public │ ├── .nojekyll │ ├── _headers │ ├── cover.jpg │ ├── robots.txt │ └── site-logo.svg │ └── typings │ ├── berry-typings.md │ ├── common-typings.md │ ├── contest-typings.md │ ├── encounter-typings.md │ ├── evolution-typings.md │ ├── game-typings.md │ ├── item-typings.md │ ├── location-typings.md │ ├── machine-typings.md │ ├── move-typings.md │ └── pokemon-typings.md ├── package.json ├── pnpm-lock.yaml ├── sonar.properties ├── src ├── clients │ ├── base.ts │ ├── berry.client.ts │ ├── contest.client.ts │ ├── encounter.client.ts │ ├── evolution.client.ts │ ├── game.client.ts │ ├── index.ts │ ├── item.client.ts │ ├── location.client.ts │ ├── machine.client.ts │ ├── main.client.ts │ ├── move.client.ts │ ├── pokemon.client.ts │ └── utility.client.ts ├── config │ └── logger.ts ├── constants │ ├── base.ts │ ├── berries.ts │ ├── contests.ts │ ├── encounters.ts │ ├── endpoints.ts │ ├── evolutions.ts │ ├── games.ts │ ├── index.ts │ ├── items.ts │ ├── locations.ts │ ├── moves.ts │ ├── pokemons.ts │ └── utilities.ts ├── index.ts └── models │ ├── Berry │ ├── berry.ts │ └── index.ts │ ├── Common │ ├── description.ts │ ├── effect.ts │ ├── encounter.ts │ ├── flavor-text.ts │ ├── generation.ts │ ├── index.ts │ ├── language.ts │ ├── machine.ts │ ├── name.ts │ ├── resource.ts │ ├── verbose.ts │ └── version.ts │ ├── Contest │ ├── contest.ts │ └── index.ts │ ├── Encounter │ ├── encounter.ts │ └── index.ts │ ├── Evolution │ ├── evolution.ts │ └── index.ts │ ├── Game │ ├── generation.ts │ ├── index.ts │ ├── pokedex.ts │ ├── pokemon-entry.ts │ └── version.ts │ ├── Item │ ├── index.ts │ └── item.ts │ ├── Location │ ├── encounter.ts │ ├── index.ts │ ├── location.ts │ ├── palpark.ts │ └── region.ts │ ├── Machine │ ├── index.ts │ └── machine.ts │ ├── Moves │ ├── index.ts │ └── moves.ts │ ├── Pokemon │ ├── ability.ts │ ├── characteristics.ts │ ├── egg-group.ts │ ├── gender.ts │ ├── growth-rates.ts │ ├── index.ts │ ├── nature.ts │ ├── pokeathlon-stat.ts │ ├── pokemon.ts │ ├── stats.ts │ └── type.ts │ └── index.ts ├── tests ├── berry │ ├── berry.spec.ts │ ├── berry.test-d.ts │ └── mocks │ │ ├── data.ts │ │ └── handlers.ts ├── contest │ ├── contest.spec.ts │ └── contest.test-d.ts ├── encounter │ ├── encounter.spec.ts │ └── encouter.test-d.ts ├── evolution │ ├── evolution.spec.ts │ └── evolution.test-d.ts ├── game │ ├── game.spec.ts │ └── game.test-d.ts ├── item │ ├── item.spec.ts │ └── item.test-d.ts ├── location │ ├── location.spec.ts │ └── location.test-d.ts ├── logger │ └── logger.spec.ts ├── machine │ ├── machine.spec.ts │ └── machine.test-d.ts ├── main │ ├── main.spec.ts │ └── main.test-d.ts ├── move │ ├── move.spec.ts │ └── move.test-d.ts ├── pokemon │ ├── pokemon.spec.ts │ └── pokemon.test-d.ts ├── utility │ ├── utility.spec.ts │ └── utility.test-d.ts └── utils │ ├── base-handler.ts │ └── setup.ts ├── tsconfig.json ├── tsup.config.ts └── vitest.config.ts /.devcontainer/Dockerfile: -------------------------------------------------------------------------------- 1 | # [Choice] Node.js version (use -bullseye variants on local arm64/Apple Silicon) 2 | ARG VARIANT=20 3 | FROM mcr.microsoft.com/vscode/devcontainers/typescript-node:${VARIANT} 4 | 5 | # Update package lists and upgrade existing packages 6 | RUN apt-get update && \ 7 | apt-get upgrade -y && \ 8 | apt-get clean && \ 9 | rm -rf /var/lib/apt/lists/* 10 | -------------------------------------------------------------------------------- /.devcontainer/devcontainer.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://raw.githubusercontent.com/devcontainers/spec/main/schemas/devContainer.schema.json", 3 | "name": "Pokenode-ts (Node.js & TypeScript)", 4 | "build": { 5 | "dockerfile": "Dockerfile", 6 | "args": { 7 | "VARIANT": "20" 8 | } 9 | }, 10 | "customizations": { 11 | "codespaces": { 12 | "openFiles": ["README.md"] 13 | }, 14 | "vscode": { 15 | "extensions": [ 16 | "editorconfig.editorconfig", 17 | "eamodio.gitlens", 18 | "wix.vscode-import-cost", 19 | "visualstudioexptteam.vscodeintellicode", 20 | "xabikos.javascriptsnippets", 21 | "ms-vscode.vscode-typescript-next", 22 | "ms-vscode.js-debug-nightly", 23 | "yzhang.markdown-all-in-one", 24 | "christian-kohler.path-intellisense", 25 | "biomejs.biome", 26 | "ms-azuretools.vscode-docker", 27 | "tamasfe.even-better-toml", 28 | "Catppuccin.catppuccin-vsc", 29 | "Catppuccin.catppuccin-vsc-icons", 30 | "github.vscode-github-actions" 31 | ], 32 | "settings": { 33 | "explorer.confirmDelete": false, 34 | "security.workspace.trust.untrustedFiles": "open", 35 | "workbench.startupEditor": "none", 36 | "typescript.tsserver.log": "off", 37 | "editor.defaultFormatter": "biomejs.biome", 38 | "editor.formatOnSave": true, 39 | "files.autoSave": "off", 40 | "explorer.confirmDragAndDrop": false, 41 | "workbench.colorTheme": "Catppuccin Mocha", 42 | "workbench.iconTheme": "catppuccin-mocha" 43 | } 44 | } 45 | }, 46 | "forwardPorts": [9527], 47 | "postCreateCommand": "pnpm install --frozen-lockfile", 48 | "remoteUser": "node" 49 | } 50 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # EditorConfig is awesome: https://EditorConfig.org 2 | 3 | root = true 4 | 5 | [*] 6 | indent_style = space 7 | indent_size = 2 8 | end_of_line = lf 9 | charset = utf-8 10 | trim_trailing_whitespace = true 11 | insert_final_newline = true 12 | curly_bracket_next_line = false 13 | spaces_around_operators = true 14 | 15 | [*.md] 16 | trim_trailing_whitespace = false 17 | -------------------------------------------------------------------------------- /.github/AUTHORS.md: -------------------------------------------------------------------------------- 1 | # Authors of pokenode-ts 2 | 3 | ## Gabriel (Gabb-c) 4 | 5 | - **GitHub:** [Gabb-c](https://github.com/Gabb-c) 6 | - **Email:** [gdgabrieldacunha71@gmail.com](mailto:gdgabrieldacunha71@gmail.com) 7 | 8 | --- 9 | 10 | Pokenode-ts is mostly created by [Gabriel](mailto:gdgabrieldacunha71@gmail.com), also known as [Gabb-c](https://github.com/Gabb-c) on GitHub. Feel free to contact Gabriel with any questions or collaborative opportunities. 11 | 12 | ## Contributing 13 | 14 | If you wish to contribute to this project, please see our [contribution guidelines](CONTRIBUTING.md). 15 | -------------------------------------------------------------------------------- /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | * @Gabb-c 2 | -------------------------------------------------------------------------------- /.github/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | ## Setup Environment 2 | 3 | Make sure you have Node.js installed; we recommend the [latest LTS version](https://nodejs.org/). 4 | 5 | 1. **Fork and Clone the Repository:** 6 | - [Fork this repository](https://help.github.com/articles/fork-a-repo/) to your GitHub account. 7 | - [Clone the forked repository](https://help.github.com/articles/cloning-a-repository/) to your local device. 8 | - [Codespaces configuration](https://github.com/Gabb-c/pokenode-ts/tree/main/.devcontainer) is available. 9 | 10 | 2. **Create a New Branch:** 11 | - Create a new branch for your changes: `git checkout -b MY_BRANCH_NAME`. 12 | 13 | 3. **Install pnpm:** 14 | - [Install pnpm](https://pnpm.io/installation) to manage project dependencies efficiently. 15 | 16 | 4. **Install Dependencies:** 17 | - Run `pnpm i` to install project dependencies. 18 | 19 | 5. **Development Branch:** 20 | - The primary development branch is called `dev`. Please submit pull requests against this branch. 21 | - During a release, important changes from `dev` are rebased to `main`, tested, and then rebased to `stable`. 22 | 23 | We really appreciate your contributions to Pokenode-ts! Please contact us if you have any queries or need assistance. 24 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | github: Gabb-c 2 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.yml: -------------------------------------------------------------------------------- 1 | name: Bug Report 2 | description: Create a bug report for Pokenode-ts 3 | labels: "template: bug" 4 | body: 5 | - type: markdown 6 | attributes: 7 | value: | 8 | Thank you for contributing to Pokenode-ts by reporting a bug! Please fill out the following details as thoroughly as possible. 9 | - type: markdown 10 | attributes: 11 | value: | 12 | ## Before You Begin 13 | - [ ] Verify that your issue doesn't already exist. 14 | 15 | - type: input 16 | attributes: 17 | label: Version of Pokenode-ts 18 | description: | 19 | Provide the version of Pokenode-ts where you encountered the bug. For example: 1.0.1-beta or commit hash. 20 | validations: 21 | required: true 22 | 23 | - type: input 24 | attributes: 25 | label: Node.js Version 26 | description: | 27 | Specify the version of Node.js you are using (e.g., 12.0.0). 28 | validations: 29 | required: true 30 | 31 | - type: input 32 | attributes: 33 | label: Operating System 34 | description: | 35 | Mention the operating system you are using (e.g., macOS, Windows). 36 | validations: 37 | required: true 38 | 39 | - type: textarea 40 | attributes: 41 | label: Bug Description 42 | description: | 43 | Provide a clear and concise description of the bug. 44 | 45 | validations: 46 | required: true 47 | 48 | - type: textarea 49 | attributes: 50 | label: Expected Behavior 51 | description: | 52 | Describe what you expected to happen. 53 | 54 | validations: 55 | required: true 56 | 57 | - type: textarea 58 | attributes: 59 | label: Steps to Reproduce 60 | description: | 61 | Outline the steps to reproduce the bug. Include code snippets or a link to a GitHub repository. Screenshots can be attached below. 62 | 63 | validations: 64 | required: true 65 | 66 | - type: markdown 67 | attributes: 68 | value: | 69 | ## Checklist Before Submitting 70 | - [ ] Verify that the steps you've provided are detailed and clear. 71 | - [ ] Ensure that contributors can follow the steps to reproduce the bug. 72 | - [ ] Your steps will be used to add integration tests to prevent the issue from recurring. 73 | 74 | - type: markdown 75 | attributes: 76 | value: | 77 | Thank you for your contribution to improving Pokenode-ts! 78 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/config.yml: -------------------------------------------------------------------------------- 1 | blank_issues_enabled: false 2 | #contact_links: 3 | # - name: Discord Server 4 | # url: https:// 5 | # about: Join in our Discord server! 6 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.yml: -------------------------------------------------------------------------------- 1 | name: Feature Request 2 | description: Create a feature request for Pokenode-ts 3 | labels: "template: story" 4 | body: 5 | - type: markdown 6 | attributes: 7 | value: | 8 | **Feature Request Form** 9 | Thank you for contributing to Pokenode-ts by submitting a feature request! Please fill out the following form with as much detail as possible. 10 | 11 | - type: markdown 12 | attributes: 13 | value: | 14 | **Note:** Feature requests will be converted to issues and labeled as Improvements. 15 | 16 | - type: textarea 17 | attributes: 18 | label: Feature Description 19 | description: A clear and concise description of the feature you'd like to request and your use case. 20 | validations: 21 | required: true 22 | 23 | - type: textarea 24 | attributes: 25 | label: Proposed Solution 26 | description: A clear and concise description of the solution you envision. 27 | validations: 28 | required: true 29 | 30 | - type: textarea 31 | attributes: 32 | label: Alternatives Considered 33 | description: Describe any alternative solutions or features you've considered. 34 | validations: 35 | required: true 36 | -------------------------------------------------------------------------------- /.github/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 Gabriel 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /.github/SECURITY.md: -------------------------------------------------------------------------------- 1 | # Reporting a Vulnerability 2 | 3 | Thank you for helping us keep Pokenode-ts secure. If you identify a security issue, we appreciate your responsible disclosure. Please take the following actions to report the vulnerability: 4 | 5 | 1. Go to the [GitHub Security Advisories page](https://github.com/Gabb-c/pokenode-ts/security/advisories/new). 6 | 2. Click on the `Get started` button to open a new private vulnerability report. 7 | 8 | When reporting a vulnerability, please include the following information: 9 | 10 | - **Description:** Give a full explanation of the vulnerability, including how it may be exploited. 11 | - **Reproduction Steps:** Clearly detail the processes for reproducing the vulnerability. 12 | - **Affected Versions:** Specify the Pokenode-ts versions impacted by the vulnerability. 13 | - **Mitigations/Workarounds:** If you find any mitigations or workarounds, please share them. 14 | 15 | It is crucial to highlight that new vulnerabilities are uncommon, but your dedication in reporting them allows us to enhance the security of Pokenode-ts. 16 | 17 | **Note:** Always use the most recent version of Pokenode-ts to keep your application as safe as possible. If relevant, give details about the version you tested when reporting the vulnerability. 18 | 19 | Thank you for your dedication to the security of Pokenode-ts. We look forward to analyzing your report and collaborating to fix any discovered issues. 20 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: github-actions 4 | directory: "./" 5 | schedule: 6 | interval: daily 7 | 8 | - package-ecosystem: npm 9 | directory: "./" 10 | schedule: 11 | interval: daily 12 | -------------------------------------------------------------------------------- /.github/issue_label_bot.yml: -------------------------------------------------------------------------------- 1 | label-alias: 2 | bug: 'kind/bug' 3 | feature_request: 'enhancement' 4 | question: 'question' 5 | -------------------------------------------------------------------------------- /.github/lock.yml: -------------------------------------------------------------------------------- 1 | # Configuration for lock-threads - https://github.com/dessant/lock-threads 2 | 3 | daysUntilLock: 365 4 | issue-lock-labels: "wontfix" 5 | lockComment: false 6 | -------------------------------------------------------------------------------- /.github/pull_request_template.md: -------------------------------------------------------------------------------- 1 | # Pull Request Template 2 | 3 | ## Checks and Guidelines 4 | 5 | 6 | * [ ] Have you checked that there aren't other open [Pull Requests](https://github.com/Gabb-c/pokenode-ts/pulls) for the same update/change? 7 | * [ ] Linting passed (`lint` and `lint:tsc`) 8 | * [ ] Tests added (if needed) 9 | * [ ] Tests passed (`test:dev`) 10 | * [ ] Build passed (`build`) 11 | 12 | 13 | 14 | ## Type of Change 15 | 16 | * [ ] Bug fix 17 | * [ ] New feature 18 | * [ ] Improvement 19 | * [ ] Breaking change 20 | * [ ] Documentation update 21 | * [ ] Security 22 | 23 | ## Describe the Changes 24 | 25 | * I've added this because... 26 | * Removed this because... 27 | 28 | * **Tests Information:** 29 | - [ ] Unit tests added and passed 30 | - [ ] Integration tests added and passed 31 | 32 | * **Breaking Change Explanation (if applicable):** 33 | - Briefly explain how users might be affected and what actions they need to take. 34 | 35 | * **Optional: Screenshot, Code Block, etc...** 36 | -------------------------------------------------------------------------------- /.github/stale.yml: -------------------------------------------------------------------------------- 1 | # Number of days of inactivity before an issue becomes stale 2 | daysUntilStale: 60 3 | # Number of days of inactivity before a stale issue is closed 4 | daysUntilClose: 7 5 | # Issues with these labels will never be considered stale 6 | exemptLabels: 7 | - pinned 8 | - security 9 | # Label to use when marking an issue as stale 10 | staleLabel: wontfix 11 | # Comment to post when marking an issue as stale. Set to `false` to disable 12 | markComment: > 13 | This issue has been automatically marked as stale because it has not had 14 | recent activity. It will be closed if no further activity occurs. Thank you 15 | for your contributions. 16 | # Comment to post when closing a stale issue. Set to `false` to disable 17 | closeComment: > 18 | This issue has been automatically closed because it has not had 19 | recent activity. Thank you for your contributions. 20 | -------------------------------------------------------------------------------- /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | name: Build 2 | 3 | on: 4 | pull_request: 5 | branches: 6 | - "**" 7 | 8 | push: 9 | branches: 10 | - "**" 11 | 12 | jobs: 13 | build: 14 | runs-on: ubuntu-latest 15 | 16 | strategy: 17 | matrix: 18 | node-version: [lts/hydrogen, lts/iron, latest] 19 | 20 | steps: 21 | - name: Checkout Repository 22 | uses: actions/checkout@v4 23 | 24 | - uses: pnpm/action-setup@v4.0.0 25 | name: Install pnpm 26 | id: pnpm-install 27 | with: 28 | version: latest 29 | run_install: false 30 | 31 | - name: Set up Node.js ${{ matrix.node-version }} 32 | uses: actions/setup-node@v4.0.3 33 | with: 34 | node-version: ${{ matrix.node-version }} 35 | cache: pnpm 36 | 37 | - name: Install dependencies 38 | run: pnpm install --frozen-lockfile 39 | 40 | - name: Build 41 | run: pnpm build 42 | 43 | - name: Build Docs 44 | run: pnpm docs:build 45 | -------------------------------------------------------------------------------- /.github/workflows/coverage.yml: -------------------------------------------------------------------------------- 1 | name: Coverage 2 | 3 | on: 4 | push: 5 | branches: [main] 6 | 7 | jobs: 8 | coverage: 9 | runs-on: ubuntu-latest 10 | 11 | steps: 12 | - name: Checkout repository 13 | uses: actions/checkout@v4 14 | 15 | - name: Install pnpm 16 | uses: pnpm/action-setup@v4.0.0 17 | id: pnpm-install 18 | with: 19 | version: latest 20 | run_install: false 21 | 22 | - name: Setup Node.js lts/iron 23 | uses: actions/setup-node@v4.0.3 24 | with: 25 | node-version: lts/iron 26 | cache: pnpm 27 | 28 | - name: Install dependencies 29 | run: pnpm install --frozen-lockfile 30 | 31 | - name: Generate coverage report 32 | run: pnpm test:coverage 33 | 34 | - name: Upload coverage report to Codecov 35 | run: bash <(curl -s https://codecov.io/bash) 36 | env: 37 | CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} 38 | -------------------------------------------------------------------------------- /.github/workflows/lint.yml: -------------------------------------------------------------------------------- 1 | name: Lint 2 | 3 | on: 4 | pull_request: 5 | branches: 6 | - "**" 7 | 8 | push: 9 | branches: 10 | - "**" 11 | 12 | jobs: 13 | lint: 14 | runs-on: ubuntu-latest 15 | steps: 16 | - name: Checkout Repository 17 | uses: actions/checkout@v4 18 | 19 | - uses: pnpm/action-setup@v4.0.0 20 | name: Install pnpm 21 | id: pnpm-install 22 | with: 23 | version: latest 24 | run_install: false 25 | 26 | - name: Setup Node.js lts/iron 27 | uses: actions/setup-node@v4.0.3 28 | with: 29 | node-version: lts/iron 30 | cache: pnpm 31 | 32 | - name: Install dependencies 33 | run: pnpm install --frozen-lockfile 34 | 35 | - name: Lint 36 | run: pnpm lint:ci 37 | -------------------------------------------------------------------------------- /.github/workflows/stable.yml: -------------------------------------------------------------------------------- 1 | name: Publish 2 | 3 | on: 4 | push: 5 | branches: [stable] 6 | 7 | jobs: 8 | build: 9 | runs-on: ubuntu-latest 10 | 11 | steps: 12 | - name: Checkout Repository 13 | uses: actions/checkout@v4 14 | 15 | - uses: pnpm/action-setup@v4.0.0 16 | name: Install pnpm 17 | id: pnpm-install 18 | with: 19 | version: latest 20 | run_install: false 21 | 22 | - name: Setup Node.js lts/iron 23 | uses: actions/setup-node@v4.0.3 24 | with: 25 | node-version: lts/iron 26 | cache: pnpm 27 | 28 | - name: Install dependencies 29 | run: pnpm install --frozen-lockfile 30 | 31 | - name: Build 32 | run: pnpm build 33 | 34 | - name: Test 35 | run: pnpm test 36 | 37 | release: 38 | name: Release 39 | if: ${{ github.ref == 'refs/heads/stable' }} 40 | needs: build 41 | runs-on: ubuntu-latest 42 | steps: 43 | - name: Checkout 44 | uses: actions/checkout@v4 45 | 46 | - uses: pnpm/action-setup@v4.0.0 47 | name: Install pnpm 48 | id: pnpm-install 49 | with: 50 | version: latest 51 | run_install: false 52 | 53 | - name: Install dependencies 54 | run: pnpm install --frozen-lockfile 55 | 56 | - name: Semantic Release 57 | uses: cycjimmy/semantic-release-action@v4.1.0 58 | with: 59 | extra_plugins: | 60 | @semantic-release/git 61 | env: 62 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 63 | NPM_TOKEN: ${{ secrets.NPM_TOKEN }} 64 | -------------------------------------------------------------------------------- /.github/workflows/test.yml: -------------------------------------------------------------------------------- 1 | name: Test 2 | 3 | on: 4 | pull_request: 5 | branches: 6 | - "**" 7 | 8 | push: 9 | branches: 10 | - "**" 11 | 12 | jobs: 13 | test: 14 | runs-on: ubuntu-latest 15 | steps: 16 | - name: Checkout repository 17 | uses: actions/checkout@v4 18 | 19 | - name: Install pnpm 20 | uses: pnpm/action-setup@v4.0.0 21 | id: pnpm-install 22 | with: 23 | version: latest 24 | run_install: false 25 | 26 | - name: Setup Node.js lts/iron 27 | uses: actions/setup-node@v4.0.3 28 | with: 29 | node-version: lts/iron 30 | cache: pnpm 31 | 32 | - name: Install dependencies 33 | run: pnpm install --frozen-lockfile 34 | 35 | - name: Run tests (Unit) 36 | run: pnpm test 37 | 38 | - name: Run tests (Typecheck) 39 | run: pnpm test:types 40 | -------------------------------------------------------------------------------- /.husky/commit-msg: -------------------------------------------------------------------------------- 1 | echo 'Linting commit message...' 2 | pnpm commitlint --edit $1 3 | -------------------------------------------------------------------------------- /.husky/pre-commit: -------------------------------------------------------------------------------- 1 | pnpm lint-staged 2 | -------------------------------------------------------------------------------- /.lintstagedrc: -------------------------------------------------------------------------------- 1 | { 2 | "*.{js,ts,cjs,mjs,d.cts,d.mts,jsx,tsx,json,jsonc}": [ 3 | "biome check --staged --apply-unsafe --no-errors-on-unmatched" 4 | ], 5 | "src/**/*.ts": ["tsc --noEmit"] 6 | } 7 | -------------------------------------------------------------------------------- /.nvmrc: -------------------------------------------------------------------------------- 1 | lts/jod 2 | -------------------------------------------------------------------------------- /.releaserc: -------------------------------------------------------------------------------- 1 | { 2 | "branches": ["stable"], 3 | "plugins": [ 4 | "@semantic-release/commit-analyzer", 5 | "@semantic-release/release-notes-generator", 6 | "@semantic-release/changelog", 7 | "@semantic-release/npm", 8 | [ 9 | "@semantic-release/git", 10 | { 11 | "assets": ["package.json"], 12 | "message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}" 13 | } 14 | ], 15 | [ 16 | "@semantic-release/github", 17 | { 18 | "assets": [ 19 | { 20 | "path": "lib/index.mjs", 21 | "label": "ES Module" 22 | }, 23 | { 24 | "path": "lib/index.js", 25 | "label": "Common JS" 26 | }, 27 | { 28 | "path": "lib/index.d.ts", 29 | "label": "Typings" 30 | } 31 | ] 32 | } 33 | ] 34 | ] 35 | } 36 | -------------------------------------------------------------------------------- /.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | "recommendations": [ 3 | "editorconfig.editorconfig", 4 | "eamodio.gitlens", 5 | "wix.vscode-import-cost", 6 | "visualstudioexptteam.vscodeintellicode", 7 | "xabikos.javascriptsnippets", 8 | "ms-vscode.vscode-typescript-next", 9 | "ms-vscode.js-debug-nightly", 10 | "yzhang.markdown-all-in-one", 11 | "christian-kohler.path-intellisense", 12 | "biomejs.biome", 13 | "ms-azuretools.vscode-docker", 14 | "tamasfe.even-better-toml", 15 | "github.vscode-github-actions" 16 | ] 17 | } 18 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "explorer.confirmDelete": false, 3 | "workbench.startupEditor": "none", 4 | "typescript.tsserver.log": "off", 5 | "editor.defaultFormatter": "biomejs.biome", 6 | "editor.formatOnSave": true, 7 | "git.autofetch": true, 8 | "workbench.iconTheme": "catppuccin-mocha", 9 | "workbench.colorTheme": "Catppuccin Mocha", 10 | "typescript.updateImportsOnFileMove.enabled": "always", 11 | "git.confirmSync": false, 12 | "explorer.confirmDragAndDrop": false, 13 | "[markdown]": { 14 | "editor.defaultFormatter": "yzhang.markdown-all-in-one" 15 | }, 16 | "testing.automaticallyOpenPeekView": "never" 17 | } 18 | -------------------------------------------------------------------------------- /.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "2.0.0", 3 | "tasks": [ 4 | { 5 | "type": "npm", 6 | "script": "build", 7 | "group": { 8 | "kind": "build", 9 | "isDefault": true 10 | }, 11 | "problemMatcher": [], 12 | "label": "Build", 13 | "detail": "pnpm build" 14 | }, 15 | { 16 | "type": "npm", 17 | "script": "test", 18 | "problemMatcher": [], 19 | "label": "Test (development)", 20 | "detail": "pnpm test", 21 | "group": { 22 | "kind": "test", 23 | "isDefault": true 24 | } 25 | } 26 | ] 27 | } 28 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Pokenode-ts 2 | 3 | **Pokenode-ts** is a lightweight Node.js wrapper for the PokéAPI with built-in types. It provides an easy way to integrate your application with the PokéAPI. 4 | 5 | ## Features 6 | 7 | - 🛠️ **Built-in typings**: TypeScript support with pre-defined types. 8 | - 📦 **Axios with auto-cache requests**: Efficiently manage API requests with automatic caching. 9 | - 🌲 **Logging**: Easily log and track your API interactions. 10 | 11 | ## Installation 12 | 13 | ```bash 14 | # NPM 15 | npm install axios axios-cache-interceptor pokenode-ts 16 | 17 | # Yarn 18 | yarn add axios axios-cache-interceptor pokenode-ts 19 | 20 | # Pnpm 21 | pnpm add axios axios-cache-interceptor pokenode-ts 22 | ``` 23 | 24 | ## Basic Example 25 | 26 | ```ts 27 | import { PokemonClient } from 'pokenode-ts'; // Import the Client 28 | 29 | const pokemon = await api.getPokemonByName('luxray') // Make the request 30 | .catch(() => console.log("Oops!")); 31 | 32 | console.log(pokemon.name); // Typesafe response ✨ (Outputs "Luxray") 33 | ``` 34 | 35 | ## Documentation 36 | 37 | Check out our [Documentation page](https://pokenode-ts.vercel.app/)! 38 | 39 | ## Security 40 | 41 | Every change in this project is analyzed by [SonarCloud](https://sonarcloud.io/) 42 | 43 | [![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=Gabb-c_pokenode-ts&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=Gabb-c_pokenode-ts 'Sonar Quality Gate Status') 44 | [![Bugs](https://sonarcloud.io/api/project_badges/measure?project=Gabb-c_pokenode-ts&metric=bugs)](https://sonarcloud.io/summary/new_code?id=Gabb-c_pokenode-ts 'Sonar Bugs') 45 | [![Code Smells](https://sonarcloud.io/api/project_badges/measure?project=Gabb-c_pokenode-ts&metric=code_smells)](https://sonarcloud.io/summary/new_code?id=Gabb-c_pokenode-ts 'Sonar Code Smells') 46 | [![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=Gabb-c_pokenode-ts&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=Gabb-c_pokenode-ts 'Sonar Quality Gate Status') 47 | [![codecov](https://codecov.io/gh/Gabb-c/pokenode-ts/branch/master/graph/badge.svg?token=whfY8GNSpS)](https://codecov.io/gh/Gabb-c/pokenode-ts 'Codecov Coverage Reports') 48 | 49 | ## Leave your feedback 50 | 51 | - Did you like pokenode-ts? [Give us a star ⭐](https://github.com/Gabb-c/pokenode-ts) 52 | - Found a problem? Let us know by [creating an issue 🔎](https://github.com/Gabb-c/pokenode-ts/issues) 53 | - Want to contribute? [Submit a PR 📑](https://github.com/Gabb-c/pokenode-ts/pulls) 54 | 55 | ## Donate 56 | 57 | If pokenode-ts is valuable to you, please consider [buying me a coffee](https://github.com/sponsors/Gabb-c) ❤️ 58 | 59 | ![Analytics](https://repobeats.axiom.co/api/embed/f71a113e3161e1d054170c94e4ac3fcfc960cdd4.svg 'Repobeats analytics image') 60 | -------------------------------------------------------------------------------- /biome.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://biomejs.dev/schemas/1.9.4/schema.json", 3 | "vcs": { 4 | "enabled": true, 5 | "clientKind": "git", 6 | "useIgnoreFile": true 7 | }, 8 | "organizeImports": { 9 | "enabled": true 10 | }, 11 | "linter": { 12 | "enabled": true, 13 | "rules": { 14 | "recommended": true 15 | }, 16 | "ignore": ["node_modules", "lib"] 17 | }, 18 | "formatter": { 19 | "enabled": true, 20 | "formatWithErrors": true, 21 | "indentStyle": "space", 22 | "indentWidth": 2, 23 | "lineWidth": 100, 24 | "lineEnding": "lf", 25 | "ignore": ["node_modules", "lib"] 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /commitlint.config.js: -------------------------------------------------------------------------------- 1 | export default { 2 | extends: ["@commitlint/config-conventional"], 3 | }; 4 | -------------------------------------------------------------------------------- /docs/.vitepress/assets/bundlephobia-icon.svg: -------------------------------------------------------------------------------- 1 | 2 | Bundle Phobia 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 26 | 27 | 28 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /docs/.vitepress/assets/jsdelivr-icon.svg: -------------------------------------------------------------------------------- 1 | 2 | jsDelivr 3 | 5 | -------------------------------------------------------------------------------- /docs/.vitepress/assets/npm-icon.svg: -------------------------------------------------------------------------------- 1 | 2 | npm 3 | 5 | -------------------------------------------------------------------------------- /docs/.vitepress/assets/packagephobia-icon.svg: -------------------------------------------------------------------------------- 1 | 2 | Package Phobia 3 | 6 | 7 | -------------------------------------------------------------------------------- /docs/.vitepress/config.ts: -------------------------------------------------------------------------------- 1 | import { readFileSync } from "node:fs"; 2 | import { resolve } from "node:path"; 3 | import { defineConfig } from "vitepress"; 4 | 5 | import { author, license, description as packageDescription } from "../../package.json"; 6 | import { headConfig } from "./meta/head-config"; 7 | import { navbarItems, sidebarRoutes } from "./meta/routes"; 8 | import { SOCIAL_LINKS } from "./meta/social-links"; 9 | 10 | const readSvg = (fileName: string): string => 11 | readFileSync(resolve(`./docs/.vitepress/assets/${fileName}`), "utf-8"); 12 | 13 | export default defineConfig({ 14 | title: "Pokenode-ts", 15 | description: packageDescription, 16 | lang: "en-US", 17 | srcDir: "./src", 18 | lastUpdated: true, 19 | head: headConfig, 20 | sitemap: { 21 | hostname: "https://pokenode-ts.vercel.app", 22 | }, 23 | themeConfig: { 24 | nav: navbarItems, 25 | sidebar: sidebarRoutes, 26 | siteTitle: "Pokenode-ts", 27 | logo: { src: "/site-logo.svg", width: 24, height: 24 }, 28 | footer: { 29 | message: `Made with ❤️
Released under the ${license} License`, 30 | copyright: `Copyright © 2021-${new Date().getFullYear()} ${author.name}`, 31 | }, 32 | socialLinks: [ 33 | { icon: "github", link: SOCIAL_LINKS.GITHUB.link }, 34 | { icon: { svg: readSvg(SOCIAL_LINKS.NPM.path) }, link: SOCIAL_LINKS.NPM.link }, 35 | { 36 | icon: { svg: readSvg(SOCIAL_LINKS.JSDELIVR.path) }, 37 | link: SOCIAL_LINKS.JSDELIVR.link, 38 | }, 39 | { 40 | icon: { svg: readSvg(SOCIAL_LINKS.BUNDLEPHOBIA.path) }, 41 | link: SOCIAL_LINKS.BUNDLEPHOBIA.link, 42 | }, 43 | { 44 | icon: { svg: readSvg(SOCIAL_LINKS.PACKAGEPHOBIA.path) }, 45 | link: SOCIAL_LINKS.PACKAGEPHOBIA.link, 46 | }, 47 | ], 48 | editLink: { 49 | pattern: "https://github.com/Gabb-c/pokenode-ts/edit/main/docs/src/:path", 50 | text: "Suggest changes to this page", 51 | }, 52 | search: { 53 | provider: "local", 54 | }, 55 | carbonAds: { 56 | code: "CEBDT27Y", 57 | placement: "vuejsorg", 58 | }, 59 | }, 60 | cleanUrls: true, 61 | }); 62 | -------------------------------------------------------------------------------- /docs/.vitepress/meta/head-config.ts: -------------------------------------------------------------------------------- 1 | import type { HeadConfig } from "vitepress"; 2 | import { name, description as packageDescription } from "../../../package.json"; 3 | 4 | export const headConfig: HeadConfig[] = [ 5 | ["link", { rel: "icon", href: "/site-logo.svg", type: "image/svg+xml" }], 6 | [ 7 | "link", 8 | { rel: "apple-touch-icon", sizes: "57x57", href: "/site-logo.svg", type: "image/svg+xml" }, 9 | ], 10 | [ 11 | "link", 12 | { rel: "apple-touch-icon", sizes: "60x60", href: "/site-logo.svg", type: "image/svg+xml" }, 13 | ], 14 | [ 15 | "link", 16 | { rel: "apple-touch-icon", sizes: "72x72", href: "/site-logo.svg", type: "image/svg+xml" }, 17 | ], 18 | [ 19 | "link", 20 | { rel: "apple-touch-icon", sizes: "76x76", href: "/site-logo.svg", type: "image/svg+xml" }, 21 | ], 22 | [ 23 | "link", 24 | { 25 | rel: "apple-touch-icon", 26 | sizes: "114x114", 27 | href: "/site-logo.svg", 28 | type: "image/svg+xml", 29 | }, 30 | ], 31 | [ 32 | "link", 33 | { 34 | rel: "apple-touch-icon", 35 | sizes: "120x120", 36 | href: "/site-logo.svg", 37 | type: "image/svg+xml", 38 | }, 39 | ], 40 | [ 41 | "link", 42 | { 43 | rel: "apple-touch-icon", 44 | sizes: "144x144", 45 | href: "/site-logo.svg", 46 | type: "image/svg+xml", 47 | }, 48 | ], 49 | [ 50 | "link", 51 | { 52 | rel: "apple-touch-icon", 53 | sizes: "152x152", 54 | href: "/site-logo.svg", 55 | type: "image/svg+xml", 56 | }, 57 | ], 58 | [ 59 | "link", 60 | { 61 | rel: "apple-touch-icon", 62 | sizes: "180x180", 63 | href: "/site-logo.svg", 64 | type: "image/svg+xml", 65 | }, 66 | ], 67 | [ 68 | "link", 69 | { 70 | rel: "icon", 71 | sizes: "192x192", 72 | href: "/site-logo.svg", 73 | type: "image/svg+xml", 74 | }, 75 | ], 76 | [ 77 | "link", 78 | { 79 | rel: "icon", 80 | sizes: "32x32", 81 | href: "/site-logo.svg", 82 | type: "image/svg+xml", 83 | }, 84 | ], 85 | [ 86 | "link", 87 | { 88 | rel: "icon", 89 | sizes: "96x96", 90 | href: "/site-logo.svg", 91 | type: "image/svg+xml", 92 | }, 93 | ], 94 | [ 95 | "link", 96 | { 97 | rel: "icon", 98 | sizes: "16x16", 99 | href: "/site-logo.svg", 100 | type: "image/svg+xml", 101 | }, 102 | ], 103 | ["meta", { property: "og:type", content: "website" }], 104 | ["meta", { name: "theme-color", content: "#FF3962" }], 105 | ["meta", { property: "og:locale", content: "en" }], 106 | ["meta", { property: "og:title", content: `${name} | ${packageDescription}` }], 107 | ["meta", { property: "og:url", content: "https://pokenode-ts.vercel.app/" }], 108 | ["meta", { property: "og:description", content: packageDescription }], 109 | ["meta", { property: "og:image", content: "/cover.jpg" }], 110 | ]; 111 | -------------------------------------------------------------------------------- /docs/.vitepress/meta/social-links.ts: -------------------------------------------------------------------------------- 1 | type SocialLink = { link: string; path: string }; 2 | type SocialLinksKeys = Record; 3 | 4 | export const SOCIAL_LINKS: SocialLinksKeys = { 5 | GITHUB: { link: "https://github.com/Gabb-c/pokenode-ts", path: "" }, 6 | NPM: { link: "https://www.npmjs.com/package/pokenode-ts", path: "npm-icon.svg" }, 7 | JSDELIVR: { link: "https://www.jsdelivr.com/package/npm/pokenode-ts", path: "jsdelivr-icon.svg" }, 8 | BUNDLEPHOBIA: { 9 | link: "https://bundlephobia.com/package/pokenode-ts", 10 | path: "bundlephobia-icon.svg", 11 | }, 12 | PACKAGEPHOBIA: { 13 | link: "https://packagephobia.com/result?p=pokenode-ts", 14 | path: "packagephobia-icon.svg", 15 | }, 16 | } as const; 17 | -------------------------------------------------------------------------------- /docs/.vitepress/theme/custom.css: -------------------------------------------------------------------------------- 1 | :root { 2 | --vp-c-brand-1: hsl(346, 100%, 58%); 3 | --vp-c-brand-2: hsl(346, 100%, 75%); 4 | 5 | --vp-button-brand-bg: hsl(346, 100%, 58%); 6 | --vp-button-brand-active-bg: hsla(346, 100%, 58%, 0.365); 7 | --vp-button-brand-hover-bg: hsl(346, 100%, 75%); 8 | 9 | --vp-c-brand-light: hsla(346, 100%, 58%, 0.365); 10 | --vp-c-brand-lighter: hsla(346, 100%, 75%, 0.365); 11 | --vp-c-brand-dark: hsl(346, 100%, 58%); 12 | --vp-c-brand-darker: hsl(346, 100%, 58%); 13 | 14 | --vp-home-hero-name-color: transparent; 15 | --vp-home-hero-name-background: -webkit-linear-gradient(120deg, #FF3962 30%, #D3D3D3); 16 | 17 | --vp-home-hero-image-background-image: linear-gradient(-45deg, #FF3962 50%, #D3D3D3 50%); 18 | --vp-home-hero-image-filter: blur(44px); 19 | } 20 | 21 | @media (min-width: 640px) { 22 | :root { 23 | --vp-home-hero-image-filter: blur(56px); 24 | } 25 | } 26 | 27 | @media (min-width: 960px) { 28 | :root { 29 | --vp-home-hero-image-filter: blur(72px); 30 | } 31 | } 32 | 33 | html { 34 | scroll-behavior: smooth; 35 | overflow-x: hidden; 36 | } 37 | 38 | /* Define scrollbar track */ 39 | ::-webkit-scrollbar { 40 | width: 10px; /* Adjust as needed */ 41 | } 42 | 43 | /* Define scrollbar thumb */ 44 | ::-webkit-scrollbar-thumb { 45 | background-color: #FF3962; /* Match the main color */ 46 | border-radius: 5px; /* Rounded corners */ 47 | } 48 | 49 | /* Define scrollbar track on hover */ 50 | ::-webkit-scrollbar-thumb:hover { 51 | background-color: #FF3962; /* Match the main color */ 52 | } 53 | 54 | /* Define scrollbar track */ 55 | ::-webkit-scrollbar-track { 56 | background-color: transparent; /* Make scrollbar background transparent */ 57 | border-radius: 5px; /* Rounded corners */ 58 | } 59 | 60 | ::selection { 61 | background-color: #FF3962; /* Change to the desired color */ 62 | color: #FFFFFF; /* Change to the desired text color */ 63 | } 64 | -------------------------------------------------------------------------------- /docs/.vitepress/theme/index.ts: -------------------------------------------------------------------------------- 1 | import Theme from "vitepress/theme"; 2 | import "./custom.css"; 3 | 4 | export default Theme; 5 | -------------------------------------------------------------------------------- /docs/src/clients/berry-client.md: -------------------------------------------------------------------------------- 1 | # Berry Client 2 | 3 | The Berry Client provide methods to access the Berry Endpoinds 4 | 5 | - `getBerryByName` 6 | - `getBerryById` 7 | - `getBerryFirmnessByName` 8 | - `getBerryFirmnessById` 9 | - `getBerryFlavorByName` 10 | - `getBerryFlavorById` 11 | - `listBerries` 12 | - `listBerryFirmness` 13 | - `listBerryFlavors` 14 | 15 | ## Example 16 | 17 | ```js 18 | import { BerryClient } from 'pokenode-ts'; // import the BerryClient 19 | 20 | (async () => { 21 | const api = new BerryClient(); // create a BerryClient 22 | 23 | await api 24 | .getBerryByName('cheri') 25 | .then((data) => console.log(data)) 26 | .catch((error) => console.error(error)); 27 | })(); 28 | ``` 29 | 30 | Or: 31 | 32 | ```js 33 | import { BerryClient, Berries } from 'pokenode-ts'; // import the BerryClient and the Berries enum 34 | 35 | (async () => { 36 | const api = new BerryClient(); // create a BerryClient 37 | 38 | await api 39 | .getBerryById(Berries.CHERI) 40 | .then((data) => console.log(data)) 41 | .catch((error) => console.error(error)); 42 | })(); 43 | ``` 44 | 45 | Will output: 46 | 47 | ```json 48 | { 49 | "firmness": { 50 | "name": "soft", 51 | "url": "https://pokeapi.co/api/v2/berry-firmness/2/" 52 | }, 53 | "flavors": [ 54 | { 55 | "flavor": { 56 | "name": "spicy", 57 | "url": "https://pokeapi.co/api/v2/berry-flavor/1/" 58 | }, 59 | "potency": 10 60 | }, 61 | { 62 | "flavor": { 63 | "name": "dry", 64 | "url": "https://pokeapi.co/api/v2/berry-flavor/2/" 65 | }, 66 | "potency": 0 67 | }, 68 | { 69 | "flavor": { 70 | "name": "sweet", 71 | "url": "https://pokeapi.co/api/v2/berry-flavor/3/" 72 | }, 73 | "potency": 0 74 | }, 75 | { 76 | "flavor": { 77 | "name": "bitter", 78 | "url": "https://pokeapi.co/api/v2/berry-flavor/4/" 79 | }, 80 | "potency": 0 81 | }, 82 | { 83 | "flavor": { 84 | "name": "sour", 85 | "url": "https://pokeapi.co/api/v2/berry-flavor/5/" 86 | }, 87 | "potency": 0 88 | } 89 | ], 90 | "growth_time": 3, 91 | "id": 1, 92 | "item": { 93 | "name": "cheri-berry", 94 | "url": "https://pokeapi.co/api/v2/item/126/" 95 | }, 96 | "max_harvest": 5, 97 | "name": "cheri", 98 | "natural_gift_power": 60, 99 | "natural_gift_type": { 100 | "name": "fire", 101 | "url": "https://pokeapi.co/api/v2/type/10/" 102 | }, 103 | "size": 20, 104 | "smoothness": 25, 105 | "soil_dryness": 15 106 | } 107 | ``` 108 | 109 | ::: tip 110 | For more information about the Berry Client endpoints, check out the [PokéAPI Documentation](https://pokeapi.co/docs/v2#berries-section). 111 | ::: 112 | -------------------------------------------------------------------------------- /docs/src/clients/contest-client.md: -------------------------------------------------------------------------------- 1 | # Contest Client 2 | 3 | ## Usage 4 | 5 | The Contest Client provide methods to access the [Contest Endpoinds](https://pokeapi.co/docs/v2#contests-section): 6 | 7 | - `getContestTypeByName` 8 | - `getContestTypeByID` 9 | - `getContestEffectById` 10 | - `getSuperContestEffectById` 11 | - `listContestTypes` 12 | - `listContestEffects` 13 | - `listSuperContestEffects` 14 | 15 | ## Example 16 | 17 | ```js 18 | import { ContestClient } from 'pokenode-ts'; // import the ContestClient 19 | 20 | (async () => { 21 | const api = new ContestClient(); // create a ContestClient 22 | 23 | await api 24 | .getContestTypeByName('tough') 25 | .then((data) => console.log(data)) 26 | .catch((error) => console.error(error)); 27 | })(); 28 | ``` 29 | 30 | Or: 31 | 32 | ```js 33 | import { ContestClient, ContestTypes } from 'pokenode-ts'; // import the ContestClient and the ContestTypes enum 34 | 35 | (async () => { 36 | const api = new ContestClient(); // create a ContestClient 37 | 38 | await api 39 | .getContestTypeById(ContestTypes.TOUGH) 40 | .then((data) => console.log(data)) 41 | .catch((error) => console.error(error)); 42 | })(); 43 | ``` 44 | 45 | Will output: 46 | 47 | ```json 48 | { 49 | "berry_flavor": { 50 | "name": "sour", 51 | "url": "https://pokeapi.co/api/v2/berry-flavor/5/" 52 | }, 53 | "id": 5, 54 | "name": "tough", 55 | "names": [ 56 | { 57 | "color": "Jaune", 58 | "language": { 59 | "name": "fr", 60 | "url": "https://pokeapi.co/api/v2/language/5/" 61 | }, 62 | "name": "Robustesse" 63 | }, 64 | { 65 | "color": "Yellow", 66 | "language": { 67 | "name": "en", 68 | "url": "https://pokeapi.co/api/v2/language/9/" 69 | }, 70 | "name": "Tough" 71 | } 72 | ] 73 | } 74 | ``` 75 | 76 | ## More 77 | 78 | > For more information about the Contest Client endpoints, check out the [PokéAPI Documentation](https://pokeapi.co/docs/v2#contests-section). 79 | -------------------------------------------------------------------------------- /docs/src/clients/encounter-client.md: -------------------------------------------------------------------------------- 1 | # Encounter Client 2 | 3 | ## Usage 4 | 5 | The Encounter Client provide methods to access the [Encounter Endpoinds](https://pokeapi.co/docs/v2#encounters-section): 6 | 7 | - `getEncounterMethodByName` 8 | - `getEncounterMethodByID` 9 | - `getEncounterConditionByName` 10 | - `getEncounterConditionById` 11 | - `getEncounterConditionValueByName` 12 | - `getEncounterConditionValueById` 13 | - `listEncunterMethods` 14 | - `listEncounterConditions` 15 | - `listEncounterConditionValues` 16 | 17 | ## Example 18 | 19 | ```js 20 | import { EncounterClient, EncounterMethods } from 'pokenode-ts'; // import the EncounterClient (EncounterMethods enum is fully optional) 21 | 22 | (async () => { 23 | const api = new EncounterClient(); // create an EncounterClient 24 | 25 | await api 26 | .getEncounterMethodById(EncounterMethods.SURF) 27 | .then((data) => console.log(data)) 28 | .catch((error) => console.error(error)); 29 | })(); 30 | ``` 31 | 32 | Will output: 33 | 34 | ```json 35 | { 36 | "id": 5, 37 | "name": "surf", 38 | "names": [ 39 | { 40 | "language": { 41 | "name": "de", 42 | "url": "https://pokeapi.co/api/v2/language/6/" 43 | }, 44 | "name": "Surfen" 45 | }, 46 | { 47 | "language": { 48 | "name": "en", 49 | "url": "https://pokeapi.co/api/v2/language/9/" 50 | }, 51 | "name": "Surfing" 52 | } 53 | ], 54 | "order": 14 55 | } 56 | ``` 57 | 58 | ## More 59 | 60 | > For more information about the Encounter Client endpoints, check out the [PokéAPI Documentation](https://pokeapi.co/docs/v2#encounters-section). 61 | -------------------------------------------------------------------------------- /docs/src/clients/evolution-client.md: -------------------------------------------------------------------------------- 1 | # Evolution Client 2 | 3 | ## Usage 4 | 5 | The Evolution Client provide methods to access the [Evolution Endpoinds](https://pokeapi.co/docs/v2#evolution-section): 6 | 7 | - `getEvolutionChainByID` 8 | - `getEvolutionTriggerByName` 9 | - `getEvolutionTriggerByID` 10 | - `listEvolutionChains` 11 | - `listEvolutionTriggers` 12 | 13 | ## Example 14 | 15 | ```js 16 | import { EvolutionClient } from 'pokenode-ts'; // import the EvolutionClient 17 | 18 | (async () => { 19 | const api = new EvolutinClient(); // create an EncounterClient 20 | 21 | await api 22 | .getEvolutionTriggerByName('level-up') 23 | .then((data) => console.log(data)) 24 | .catch((error) => console.error(error)); 25 | })(); 26 | ``` 27 | 28 | Or: 29 | 30 | ```js 31 | import { EvolutionClient, EvolutionTriggers } from 'pokenode-ts'; // import the EvolutionClient and the EvolutionTriggers enum 32 | 33 | (async () => { 34 | const api = new EvolutinClient(); // create an EncounterClient 35 | 36 | await api 37 | .getEvolutionTriggerById(EvolutionTriggers.LEVEL_UP) 38 | .then((data) => console.log(data)) 39 | .catch((error) => console.error(error)); 40 | })(); 41 | ``` 42 | 43 | Will output: 44 | 45 | ```json 46 | { 47 | "id": 1, 48 | "name": "level-up", 49 | "names": [ 50 | { 51 | "language": { 52 | "name": "fr", 53 | "url": "https://pokeapi.co/api/v2/language/5/" 54 | }, 55 | "name": "Montée de niveau" 56 | }, 57 | { 58 | "language": { 59 | "name": "de", 60 | "url": "https://pokeapi.co/api/v2/language/6/" 61 | }, 62 | "name": "Levelaufstieg" 63 | }, 64 | { 65 | "language": { 66 | "name": "en", 67 | "url": "https://pokeapi.co/api/v2/language/9/" 68 | }, 69 | "name": "Level up" 70 | } 71 | ], 72 | "pokemon_species": [ 73 | { 74 | "name": "ivysaur", 75 | "url": "https://pokeapi.co/api/v2/pokemon-species/2/" 76 | }, 77 | { 78 | "name": "venusaur", 79 | "url": "https://pokeapi.co/api/v2/pokemon-species/3/" 80 | }, 81 | ... 82 | ], 83 | } 84 | ``` 85 | 86 | ## More 87 | 88 | > For more information about the Evolution Client endpoints, check out the [PokéAPI Documentation](https://pokeapi.co/docs/v2#evolution-section). 89 | -------------------------------------------------------------------------------- /docs/src/clients/game-client.md: -------------------------------------------------------------------------------- 1 | # Game Client 2 | 3 | ## Usage 4 | 5 | The Game Client provide methods to access the [Game Endpoinds](https://pokeapi.co/docs/v2#games-section): 6 | 7 | - `getGenerationByName` 8 | - `getGenerationById` 9 | - `getPokedexByName` 10 | - `getPokedexById` 11 | - `getVersionByName` 12 | - `getVersionById` 13 | - `getVersionGroupByName` 14 | - `getVersionGroupById` 15 | - `listGenerations` 16 | - `listPokedexes` 17 | - `listVersion` 18 | - `listVersionGroups` 19 | 20 | ## Example 21 | 22 | ```js 23 | import { GameClient } from 'pokenode-ts'; // import the GameClient 24 | 25 | (async () => { 26 | const api = new GameClient(); // create a GameClient 27 | 28 | await api 29 | .getPokedexByName('national') 30 | .then((data) => console.log(data)) 31 | .catch((error) => console.error(error)); 32 | })(); 33 | ``` 34 | 35 | Or: 36 | 37 | ```js 38 | import { GameClient, Pokedexes } from 'pokenode-ts'; // import the GameClient and the Pokedexes enum 39 | 40 | (async () => { 41 | const api = new GameClient(); // create a GameClient 42 | 43 | await api 44 | .getPokedexById(Pokedexes.NATIONAL) 45 | .then((data) => console.log(data)) 46 | .catch((error) => console.error(error)); 47 | })(); 48 | ``` 49 | 50 | Will output: 51 | 52 | ```json 53 | { 54 | "descriptions": [ 55 | { 56 | "description": "Pokédex National complet", 57 | "language": { 58 | "name": "fr", 59 | "url": "https://pokeapi.co/api/v2/language/5/" 60 | } 61 | }, 62 | { 63 | "description": "Komplette Nationale Dex", 64 | "language": { 65 | "name": "de", 66 | "url": "https://pokeapi.co/api/v2/language/6/" 67 | } 68 | }, 69 | { 70 | "description": "Pokédex Nacional completa", 71 | "language": { 72 | "name": "es", 73 | "url": "https://pokeapi.co/api/v2/language/7/" 74 | } 75 | }, 76 | { 77 | "description": "Entire National dex", 78 | "language": { 79 | "name": "en", 80 | "url": "https://pokeapi.co/api/v2/language/9/" 81 | } 82 | } 83 | ], 84 | "id": 1, 85 | "is_main_series": true, 86 | "name": "national", 87 | "names": [ 88 | { 89 | "language": { 90 | "name": "fr", 91 | "url": "https://pokeapi.co/api/v2/language/5/" 92 | }, 93 | "name": "National" 94 | }, 95 | { 96 | "language": { 97 | "name": "de", 98 | "url": "https://pokeapi.co/api/v2/language/6/" 99 | }, 100 | "name": "National" 101 | }, 102 | { 103 | "language": { 104 | "name": "es", 105 | "url": "https://pokeapi.co/api/v2/language/7/" 106 | }, 107 | "name": "Nacional" 108 | }, 109 | { 110 | "language": { 111 | "name": "en", 112 | "url": "https://pokeapi.co/api/v2/language/9/" 113 | }, 114 | "name": "National" 115 | } 116 | ], 117 | "pokemon_entries": [ 118 | { 119 | "entry_number": 1, 120 | "pokemon_species": { 121 | "name": "bulbasaur", 122 | "url": "https://pokeapi.co/api/v2/pokemon-species/1/" 123 | } 124 | }, 125 | { 126 | "entry_number": 2, 127 | "pokemon_species": { 128 | "name": "ivysaur", 129 | "url": "https://pokeapi.co/api/v2/pokemon-species/2/" 130 | } 131 | }, 132 | ... 133 | ], 134 | "region": null, 135 | "version_groups": [] 136 | } 137 | ``` 138 | 139 | ## More 140 | 141 | > For more information about the Game Client endpoints, check out the [PokéAPI Documentation](https://pokeapi.co/docs/v2#games-section). 142 | -------------------------------------------------------------------------------- /docs/src/clients/item-client.md: -------------------------------------------------------------------------------- 1 | # Item Client 2 | 3 | ## Usage 4 | 5 | The Item Client provide methods to access the [Item Endpoinds](https://pokeapi.co/docs/v2#items-section): 6 | 7 | - `getItemByName` 8 | - `getItemByID` 9 | - `getItemAttributeByName` 10 | - `getItemAttributeById` 11 | - `getItemCategoryByName` 12 | - `getItemCategoryById` 13 | - `getItemFlingEffectByName` 14 | - `getItemFlingEffectById` 15 | - `getItemPocketById` 16 | - `getItemPocketByName` 17 | - `listItems` 18 | - `listItemAttributes` 19 | - `listItemCategories` 20 | - `listItemFlingEffects` 21 | - `listItemPockets` 22 | 23 | ## Example 24 | 25 | ```js 26 | import { ItemClient } from 'pokenode-ts'; // import the ItemClient 27 | 28 | (async () => { 29 | const api = new ItemClient(); // create an ItemClient 30 | 31 | await api 32 | .getItemById(3) 33 | .then((data) => console.log(data)) 34 | .catch((error) => console.error(error)); 35 | })(); 36 | ``` 37 | 38 | Or: 39 | 40 | ```js 41 | import { ItemClient } from 'pokenode-ts'; // import the ItemClient 42 | 43 | (async () => { 44 | const api = new ItemClient(); // create an ItemClient 45 | 46 | await api 47 | .getItemByName('medicine') 48 | .then((data) => console.log(data)) 49 | .catch((error) => console.error(error)); 50 | })(); 51 | ``` 52 | 53 | Will output: 54 | 55 | ```json 56 | { 57 | "id": 3, 58 | "items": [ 59 | { 60 | "name": "cheri-berry", 61 | "url": "https://pokeapi.co/api/v2/item/126/" 62 | }, 63 | { 64 | "name": "chesto-berry", 65 | "url": "https://pokeapi.co/api/v2/item/127/" 66 | }, 67 | { 68 | "name": "pecha-berry", 69 | "url": "https://pokeapi.co/api/v2/item/128/" 70 | }, 71 | { 72 | "name": "rawst-berry", 73 | "url": "https://pokeapi.co/api/v2/item/129/" 74 | }, 75 | { 76 | "name": "aspear-berry", 77 | "url": "https://pokeapi.co/api/v2/item/130/" 78 | }, 79 | { 80 | "name": "leppa-berry", 81 | "url": "https://pokeapi.co/api/v2/item/131/" 82 | }, 83 | { 84 | "name": "oran-berry", 85 | "url": "https://pokeapi.co/api/v2/item/132/" 86 | }, 87 | { 88 | "name": "persim-berry", 89 | "url": "https://pokeapi.co/api/v2/item/133/" 90 | }, 91 | { 92 | "name": "lum-berry", 93 | "url": "https://pokeapi.co/api/v2/item/134/" 94 | }, 95 | { 96 | "name": "sitrus-berry", 97 | "url": "https://pokeapi.co/api/v2/item/135/" 98 | } 99 | ], 100 | "name": "medicine", 101 | "names": [ 102 | { 103 | "language": { 104 | "name": "en", 105 | "url": "https://pokeapi.co/api/v2/language/9/" 106 | }, 107 | "name": "Medicine" 108 | } 109 | ], 110 | "pocket": { 111 | "name": "berries", 112 | "url": "https://pokeapi.co/api/v2/item-pocket/5/" 113 | } 114 | } 115 | ``` 116 | 117 | ## More 118 | 119 | > For more information about the Item Client endpoints, check out the [PokéAPI Documentation](https://pokeapi.co/docs/v2#items-section). 120 | -------------------------------------------------------------------------------- /docs/src/clients/location-client.md: -------------------------------------------------------------------------------- 1 | # Location Client 2 | 3 | ## Usage 4 | 5 | The Location Client provide methods to access the [Location Endpoinds](https://pokeapi.co/docs/v2#locations-section): 6 | 7 | - `getLocationByName` 8 | - `getLocationById` 9 | - `getLocationAreaByName` 10 | - `getLocatinAreaById` 11 | - `getPalParkAreaByName` 12 | - `getPalParkAreaById` 13 | - `getRegionByName` 14 | - `getRegionById` 15 | - `listLocations` 16 | - `listLocationAreas` 17 | - `listPalParkAreas` 18 | - `listRegions` 19 | 20 | ## Example 21 | 22 | ```js 23 | import { LocationClient, PalParkAreas } from 'pokenode-ts'; // import the LocationClient and the PalParkAreas enum 24 | 25 | (async () => { 26 | const api = new LocationClient(); // create a LocationClient 27 | 28 | await api 29 | .getPalParkAreaById(PalParkAreas.FOREST) 30 | .then((data) => console.log(data)) 31 | .catch((error) => console.error(error)); 32 | })(); 33 | ``` 34 | 35 | Or: 36 | 37 | ```js 38 | import { LocationClient } from 'pokenode-ts'; // import the LocationClient 39 | 40 | (async () => { 41 | const api = new LocationClient(); // create a LocationClient 42 | 43 | await api 44 | .getPalParkAreaByName('forest') 45 | .then((data) => console.log(data)) 46 | .catch((error) => console.error(error)); 47 | })(); 48 | ``` 49 | 50 | Will output: 51 | 52 | ```json 53 | { 54 | "id": 1, 55 | "name": "forest", 56 | "names": [ 57 | { 58 | "language": { 59 | "name": "fr", 60 | "url": "https://pokeapi.co/api/v2/language/5/" 61 | }, 62 | "name": "Forêt" 63 | }, 64 | { 65 | "language": { 66 | "name": "es", 67 | "url": "https://pokeapi.co/api/v2/language/7/" 68 | }, 69 | "name": "Bosque" 70 | }, 71 | { 72 | "language": { 73 | "name": "en", 74 | "url": "https://pokeapi.co/api/v2/language/9/" 75 | }, 76 | "name": "Forest" 77 | } 78 | ], 79 | "pokemon_encounters": [ 80 | { 81 | "base_score": 30, 82 | "pokemon_species": { 83 | "name": "caterpie", 84 | "url": "https://pokeapi.co/api/v2/pokemon-species/10/" 85 | }, 86 | "rate": 50 87 | }, 88 | { 89 | "base_score": 50, 90 | "pokemon_species": { 91 | "name": "metapod", 92 | "url": "https://pokeapi.co/api/v2/pokemon-species/11/" 93 | }, 94 | "rate": 30 95 | }, 96 | ... 97 | ] 98 | } 99 | ``` 100 | 101 | ## More 102 | 103 | > For more information about the Location Client endpoints, check out the [PokéAPI Documentation](https://pokeapi.co/docs/v2#locations-section). 104 | -------------------------------------------------------------------------------- /docs/src/clients/machine-client.md: -------------------------------------------------------------------------------- 1 | # Machine Client 2 | 3 | ## Usage 4 | 5 | The Machine Client provide methods to access the [Machine Endpoinds](https://pokeapi.co/docs/v2#machines-section): 6 | 7 | - `getMachineById` 8 | - `listMachines` 9 | 10 | ## Example 11 | 12 | ```js 13 | import { MachineClient } from 'pokenode-ts'; // import the MachineClient 14 | 15 | (async () => { 16 | const api = new MachineClient(); // create a MachineClient 17 | 18 | await api 19 | .getMachineById(1) 20 | .then((data) => console.log(data)) 21 | .catch((error) => console.error(error)); 22 | ``` 23 | 24 | Will output: 25 | 26 | ```json 27 | { 28 | "id": 1, 29 | "item": { 30 | "name": "tm01", 31 | "url": "https://pokeapi.co/api/v2/item/305/" 32 | }, 33 | "move": { 34 | "name": "mega-punch", 35 | "url": "https://pokeapi.co/api/v2/move/5/" 36 | }, 37 | "version_group": { 38 | "name": "red-blue", 39 | "url": "https://pokeapi.co/api/v2/version-group/1/" 40 | } 41 | } 42 | ``` 43 | 44 | ## More 45 | 46 | > For more information about the Machine Client endpoints, check out the [PokéAPI Documentation](https://pokeapi.co/docs/v2#machines-section). 47 | -------------------------------------------------------------------------------- /docs/src/clients/main-client.md: -------------------------------------------------------------------------------- 1 | # Main Client 2 | 3 | ## Usage 4 | 5 | The Main Client provide methods to access all of the [PokéAPI Endpoinds](https://pokeapi.co/docs/v2): 6 | 7 | - [Berry](/clients/berry-client) 8 | - [Contest](/clients/contest-client) 9 | - [Encounter](/clients/encounter-client) 10 | - [Evolution](/clients/evolution-client) 11 | - [Game](/clients/game-client) 12 | - [Item](/clients/item-client) 13 | - [Location](/clients/location-client) 14 | - [Machine](/clients/machine-client) 15 | - [Move](/clients/move-client) 16 | - [Pokemon](/clients/pokemon-client) 17 | - [Utility](/clients/utility-client) 18 | 19 | ## Example 20 | 21 | ```js 22 | import { MainClient } from 'pokenode-ts'; 23 | 24 | (async () => { 25 | const api = new MainClient(); 26 | 27 | await api.berry 28 | .getBerryByName('cheri') 29 | .then((data) => console.log(data.name)) // will output "cheri" 30 | .catch((error) => console.error(error)); 31 | })(); 32 | ``` 33 | 34 | Will output: 35 | 36 | ```json 37 | { 38 | "firmness": { 39 | "name": "soft", 40 | "url": "https://pokeapi.co/api/v2/berry-firmness/2/" 41 | }, 42 | "flavors": [ 43 | { 44 | "flavor": { 45 | "name": "spicy", 46 | "url": "https://pokeapi.co/api/v2/berry-flavor/1/" 47 | }, 48 | "potency": 10 49 | }, 50 | { 51 | "flavor": { 52 | "name": "dry", 53 | "url": "https://pokeapi.co/api/v2/berry-flavor/2/" 54 | }, 55 | "potency": 0 56 | }, 57 | { 58 | "flavor": { 59 | "name": "sweet", 60 | "url": "https://pokeapi.co/api/v2/berry-flavor/3/" 61 | }, 62 | "potency": 0 63 | }, 64 | { 65 | "flavor": { 66 | "name": "bitter", 67 | "url": "https://pokeapi.co/api/v2/berry-flavor/4/" 68 | }, 69 | "potency": 0 70 | }, 71 | { 72 | "flavor": { 73 | "name": "sour", 74 | "url": "https://pokeapi.co/api/v2/berry-flavor/5/" 75 | }, 76 | "potency": 0 77 | } 78 | ], 79 | "growth_time": 3, 80 | "id": 1, 81 | "item": { 82 | "name": "cheri-berry", 83 | "url": "https://pokeapi.co/api/v2/item/126/" 84 | }, 85 | "max_harvest": 5, 86 | "name": "cheri", 87 | "natural_gift_power": 60, 88 | "natural_gift_type": { 89 | "name": "fire", 90 | "url": "https://pokeapi.co/api/v2/type/10/" 91 | }, 92 | "size": 20, 93 | "smoothness": 25, 94 | "soil_dryness": 15 95 | } 96 | ``` 97 | 98 | ## More 99 | 100 | > For more information about the PokéAPI endpoints, check out the [PokéAPI Documentation](https://pokeapi.co/docs/v2). 101 | -------------------------------------------------------------------------------- /docs/src/clients/move-client.md: -------------------------------------------------------------------------------- 1 | # Move Client 2 | 3 | ## Usage 4 | 5 | The Move Client provide methods to access the [Move Endpoinds](https://pokeapi.co/docs/v2#moves-section): 6 | 7 | - `getMoveByName` 8 | - `getMoveById` 9 | - `getMoveAilmentByName` 10 | - `getMoveAilmentById` 11 | - `getMoveBattleStyleByName` 12 | - `getMoveBattleStyleById` 13 | - `getMoveCategoryByName` 14 | - `getMoveCategoryById` 15 | - `getMoveDamageClassByName` 16 | - `getMoveDamageClassById` 17 | - `getMoveLearnMethodByName` 18 | - `getMoveLearnMethodById` 19 | - `getMoveTargetByName` 20 | - `getMoveTargetById` 21 | - `listMoves` 22 | - `listMoveAilments` 23 | - `listMoveBattleStyles` 24 | - `listMoveCategories` 25 | - `listMoveDamageClasses` 26 | - `listMoveLearnMethods` 27 | - `listMoveTargets` 28 | 29 | ## Example 30 | 31 | ```js 32 | import { MoveClient, MoveAilments } from 'pokenode-ts'; // import the MachineClient and the MoveAilments enum 33 | 34 | (async () => { 35 | const api = new MoveClient(); // create a MoveClient 36 | 37 | await api 38 | .getMoveAilmentById(MoveAilments.PARALYSIS) 39 | .then((data) => console.log(data)) 40 | .catch((error) => console.error(error)); 41 | ``` 42 | 43 | Or: 44 | 45 | ```js 46 | import { MoveClient } from 'pokenode-ts'; // import the MachineClient 47 | 48 | (async () => { 49 | const api = new MoveClient(); // create a MoveClient 50 | 51 | await api 52 | .getMoveAilmentByName('paralysis') 53 | .then((data) => console.log(data)) 54 | .catch((error) => console.error(error)); 55 | ``` 56 | 57 | Will output: 58 | 59 | ```json 60 | { 61 | "id": 1, 62 | "moves": [ 63 | { 64 | "name": "thunder-punch", 65 | "url": "https://pokeapi.co/api/v2/move/9/" 66 | }, 67 | { 68 | "name": "body-slam", 69 | "url": "https://pokeapi.co/api/v2/move/34/" 70 | }, 71 | ... 72 | ], 73 | "name": "paralysis", 74 | "names": [ 75 | { 76 | "language": { 77 | "name": "fr", 78 | "url": "https://pokeapi.co/api/v2/language/5/" 79 | }, 80 | "name": "Paralysie" 81 | }, 82 | { 83 | "language": { 84 | "name": "es", 85 | "url": "https://pokeapi.co/api/v2/language/7/" 86 | }, 87 | "name": "Parálisis" 88 | }, 89 | { 90 | "language": { 91 | "name": "en", 92 | "url": "https://pokeapi.co/api/v2/language/9/" 93 | }, 94 | "name": "Paralysis" 95 | } 96 | ] 97 | } 98 | ``` 99 | 100 | ## More 101 | 102 | > For more information about the Move Client endpoints, check out the [PokéAPI Documentation](https://pokeapi.co/docs/v2#moves-section). 103 | -------------------------------------------------------------------------------- /docs/src/clients/pokemon-client.md: -------------------------------------------------------------------------------- 1 | # Pokemon Client 2 | 3 | ## Usage 4 | 5 | The Pokemon Client provides methods to access the [Pokémon Endpoints](https://pokeapi.co/docs/v2#pokemon-section): 6 | 7 | - `getAbilityByName` 8 | - `getAbilityById` 9 | - `getCharacteristicByName` 10 | - `getCharacteristicById` 11 | - `getEggGroupByName` 12 | - `getEggGroupById` 13 | - `getGenderByName` 14 | - `getGenderById` 15 | - `getGrowthRateByName` 16 | - `getGrowthRateById` 17 | - `getNatureByName` 18 | - `getNatureById` 19 | - `getPokeathlonStatByName` 20 | - `getPokeathlonStatById` 21 | - `getPokemonByName` 22 | - `getPokemonById` 23 | - `getPokemonLocationAreaById` 24 | - `getPokemonColorByName` 25 | - `getPokeomnColorById` 26 | - `getPokemonFormByName` 27 | - `getPokemonFormById` 28 | - `getPokemonHabitatByName` 29 | - `getPokemonHabitatById` 30 | - `getPokemonShapeByName` 31 | - `getPokemonShapeById` 32 | - `getPokemonSpeciesByName` 33 | - `getPokemonSpeciesById` 34 | - `getStatByName` 35 | - `getStatById` 36 | - `getTypeByName` 37 | - `getTypeById` 38 | - `listAbilities` 39 | - `listCharacteristics` 40 | - `listEggGroups` 41 | - `listGenders` 42 | - `listGrowthRates` 43 | - `listNatures` 44 | - `listPokeathlonStats` 45 | - `listPokemons` 46 | - `listPokemonColors` 47 | - `listPokemonForms` 48 | - `listPokemonHabitats` 49 | - `listPokemonShapes` 50 | - `listPokemonSpecies` 51 | - `listStats` 52 | - `listTypes` 53 | 54 | ## Example 55 | 56 | ```js 57 | import { PokemonClient, EggGroups } from 'pokenode-ts'; // import the PokemonClient (EggGroups enum is fully optional) 58 | 59 | (async () => { 60 | const api = new PokemonClient(); // create a PokemonClient 61 | 62 | await api 63 | .getEggGroupById(EggGroups.MONSTER) 64 | .then((data) => console.log(data)) 65 | .catch((error) => console.error(error)); 66 | })(); 67 | ``` 68 | 69 | Or: 70 | 71 | ```js 72 | import { PokemonClient, EggGroups } from 'pokenode-ts'; // import the PokemonClient 73 | 74 | (async () => { 75 | const api = new PokemonClient(); // create a PokemonClient 76 | 77 | await api 78 | .getEggGroupByName('monster') 79 | .then((data) => console.log(data)) 80 | .catch((error) => console.error(error)); 81 | })(); 82 | ``` 83 | 84 | Will output: 85 | 86 | ```json 87 | { 88 | "id": 1, 89 | "name": "monster", 90 | "names": [ 91 | { 92 | "language": { 93 | "name": "ja-Hrkt", 94 | "url": "https://pokeapi.co/api/v2/language/1/" 95 | }, 96 | "name": "かいじゅう" 97 | }, 98 | { 99 | "language": { 100 | "name": "ko", 101 | "url": "https://pokeapi.co/api/v2/language/3/" 102 | }, 103 | "name": "괴수" 104 | }, 105 | { 106 | "language": { 107 | "name": "fr", 108 | "url": "https://pokeapi.co/api/v2/language/5/" 109 | }, 110 | "name": "Monstrueux" 111 | }, 112 | ... 113 | ], 114 | "pokemon_species": [ 115 | { 116 | "name": "bulbasaur", 117 | "url": "https://pokeapi.co/api/v2/pokemon-species/1/" 118 | }, 119 | { 120 | "name": "ivysaur", 121 | "url": "https://pokeapi.co/api/v2/pokemon-species/2/" 122 | }, 123 | ... 124 | ] 125 | } 126 | ``` 127 | 128 | ## More 129 | 130 | > For more information about the Pokemon Client endpoints, check out the [PokéAPI Documentation](https://pokeapi.co/docs/v2#pokemon-section). 131 | -------------------------------------------------------------------------------- /docs/src/clients/utility-client.md: -------------------------------------------------------------------------------- 1 | # Utility Client 2 | 3 | ## Usage 4 | 5 | The Utility Client provide methods to access the [Languages Endpoinds](https://pokeapi.co/docs/v2#languages-section) and resources: 6 | 7 | - `getLanguageByName` 8 | - `getLanguageById` 9 | - `getResourceByUrl` 10 | - `listLanguages` 11 | 12 | ## Example 13 | 14 | ```ts 15 | import { UtilityClient } from 'pokenode-ts'; // import the UtilityClient 16 | 17 | (async () => { 18 | const api = new UtilityClient(); // create a UtilityClient 19 | 20 | await api 21 | .getResourceByUrl('https://pokeapi.co/api/v2/pokemon/luxray') // using method getResourceByUrl() (pokemon endpoint) 22 | .then((response: Pokemon) => console.log(response)) // The resource will be a Pokemon (Luxray) 23 | .catch((error) => console.log(error)); 24 | })(); 25 | ``` 26 | 27 | ```js 28 | import { UtilityClient, Languages } from 'pokenode-ts'; // import the UtilityClient 29 | 30 | (async () => { 31 | const api = new UtilityClient(); // create an UtilityClient 32 | 33 | const lang = await api 34 | .getLanguageById(Languages.KO) // using method getLanguageById() 35 | .then((response) => response) 36 | .catch((error) => console.log(error)); 37 | })(); 38 | ``` 39 | 40 | Will output: 41 | 42 | ```json 43 | { 44 | "id": 3, 45 | "iso3166": "kr", 46 | "iso639": "ko", 47 | "name": "ko", 48 | "names": [ 49 | { 50 | "language": { 51 | "name": "ja-Hrkt", 52 | "url": "https://pokeapi.co/api/v2/language/1/" 53 | }, 54 | "name": "韓国語" 55 | }, 56 | { 57 | "language": { 58 | "name": "ko", 59 | "url": "https://pokeapi.co/api/v2/language/3/" 60 | }, 61 | "name": "한국어" 62 | }, 63 | { 64 | "language": { 65 | "name": "fr", 66 | "url": "https://pokeapi.co/api/v2/language/5/" 67 | }, 68 | "name": "Coréen" 69 | }, 70 | { 71 | "language": { 72 | "name": "de", 73 | "url": "https://pokeapi.co/api/v2/language/6/" 74 | }, 75 | "name": "Koreanisch" 76 | }, 77 | { 78 | "language": { 79 | "name": "es", 80 | "url": "https://pokeapi.co/api/v2/language/7/" 81 | }, 82 | "name": "Coreano" 83 | }, 84 | { 85 | "language": { 86 | "name": "en", 87 | "url": "https://pokeapi.co/api/v2/language/9/" 88 | }, 89 | "name": "Korean" 90 | } 91 | ], 92 | "official": true 93 | } 94 | ``` 95 | -------------------------------------------------------------------------------- /docs/src/guides/cache.md: -------------------------------------------------------------------------------- 1 | # Cache 2 | 3 | With `Axios Cache Interceptor` you can store request results to prevent unneeded network requests. 4 | 5 | ## Basic Usage 6 | 7 | Cache is `enabled by default`. Use the `cacheOptions` property to configure it: 8 | 9 | ```js 10 | import { BerryClient, Constants } from 'pokenode-ts'; 11 | 12 | const api = new BerryClient({ cacheOptions: { ... } }); // options here 13 | ``` 14 | 15 | :::tip 16 | For more information, check out [Axios Cache Interceptor Documentation](https://axios-cache-interceptor.js.org/) 17 | ::: 18 | -------------------------------------------------------------------------------- /docs/src/guides/contributing.md: -------------------------------------------------------------------------------- 1 | # Contributing to Pokenode-ts 2 | 3 | ## Development Setup 4 | 5 | 1. [Fork](https://help.github.com/articles/fork-a-repo/) this repository to your own GitHub account and then [clone](https://help.github.com/articles/cloning-a-repository/) it to your local device. 6 | 2. Create a new branch `git checkout -b MY_BRANCH_NAME` 7 | 3. [Install pnpm](https://pnpm.io/pt/installation) 8 | 4. Install the dependencies `pnpm i` 9 | 5. The development branch is `dev` (this is the branch pull requests should be made against). On a release, the relevant parts of the changes in the `dev` branch are rebased into `master`, tested, and then rebased to `stable`. 10 | 11 | :::tip 12 | Check out our: 13 | 14 | - [Code of Conduct](https://github.com/Gabb-c/pokenode-ts/blob/master/.github/CODE_OF_CONDUCT.md) 15 | - [Pull Request Template](https://github.com/Gabb-c/pokenode-ts/blob/master/.github/pull_request_template.md) 16 | - [Bug Report Template](https://github.com/Gabb-c/pokenode-ts/blob/master/.github/ISSUE_TEMPLATE/bug_report.yml) 17 | - [Feature Request Template](https://github.com/Gabb-c/pokenode-ts/blob/master/.github/ISSUE_TEMPLATE/bug_report.yml) 18 | ::: 19 | 20 | ## Testing PokéAPI Endpoints 21 | 22 | If you want to test the PokéAPI endpoints, we recommend using [Insomnia](https://insomnia.rest/): 23 | 24 |
25 | 26 | Run in Insomnia 27 | 28 |
29 | 30 | ## Leave your feedback 31 | 32 | - Did you like pokenode-ts? [Give us a star ⭐](https://github.com/Gabb-c/pokenode-ts) 33 | - Found a problem? Let us know by [creating an issue 🔎📑](https://github.com/Gabb-c/pokenode-ts/issues) 34 | - Want to contribute? [Submit a PR](https://github.com/Gabb-c/pokenode-ts/pulls) 35 | -------------------------------------------------------------------------------- /docs/src/guides/getting-started.md: -------------------------------------------------------------------------------- 1 | # Getting Started 2 | 3 | ## Installation 4 | 5 | Install pokenode-ts with your favorite package manager: 6 | 7 | :::code-group 8 | 9 | ```bash [NPM] 10 | npm i axios axios-cache-interceptor pokenode-ts 11 | ``` 12 | 13 | ```bash [Yarn] 14 | yarn add axios axios-cache-interceptor pokenode-ts 15 | ``` 16 | 17 | ```bash [Pnpm] 18 | pnpm i axios axios-cache-interceptor pokenode-ts 19 | ``` 20 | 21 | ::: 22 | 23 | ## Basic Example 24 | 25 | Using a client, like [PokemonClient](https://gabb-c.github.io/pokenode-ts/#/clients/pokemon-client): 26 | 27 | ```js 28 | import { PokemonClient } from 'pokenode-ts'; 29 | 30 | (async () => { 31 | const api = new PokemonClient(); 32 | 33 | await api 34 | .getPokemonByName('luxray') 35 | .then((data) => console.log(data.name)) // will output "Luxray" 36 | .catch((error) => console.error(error)); 37 | })(); 38 | ``` 39 | 40 | Or, using the MainClient: 41 | 42 | ```js 43 | import { MainClient } from 'pokenode-ts'; 44 | 45 | (async () => { 46 | const api = new MainClient(); 47 | 48 | await api.pokemon 49 | .getPokemonByName('luxray') 50 | .then((data) => console.log(data.name)) // will output "Luxray" 51 | .catch((error) => console.error(error)); 52 | })(); 53 | ``` 54 | 55 | ## Using Constants 56 | 57 | Pokenode-ts has some useful abbreviations for some endpoints if you don't want to use raw strings or search for the ID's ;) 58 | 59 | ```js 60 | import { Constants } from 'pokenode-ts'; 61 | 62 | console.log(Constants.Berries.ASPEAR); // will output 5, the Aspear Berry ID 63 | ``` 64 | 65 | Or 66 | 67 | ```js 68 | import { Berries } from 'pokenode-ts'; 69 | 70 | console.log(Berries.ASPEAR); // will output 5, the Aspear Berry ID 71 | ``` 72 | 73 | ## Leave your feedback 74 | 75 | - Did you like pokenode-ts? [Give us a star ⭐](https://github.com/Gabb-c/pokenode-ts) 76 | - Found a problem? Let us know by [creating an issue 🔎📑](https://github.com/Gabb-c/pokenode-ts/issues) 77 | - Want to contribute? [Submit a PR](https://github.com/Gabb-c/pokenode-ts/pulls) 78 | -------------------------------------------------------------------------------- /docs/src/guides/logging.md: -------------------------------------------------------------------------------- 1 | # Logging 2 | 3 | ## Logs 4 | 5 | Every client in Pokenode-ts can display logs from requests and responses. 6 | 7 | ## Basic Logging 8 | 9 | To enable logs just pass `logs: true`: 10 | 11 | ```ts 12 | import { BerryClient } from 'pokenode-ts'; 13 | 14 | const api = new BerryClient({ logs: true }); // Enable logs 15 | ``` 16 | 17 | Will output: 18 | 19 | ``` 20 | // success 21 | [ Request Config ] GET | /berry/cheri 22 | [ Response ] STATUS 200 | CACHED 23 | 24 | // error 25 | [ Request Config ] GET | /berry/cheri 26 | [ Response Error ] CODE ERR_BAD_REQUEST | Request failed with status code 404 27 | ``` 28 | -------------------------------------------------------------------------------- /docs/src/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: home 3 | 4 | hero: 5 | name: Pokenode-ts 6 | text: Type-Safe, Configurable, Lightweight 7 | tagline: A powerful Node.js wrapper for the PokéAPI with built-in types. 8 | image: 9 | src: /site-logo.svg 10 | alt: VitePress 11 | actions: 12 | - theme: brand 13 | text: Get Started 14 | link: /guides/getting-started 15 | - theme: alt 16 | text: View on GitHub 17 | link: https://github.com/Gabb-c/pokenode-ts 18 | 19 | features: 20 | - icon: 🛠️ 21 | title: Built-in Types 22 | details: Pokenode-ts includes up-to-date type definitions based on the PokéAPI documentation, ensuring type safety and improved developer experience. 23 | - icon: 📦 24 | title: Request Cache 25 | details: Leverages Axios auto-cache feature to optimize performance. Store API responses to minimize unnecessary network requests. 26 | - icon: 🌲 27 | title: Logging 28 | details: Provides logging functionality for development and debugging purposes. 29 | --- 30 | 31 | 60 | 61 | 62 | 63 | 66 | 70 | 71 | 74 | 75 | -------------------------------------------------------------------------------- /docs/src/public/.nojekyll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Gabb-c/pokenode-ts/dba280ece88650384ce26693ce1a9f2e40af8452/docs/src/public/.nojekyll -------------------------------------------------------------------------------- /docs/src/public/_headers: -------------------------------------------------------------------------------- 1 | / 2 | X-Frame-Options: DENY 3 | X-XSS-Protection: 1; mode=block 4 | 5 | /api/ 6 | X-Frame-Options: DENY 7 | X-XSS-Protection: 1; mode=block 8 | 9 | /config/ 10 | X-Frame-Options: DENY 11 | X-XSS-Protection: 1; mode=block 12 | 13 | /guide/ 14 | X-Frame-Options: DENY 15 | X-XSS-Protection: 1; mode=block 16 | 17 | /*.html 18 | X-Frame-Options: DENY 19 | X-XSS-Protection: 1; mode=block 20 | 21 | /* 22 | X-Content-Type-Options: nosniff 23 | Referrer-Policy: no-referrer 24 | Strict-Transport-Security: max-age=31536000; includeSubDomains 25 | 26 | /assets/* 27 | cache-control: max-age=31536000 28 | cache-control: immutable 29 | -------------------------------------------------------------------------------- /docs/src/public/cover.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Gabb-c/pokenode-ts/dba280ece88650384ce26693ce1a9f2e40af8452/docs/src/public/cover.jpg -------------------------------------------------------------------------------- /docs/src/public/robots.txt: -------------------------------------------------------------------------------- 1 | User-Agent: * 2 | Allow: / 3 | -------------------------------------------------------------------------------- /docs/src/public/site-logo.svg: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /docs/src/typings/berry-typings.md: -------------------------------------------------------------------------------- 1 | # Berries 2 | 3 | ## Berry 4 | 5 | Berries are small fruits that can provide HP and status condition restoration, 6 | stat enhancement, and even damage negation when eaten by Pokémon. 7 | 8 | ```ts 9 | export interface Berry { 10 | /** The identifier for this resource */ 11 | id: number; 12 | /** The name for this resource */ 13 | name: string; 14 | /** Time it takes the tree to grow one stage, in hours. Berry trees go through four of these growth stages before they can be picked */ 15 | growth_time: string; 16 | /** The maximum number of these berries that can grow on one tree in Generation IV */ 17 | max_harvest: number; 18 | /** The power of the move "Natural Gift" when used with this Berry */ 19 | natural_gift_power: number; 20 | /** The size of this Berry, in millimeters */ 21 | size: number; 22 | /** The smoothness of this Berry, used in making Pokéblocks or Poffins */ 23 | smoothness: number; 24 | /** The speed at which this Berry dries out the soil as it grows. A higher rate means the soil dries more quickly */ 25 | soil_dryness: number; 26 | /** The firmness of this berry, used in making Pokéblocks or Poffins */ 27 | firmness: NamedAPIResource; 28 | /** A list of references to each flavor a berry can have and the potency of each of those flavors in regard to this berry */ 29 | flavors: BerryFlavorMap[]; 30 | /** Berries are actually items. This is a reference to the item specific data for this berry */ 31 | item: NamedAPIResource; 32 | /** The type inherited by "Natural Gift" when used with this Berry */ 33 | natural_gift_type: NamedAPIResource; 34 | } 35 | ``` 36 | 37 | > Check out [Bulbapedia](https://bulbapedia.bulbagarden.net/wiki/Berry) for greater detail. 38 | 39 | ## Berry Flavor 40 | 41 | Flavors determine whether a Pokémon will benefit or suffer from eating a berry based on their nature. 42 | 43 | ```ts 44 | export interface BerryFlavor { 45 | /** The identifier for this resource */ 46 | id: number; 47 | /** The name for this resource */ 48 | name: string; 49 | /** A list of the berries with this flavor */ 50 | berries: FlavorBerryMap[]; 51 | /** The contest type that correlates with this berry flavor */ 52 | contest_type: NamedAPIResource; 53 | /** The name of this resource listed in different languages */ 54 | names: Name[]; 55 | } 56 | ``` 57 | 58 | > Check out [Bulbapedia](https://bulbapedia.bulbagarden.net/wiki/Flavor) for greater detail. 59 | 60 | ## Berry Firmness 61 | 62 | Berries can be soft, very soft, hard, super hard or very hard. 63 | 64 | ```ts 65 | export interface BerryFirmness { 66 | /** The identifier for this resource */ 67 | id: number; 68 | /** The name for this resource */ 69 | name: string; 70 | /** A list of the berries with this firmness */ 71 | berries: NamedAPIResource[]; 72 | /** The name of this resource listed in different languages */ 73 | names: Name[]; 74 | } 75 | ``` 76 | 77 | > Check out [Bulbapedia](https://bulbapedia.bulbagarden.net/wiki/Category:Berries_by_firmness) for greater detail. 78 | 79 | ## Berry Flavor Map 80 | 81 | Reference to the flavor a berry can have and the potency of each of those flavors in regard to this berry. 82 | 83 | ```ts 84 | export interface BerryFlavorMap { 85 | /** How powerful the referenced flavor is for this berry */ 86 | potency: number; 87 | /** The referenced berry flavor */ 88 | flavor: NamedAPIResource; 89 | } 90 | ``` 91 | 92 | ## Flavor Berry Map 93 | 94 | Berry with the given flavor. 95 | 96 | ```ts 97 | export interface FlavorBerryMap { 98 | /**How powerful the referenced flavor is for this berry */ 99 | potency: number; 100 | /** The berry with the referenced flavor*/ 101 | berry: NamedAPIResource; 102 | } 103 | ``` 104 | -------------------------------------------------------------------------------- /docs/src/typings/contest-typings.md: -------------------------------------------------------------------------------- 1 | # Contests 2 | 3 | ## Contest Type 4 | 5 | Contest types are categories judges used to weigh a Pokémon's condition in Pokémon contests. 6 | 7 | ```ts 8 | export interface ContestType { 9 | /** The identifier for this resource */ 10 | id: number; 11 | /** The name for this resource */ 12 | name: string; 13 | /** The berry flavor that correlates with this contest type */ 14 | berry_flavor: NamedAPIResource; 15 | /** The name of this contest type listed in different languages */ 16 | names: ContestName[]; 17 | } 18 | ``` 19 | 20 | > Check out [Bulbapedia](https://bulbapedia.bulbagarden.net/wiki/Contest_condition) for greater detail. 21 | 22 | ## Contest Effect 23 | 24 | Contest effects refer to the effects of moves when used in contests. 25 | 26 | ```ts 27 | export interface ContestEffect { 28 | /** The identifier for this resource */ 29 | id: number; 30 | /** The base number of hearts the user of this move gets */ 31 | appeal: number; 32 | /** The base number of hearts the user's opponent loses */ 33 | jam: number; 34 | /** The result of this contest effect listed in different languages */ 35 | effect_entries: Effect[]; 36 | /** The flavor text of this contest effect listed in different languages */ 37 | flavor_text_entries: FlavorText[]; 38 | } 39 | ``` 40 | 41 | ## Super Contest Effect 42 | 43 | Super contest effects refer to the effects of moves when used in super contests. 44 | A Pokémon Super Contest is an expanded format of the [Pokémon Contests](https://bulbapedia.bulbagarden.net/wiki/Pok%C3%A9mon_Contest) 45 | for the Generation IV games, specifically in [Diamond, Pearl](https://bulbapedia.bulbagarden.net/wiki/Pok%C3%A9mon_Diamond_and_Pearl_Versions), 46 | and [Platinum](https://bulbapedia.bulbagarden.net/wiki/Pok%C3%A9mon_Platinum_Version). 47 | In it, Pokémon are rated on their appearance and performance, rather than strength. 48 | 49 | ```ts 50 | export interface SuperContestEffect { 51 | /** The identifier for this resource */ 52 | id: number; 53 | /** The level of appeal this super contest effect has */ 54 | appeal: number; 55 | /** The flavor text of this super contest effect listed in different languages */ 56 | flavor_text_entries: FlavorText[]; 57 | /** A list of moves that have the effect when used in super contests */ 58 | moves: NamedAPIResource[]; 59 | } 60 | ``` 61 | 62 | > Check out [Bulbapedia](https://bulbapedia.bulbagarden.net/wiki/Pok%C3%A9mon_Super_Contest) for greater detail. 63 | 64 | ## Contest Name 65 | 66 | The name of the given contest type. 67 | 68 | ```ts 69 | export interface ContestName { 70 | /** The name for this contest */ 71 | name: string; 72 | /** The color associated with this contest's name */ 73 | color: string; 74 | /** The language that this name is in */ 75 | language: NamedAPIResource; 76 | } 77 | ``` 78 | -------------------------------------------------------------------------------- /docs/src/typings/encounter-typings.md: -------------------------------------------------------------------------------- 1 | # Encounters 2 | 3 | ## Encounter Method 4 | 5 | Methods by which the player might can encounter Pokémon in the wild, e.g., walking in tall grass. 6 | 7 | ```ts 8 | export interface EncounterMethod { 9 | /** The identifier for this resource */ 10 | id: number; 11 | /** The name for this resource */ 12 | name: string; 13 | /** A good value for sorting */ 14 | order: number; 15 | /** The name of this resource listed in different languages */ 16 | names: Name[]; 17 | } 18 | ``` 19 | 20 | > Check out [Bulbapedia](https://bulbapedia.bulbagarden.net/wiki/Wild_Pok%C3%A9mon) for greater detail. 21 | 22 | ## Encounter Condition 23 | 24 | Conditions which affect what pokemon might appear in the wild, e.g., **day** or **night**. 25 | 26 | ```ts 27 | export interface EncounterCondition { 28 | /** The identifier for this resource */ 29 | id: number; 30 | /** The name for this resource */ 31 | name: string; 32 | /** The name of this resource listed in different languages */ 33 | names: Name[]; 34 | /** A list of possible values for this encounter condition */ 35 | values: NamedAPIResource[]; 36 | } 37 | ``` 38 | 39 | > Check out [Bulbapedia](https://bulbapedia.bulbagarden.net/wiki/Time) 40 | 41 | ## Encounter Condition Value 42 | 43 | Encounter condition values are the various states that an encounter 44 | condition can have, i.e., time of day can be either **day** or **night**. 45 | 46 | ```ts 47 | export interface EncounterConditionValue { 48 | /** The identifier for this resource */ 49 | id: number; 50 | /** The name for this resource */ 51 | name: string; 52 | /** The condition this encounter condition value pertains to */ 53 | condition: NamedAPIResource; 54 | /** The name of this resource listed in different languages */ 55 | names: Name[]; 56 | } 57 | ``` 58 | 59 | > Check out [Bulbapedia](https://bulbapedia.bulbagarden.net/wiki/Time) 60 | -------------------------------------------------------------------------------- /docs/src/typings/machine-typings.md: -------------------------------------------------------------------------------- 1 | # Machines 2 | 3 | ## Machine 4 | 5 | Machines are the representation of items that teach moves to Pokémon. 6 | They vary from version to version, so it is not certain that one specific 7 | [TM (Technical Machine)](https://bulbapedia.bulbagarden.net/wiki/TM) or 8 | [HM (Hidden Machine)](https://bulbapedia.bulbagarden.net/wiki/HM) corresponds to a single Machine. 9 | 10 | ```ts 11 | export interface Machine { 12 | /** The identifier for this resource */ 13 | id: number; 14 | /** The TM or HM item that corresponds to this machine */ 15 | item: NamedAPIResource; 16 | /** The move that is taught by this machine */ 17 | move: NamedAPIResource; 18 | /** The version group that this machine applies to */ 19 | version_group: NamedAPIResource; 20 | } 21 | ``` 22 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "pokenode-ts", 3 | "version": "1.19.0", 4 | "private": false, 5 | "description": "A lightweight Node.js wrapper for the PokéAPI with built-in types.", 6 | "keywords": ["pokeapi", "PokéAPI", "pokemon", "pokedex"], 7 | "homepage": "https://pokenode-ts.vercel.app/", 8 | "bugs": { 9 | "url": "https://github.com/Gabb-c/pokenode-ts/issues" 10 | }, 11 | "repository": { 12 | "type": "git", 13 | "url": "https://github.com/Gabb-c/pokenode-ts" 14 | }, 15 | "funding": "https://github.com/Gabb-c/pokenode-ts?sponsor=1", 16 | "license": "MIT", 17 | "author": { 18 | "name": "Gabb-c", 19 | "url": "https://github.com/Gabb-c" 20 | }, 21 | "sideEffects": false, 22 | "type": "module", 23 | "exports": { 24 | "types": "./lib/index.d.ts", 25 | "import": "./lib/index.js", 26 | "require": "./lib/index.cjs", 27 | "default": "./lib/index.cjs" 28 | }, 29 | "main": "lib/index.cjs", 30 | "module": "lib/index.js", 31 | "files": ["lib"], 32 | "types": "lib/index.d.ts", 33 | "scripts": { 34 | "build": "tsup --config tsup.config.ts && size-limit", 35 | "docs:build": "vitepress build docs", 36 | "docs:dev": "vitepress dev docs --force", 37 | "docs:preview": "vitepress preview docs", 38 | "format": "biome format ./src", 39 | "lint:ci": "biome ci src", 40 | "prepare": "is-ci || husky", 41 | "prepublishOnly": "pnpm build", 42 | "test": "vitest", 43 | "test:types": "vitest --typecheck.only", 44 | "test:coverage": "vitest run --coverage", 45 | "test:ui": "vitest --ui --api 9527" 46 | }, 47 | "devDependencies": { 48 | "@biomejs/biome": "^1.9.4", 49 | "@commitlint/cli": "^19.6.1", 50 | "@commitlint/config-conventional": "^19.6.0", 51 | "@semantic-release/changelog": "^6.0.3", 52 | "@semantic-release/commit-analyzer": "^13.0.1", 53 | "@semantic-release/git": "^10.0.1", 54 | "@semantic-release/github": "^11.0.1", 55 | "@semantic-release/npm": "^12.0.1", 56 | "@semantic-release/release-notes-generator": "^14.0.3", 57 | "@size-limit/preset-small-lib": "^11.1.6", 58 | "@swc/core": "^1.10.7", 59 | "@types/is-ci": "^3.0.4", 60 | "@types/node": "^22.10.7", 61 | "@vitest/coverage-v8": "^3.0.1", 62 | "@vitest/ui": "^3.0.1", 63 | "axios": "^1.7.9", 64 | "axios-cache-interceptor": "^1.6.2", 65 | "ci-info": "^4.1.0", 66 | "http-status-codes": "^2.3.0", 67 | "husky": "^9.1.7", 68 | "is-ci": "^4.1.0", 69 | "lint-staged": "^15.4.1", 70 | "msw": "^2.7.0", 71 | "semantic-release": "^24.2.1", 72 | "size-limit": "^11.1.6", 73 | "tsup": "^8.3.5", 74 | "typescript": "^5.7.3", 75 | "vite": "^6.0.7", 76 | "vite-tsconfig-paths": "^5.1.4", 77 | "vitepress": "1.5.0", 78 | "vitest": "^3.0.1", 79 | "vue": "^3.5.13" 80 | }, 81 | "peerDependencies": { 82 | "axios": "^1.7.9", 83 | "axios-cache-interceptor": "^1.6.2" 84 | }, 85 | "engines": { 86 | "node": ">=16" 87 | }, 88 | "size-limit": [ 89 | { 90 | "path": "lib/index.js" 91 | } 92 | ], 93 | "pnpm": { 94 | "peerDependencyRules": { 95 | "ignoreMissing": ["@algolia/client-search", "search-insights"] 96 | } 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /sonar.properties: -------------------------------------------------------------------------------- 1 | sonar.typescript.tsconfigPath=tsconfig.json 2 | sonar.typescript.lcov.reportPaths=coverage/ 3 | sonar.sources=src/ 4 | sonar.tests=tests/ 5 | -------------------------------------------------------------------------------- /src/clients/berry.client.ts: -------------------------------------------------------------------------------- 1 | import { ENDPOINTS } from "@constants"; 2 | import type { Berry, BerryFirmness, BerryFlavor, NamedAPIResourceList } from "@models"; 3 | import { BaseClient } from "./base"; 4 | 5 | /** 6 | * ### Berry Client 7 | * 8 | * Client used to access the Berry Endpoints: 9 | * - [Berries](https://pokeapi.co/docs/v2#berries) 10 | * - [Berry Firmnesses](https://pokeapi.co/docs/v2#berry-firmnesses) 11 | * - [Berry Flavors](https://pokeapi.co/docs/v2#berry-flavors) 12 | * 13 | * See [PokéAPI Documentation](https://pokeapi.co/docs/v2#berries-section) 14 | */ 15 | export class BerryClient extends BaseClient { 16 | /** 17 | * Get a Berry by it's name 18 | * @param name The berry name 19 | * @returns A Berry 20 | */ 21 | public async getBerryByName(name: string): Promise { 22 | return this.getResource(ENDPOINTS.BERRY, name); 23 | } 24 | 25 | /** 26 | * Get a Berry by it's ID 27 | * @param id The Berry ID 28 | * @returns A Berry 29 | */ 30 | public async getBerryById(id: number): Promise { 31 | return this.getResource(ENDPOINTS.BERRY, id); 32 | } 33 | 34 | /** 35 | * Get a Berry Firmness by it's ID 36 | * @param id The Berry ID 37 | * @returns Berry Firmness 38 | */ 39 | public async getBerryFirmnessById(id: number): Promise { 40 | return this.getResource(ENDPOINTS.BERRY_FIRMNESS, id); 41 | } 42 | 43 | /** 44 | * Get a Berry Firmness by it's ID 45 | * @param name The Berry name 46 | * @returns Berry Firmness 47 | */ 48 | public async getBerryFirmnessByName(name: string) { 49 | return this.getResource(ENDPOINTS.BERRY_FIRMNESS, name); 50 | } 51 | 52 | /** 53 | * Flavors determine whether a Pokémon will benefit or suffer from eating a berry based on their nature. 54 | * Check out [Bulbapedia](https://bulbapedia.bulbagarden.net/wiki/Flavor) for greater detail. 55 | * @param id The Berry Flavor ID 56 | * @returns Berry Flavor 57 | */ 58 | public async getBerryFlavorById(id: number): Promise { 59 | return this.getResource(ENDPOINTS.BERRY_FLAVOR, id); 60 | } 61 | 62 | /** 63 | * Flavors determine whether a Pokémon will benefit or suffer from eating a berry based on their nature. 64 | * Check out [Bulbapedia](https://bulbapedia.bulbagarden.net/wiki/Flavor) for greater detail. 65 | * @param name The Berry Flavor name 66 | * @returns Berry Flavor 67 | */ 68 | public async getBerryFlavorByName(name: string): Promise { 69 | return this.getResource(ENDPOINTS.BERRY_FLAVOR, name); 70 | } 71 | 72 | /** 73 | * List Berries 74 | * @param offset The first item that you will get 75 | * @param limit How many berries per page 76 | * @returns A list of berries 77 | */ 78 | public async listBerries(offset?: number, limit?: number): Promise { 79 | return this.getListResource(ENDPOINTS.BERRY, offset, limit); 80 | } 81 | 82 | /** 83 | * List Berries 84 | * @param offset The first item that you will get 85 | * @param limit How many berry firmnesses per page 86 | * @returns A list of berry firmnesses 87 | */ 88 | public async listBerryFirmnesses(offset?: number, limit?: number): Promise { 89 | return this.getListResource(ENDPOINTS.BERRY_FIRMNESS, offset, limit); 90 | } 91 | 92 | /** 93 | * List Berry Flavors 94 | * @param offset The first item that you will get 95 | * @param limit How many Berry Flavors per page 96 | * @returns A list of Berry Flavors 97 | */ 98 | public async listBerryFlavors(offset?: number, limit?: number): Promise { 99 | return this.getListResource(ENDPOINTS.BERRY_FLAVOR, offset, limit); 100 | } 101 | } 102 | -------------------------------------------------------------------------------- /src/clients/contest.client.ts: -------------------------------------------------------------------------------- 1 | import { ENDPOINTS } from "@constants"; 2 | import type { ContestEffect, ContestType, NamedAPIResourceList, SuperContestEffect } from "@models"; 3 | import { BaseClient } from "./base"; 4 | 5 | /** 6 | * ### Contest Client 7 | * 8 | * Client used to access the Contest Endpoints: 9 | * - [Contest Types](https://pokeapi.co/docs/v2#contest-types) 10 | * - [Contest Effects](https://pokeapi.co/docs/v2#contest-effects) 11 | * - [Super Contest Effects](https://pokeapi.co/docs/v2#super-contest-effects) 12 | * --- 13 | * See [PokéAPI Documentation](https://pokeapi.co/docs/v2#contests-section) 14 | */ 15 | export class ContestClient extends BaseClient { 16 | /** 17 | * Get a Contest Type by it's name 18 | * @param name The contest type name 19 | * @returns A Contest Type 20 | */ 21 | public async getContestTypeByName(name: string): Promise { 22 | return this.getResource(ENDPOINTS.CONTEST_TYPE, name); 23 | } 24 | 25 | /** 26 | * Get a Contest Type by it's ID 27 | * @param id The Contest Type ID 28 | * @returns A Contest Type 29 | */ 30 | public async getContestTypeById(id: number): Promise { 31 | return this.getResource(ENDPOINTS.CONTEST_TYPE, id); 32 | } 33 | 34 | /** 35 | * Get a Contest Effect by it's ID 36 | * @param id The Contest Effect ID 37 | * @returns Contest Effect 38 | */ 39 | public async getContestEffectById(id: number): Promise { 40 | return this.getResource(ENDPOINTS.CONTEST_EFFECT, id); 41 | } 42 | 43 | /** 44 | * Get a Super Contest Effect by it's ID 45 | * @param id The Super Contest Effect ID 46 | * @returns Super Contest Effect 47 | */ 48 | public async getSuperContestEffectById(id: number): Promise { 49 | return this.getResource(ENDPOINTS.SUPER_CONTEST_EFFECT, id); 50 | } 51 | 52 | /** 53 | * List Contest Types 54 | * @param offset The first item that you will get 55 | * @param limit How many contest types per page 56 | * @returns A list of contest types 57 | */ 58 | public async listContestTypes(offset?: number, limit?: number): Promise { 59 | return this.getListResource(ENDPOINTS.CONTEST_TYPE, offset, limit); 60 | } 61 | 62 | /** 63 | * List Contest Effects 64 | * @param offset The first item that you will get 65 | * @param limit How many contest effects per page 66 | * @returns A list of contest effects 67 | */ 68 | public async listContestEffects(offset?: number, limit?: number): Promise { 69 | return this.getListResource(ENDPOINTS.CONTEST_EFFECT, offset, limit); 70 | } 71 | 72 | /** 73 | * List Super Contest Effects 74 | * @param offset The first item that you will get 75 | * @param limit How many Super Contest Effect per page 76 | * @returns A list of Super Contest Effect 77 | */ 78 | public async listSuperContestEffects( 79 | offset?: number, 80 | limit?: number, 81 | ): Promise { 82 | return this.getListResource(ENDPOINTS.SUPER_CONTEST_EFFECT, offset, limit); 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /src/clients/evolution.client.ts: -------------------------------------------------------------------------------- 1 | import { ENDPOINTS } from "@constants"; 2 | import type { EvolutionChain, EvolutionTrigger, NamedAPIResourceList } from "@models"; 3 | import { BaseClient } from "./base"; 4 | 5 | /** 6 | * ### Evolution Client 7 | * 8 | * Client used to access the Berry Endpoints: 9 | * - [Evolution Chains](https://pokeapi.co/docs/v2#evolution-chains) 10 | * - [Evolution Triggers](https://pokeapi.co/docs/v2#evolution-triggers) 11 | * --- 12 | * See [PokéAPI Documentation](https://pokeapi.co/docs/v2#evolution-section) 13 | */ 14 | export class EvolutionClient extends BaseClient { 15 | /** 16 | * Get an Evolution Chain by it's ID 17 | * @param id The Evolution Chain ID 18 | * @returns An Evolution Chain 19 | */ 20 | public async getEvolutionChainById(id: number): Promise { 21 | return this.getResource(ENDPOINTS.EVOLUTION_CHAIN, id); 22 | } 23 | 24 | /** 25 | * Get an Evolution Trigger by it's ID 26 | * @param id The Evolution Trigger ID 27 | * @returns An Evolution Trigger 28 | */ 29 | public async getEvolutionTriggerById(id: number): Promise { 30 | return this.getResource(ENDPOINTS.EVOLUTION_TRIGGER, id); 31 | } 32 | 33 | /** 34 | * Get an Evolution Trigger by it's name 35 | * @param name The Evolution Trigger name 36 | * @returns An Evolution Trigger 37 | */ 38 | public async getEvolutionTriggerByName(name: string): Promise { 39 | return this.getResource(ENDPOINTS.EVOLUTION_TRIGGER, name); 40 | } 41 | 42 | /** 43 | * List Evolution Chains 44 | * @param offset The first item that you will get 45 | * @param limit How many Evolution Chains per page 46 | * @returns A list of Evolution Chains 47 | */ 48 | public async listEvolutionChains(offset?: number, limit?: number): Promise { 49 | return this.getListResource(ENDPOINTS.EVOLUTION_CHAIN, offset, limit); 50 | } 51 | 52 | /** 53 | * List Evolution Triggers 54 | * @param offset The first item that you will get 55 | * @param limit How many Evolution Triggers per page 56 | * @returns A list of Evolution Triggers 57 | */ 58 | public async listEvolutionTriggers( 59 | offset?: number, 60 | limit?: number, 61 | ): Promise { 62 | return this.getListResource(ENDPOINTS.EVOLUTION_TRIGGER, offset, limit); 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /src/clients/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./berry.client"; 2 | export * from "./contest.client"; 3 | export * from "./encounter.client"; 4 | export * from "./evolution.client"; 5 | export * from "./game.client"; 6 | export * from "./item.client"; 7 | export * from "./location.client"; 8 | export * from "./machine.client"; 9 | export * from "./move.client"; 10 | export * from "./pokemon.client"; 11 | export * from "./utility.client"; 12 | export * from "./main.client"; 13 | -------------------------------------------------------------------------------- /src/clients/machine.client.ts: -------------------------------------------------------------------------------- 1 | import { ENDPOINTS } from "@constants"; 2 | import type { Machine, NamedAPIResourceList } from "@models"; 3 | import { BaseClient } from "./base"; 4 | 5 | /** 6 | * ### Machine Client 7 | * 8 | * Client used to access the Machine Endpoints: 9 | * - [Machines](https://pokeapi.co/docs/v2#machines) 10 | * 11 | * See [PokéAPI Documentation](https://pokeapi.co/docs/v2#machines-section) 12 | */ 13 | export class MachineClient extends BaseClient { 14 | /** 15 | * Get a Machine by it's ID 16 | * @param id The Machine ID 17 | * @returns A Machine 18 | */ 19 | public async getMachineById(id: number): Promise { 20 | return this.getResource(ENDPOINTS.MACHINE, id); 21 | } 22 | 23 | /** 24 | * List Machines 25 | * @param offset The first item that you will get 26 | * @param limit How many Machines per page 27 | * @returns A list of Machines 28 | */ 29 | public async listMachines(offset?: number, limit?: number): Promise { 30 | return this.getListResource(ENDPOINTS.MACHINE, offset, limit); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/clients/main.client.ts: -------------------------------------------------------------------------------- 1 | import { 2 | BerryClient, 3 | ContestClient, 4 | EncounterClient, 5 | EvolutionClient, 6 | GameClient, 7 | ItemClient, 8 | LocationClient, 9 | MachineClient, 10 | MoveClient, 11 | PokemonClient, 12 | UtilityClient, 13 | } from "@clients"; 14 | import { BaseClient, type ClientArgs } from "./base"; 15 | 16 | /** 17 | * ### Main Client 18 | * 19 | * The main client used to access all the PokéAPI Endpoints: 20 | * - [Berries](https://pokeapi.co/docs/v2#berries-section) 21 | * - [Contests](https://pokeapi.co/docs/v2#contests-section) 22 | * - [Encounters](https://pokeapi.co/docs/v2#encounters-section) 23 | * - [Evolution](https://pokeapi.co/docs/v2#evolution-section) 24 | * - [Games](https://pokeapi.co/docs/v2#games-section) 25 | * - [Items](https://pokeapi.co/docs/v2#items-section) 26 | * - [Locations](https://pokeapi.co/docs/v2#locations-section) 27 | * - [Machines](https://pokeapi.co/docs/v2#machines-section) 28 | * - [Moves](https://pokeapi.co/docs/v2#moves-section) 29 | * - [Pokémon](https://pokeapi.co/docs/v2#pokemon-section) 30 | * - [Utility](https://pokeapi.co/docs/v2#utility-section) 31 | * --- 32 | * See [PokéAPI Documentation](https://pokeapi.co/docs/v2) 33 | */ 34 | export class MainClient extends BaseClient { 35 | public berry: BerryClient; 36 | public contest: ContestClient; 37 | public encounter: EncounterClient; 38 | public evolution: EvolutionClient; 39 | public game: GameClient; 40 | public item: ItemClient; 41 | public location: LocationClient; 42 | public machine: MachineClient; 43 | public move: MoveClient; 44 | public pokemon: PokemonClient; 45 | public utility: UtilityClient; 46 | 47 | constructor(clientOptions?: ClientArgs) { 48 | super(clientOptions); 49 | 50 | this.berry = new BerryClient(clientOptions); 51 | this.contest = new ContestClient(clientOptions); 52 | this.encounter = new EncounterClient(clientOptions); 53 | this.evolution = new EvolutionClient(clientOptions); 54 | this.game = new GameClient(clientOptions); 55 | this.item = new ItemClient(clientOptions); 56 | this.location = new LocationClient(clientOptions); 57 | this.machine = new MachineClient(clientOptions); 58 | this.move = new MoveClient(clientOptions); 59 | this.pokemon = new PokemonClient(clientOptions); 60 | this.utility = new UtilityClient(clientOptions); 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/clients/utility.client.ts: -------------------------------------------------------------------------------- 1 | import { ENDPOINTS } from "@constants"; 2 | import type { Language, NamedAPIResourceList } from "@models"; 3 | import { BaseClient } from "./base"; 4 | 5 | /** 6 | * ### Utility Client 7 | * 8 | * Client used to access the Utility Endpoints: 9 | * - [Languages](https://pokeapi.co/docs/v2#utility-section) 10 | * - Resources 11 | * --- 12 | * See [PokéAPI Documentation](https://pokeapi.co/docs/v2#utility-section) 13 | */ 14 | export class UtilityClient extends BaseClient { 15 | /** 16 | * Get a Language by it's ID 17 | * @param id The Language ID 18 | * @returns Language 19 | */ 20 | public async getLanguageById(id: number): Promise { 21 | return this.getResource(ENDPOINTS.LANGUAGE, id); 22 | } 23 | 24 | /** 25 | * Get a Language by it's name 26 | * @param name The Language name 27 | * @returns Language 28 | */ 29 | public async getLanguageByName(name: string): Promise { 30 | return this.getResource(ENDPOINTS.LANGUAGE, name); 31 | } 32 | 33 | /** 34 | * Get a Resource by it's url 35 | * @param url The Resource url 36 | * @returns Resource 37 | */ 38 | public async getResourceByUrl(url: string): Promise { 39 | return this.getResourceByURL(url); 40 | } 41 | 42 | /** 43 | * List Languages 44 | * @param offset The first item that you will get 45 | * @param limit How many Languages per page 46 | * @returns A list of Languages 47 | */ 48 | public listLanguages(offset?: number, limit?: number): Promise { 49 | return this.getListResource(ENDPOINTS.LANGUAGE, offset, limit); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/config/logger.ts: -------------------------------------------------------------------------------- 1 | import type { AxiosError } from "axios"; 2 | import type { CacheAxiosResponse, InternalCacheRequestConfig } from "axios-cache-interceptor"; 3 | 4 | export const handleRequest = ( 5 | config: InternalCacheRequestConfig, 6 | logsEnabled?: boolean, 7 | ): InternalCacheRequestConfig => { 8 | if (logsEnabled) { 9 | console.log(`[ Request Config ] ${config.method?.toUpperCase() || ""} | ${config.url || ""}`); 10 | } 11 | return config; 12 | }; 13 | 14 | export const handleRequestError = ( 15 | error: AxiosError, 16 | logsEnabled?: boolean, 17 | ): Promise> => { 18 | if (logsEnabled) { 19 | console.error(`[ Request Error ] CODE ${error.code || "UNKNOWN"} | ${error.message}`); 20 | } 21 | return Promise.reject(error); 22 | }; 23 | 24 | export const handleResponse = ( 25 | response: CacheAxiosResponse, 26 | logsEnabled?: boolean, 27 | ): CacheAxiosResponse => { 28 | if (logsEnabled) { 29 | console.log( 30 | `[ Response ] STATUS ${response.status} | ${response.cached ? "CACHED" : "NOT CACHED"}`, 31 | ); 32 | } 33 | return response; 34 | }; 35 | 36 | export const handleResponseError = ( 37 | error: AxiosError, 38 | logsEnabled?: boolean, 39 | ): Promise> => { 40 | if (logsEnabled) { 41 | console.error(`[ Response Error ] CODE ${error.code || "UNKNOWN"} | ${error.message}`); 42 | } 43 | return Promise.reject(error); 44 | }; 45 | -------------------------------------------------------------------------------- /src/constants/base.ts: -------------------------------------------------------------------------------- 1 | export const BASE_URL = { 2 | REST: "https://pokeapi.co/api/v2", 3 | } as const; 4 | -------------------------------------------------------------------------------- /src/constants/berries.ts: -------------------------------------------------------------------------------- 1 | /** Enum of Berries (NAME - ID) */ 2 | export const BERRIES = { 3 | CHERI: 1, 4 | CHESTO: 2, 5 | PECHA: 3, 6 | RAWST: 4, 7 | ASPEAR: 5, 8 | LEPPA: 6, 9 | ORAN: 7, 10 | PERSIM: 8, 11 | LUM: 9, 12 | SITRUS: 10, 13 | FIGY: 11, 14 | WIKI: 12, 15 | MAGO: 13, 16 | AGUAV: 14, 17 | IAPAPA: 15, 18 | RAZZ: 16, 19 | BLUK: 17, 20 | NANAB: 18, 21 | WEPEAR: 19, 22 | PINAP: 20, 23 | POMEG: 21, 24 | KELPSY: 22, 25 | QUALOT: 23, 26 | HONDEW: 24, 27 | GREPA: 25, 28 | TAMATO: 26, 29 | CORNN: 27, 30 | MAGOST: 28, 31 | RABUTA: 29, 32 | NOMEL: 30, 33 | SPELON: 31, 34 | PAMTRE: 32, 35 | WATMEL: 33, 36 | DURIN: 34, 37 | BELUE: 35, 38 | OCCA: 36, 39 | PASSHO: 37, 40 | WACAN: 38, 41 | RINDO: 39, 42 | YACHE: 40, 43 | CHOPLE: 41, 44 | KEBIA: 42, 45 | SHUCA: 43, 46 | COBA: 44, 47 | PAYAPA: 45, 48 | TANGA: 46, 49 | CHARTI: 47, 50 | KASIB: 48, 51 | HABAN: 49, 52 | COLBUR: 50, 53 | BABIRI: 51, 54 | CHILAN: 52, 55 | LIECHI: 53, 56 | GANLON: 54, 57 | SALAC: 55, 58 | PETAYA: 56, 59 | APICOT: 57, 60 | LANSAT: 58, 61 | STARF: 59, 62 | ENIGMA: 60, 63 | MICLE: 61, 64 | CUSTAP: 62, 65 | JABOCA: 63, 66 | ROWAP: 64, 67 | } as const; 68 | 69 | /** Enum of Berry Firmnesses (NAME - ID) */ 70 | export const BERRY_FIRMNESSES = { 71 | VERY_SOFT: 1, 72 | SOFT: 2, 73 | HARD: 3, 74 | VERY_HARD: 4, 75 | SUPER_HARD: 5, 76 | } as const; 77 | 78 | export const BERRY_FLAVORS = { 79 | SPICY: 1, 80 | DRY: 2, 81 | SWEET: 3, 82 | BITTER: 4, 83 | SOUR: 5, 84 | } as const; 85 | -------------------------------------------------------------------------------- /src/constants/contests.ts: -------------------------------------------------------------------------------- 1 | export const CONTEST_TYPES = { 2 | COOL: 1, 3 | BEAUTY: 2, 4 | CUTE: 3, 5 | SMART: 4, 6 | TOUGH: 5, 7 | } as const; 8 | -------------------------------------------------------------------------------- /src/constants/encounters.ts: -------------------------------------------------------------------------------- 1 | export const ENCOUNTER_METHODS = { 2 | WALK: 1, 3 | OLD_ROD: 2, 4 | GOOD_ROD: 3, 5 | SUPER_ROD: 4, 6 | SURF: 5, 7 | ROCK_SMASH: 6, 8 | HEADBUTT: 7, 9 | DARK_GRASS: 8, 10 | GRASS_SPOTS: 9, 11 | CAVE_SPOTS: 10, 12 | BRIDGE_SPOTS: 11, 13 | SUPER_ROD_SPOTS: 12, 14 | SURF_SPOTS: 13, 15 | YELLOW_FLOWERS: 14, 16 | PURPLE_FLOWERS: 15, 17 | RED_FLOWERS: 16, 18 | ROUGH_TERRAIN: 17, 19 | GIFT: 18, 20 | GIFT_EGG: 19, 21 | ONLY_ONE: 20, 22 | POKEFLUTE: 21, 23 | HEADBUTT_LOW: 22, 24 | HEADBUTT_NORMAL: 23, 25 | HEADBUT_HIGH: 24, 26 | SQUIRT_BOTTLE: 25, 27 | WAILMER_PAIL: 26, 28 | SEAWEED: 27, 29 | } as const; 30 | 31 | export const ENCOUNTER_CONDITIONS = { 32 | SWARM: 1, 33 | TIME: 2, 34 | RADAR: 3, 35 | SLOT2: 4, 36 | RADIO: 5, 37 | SEASON: 6, 38 | STARTER: 7, 39 | TV_OPTION: 8, 40 | STORY_PROGRESS: 9, 41 | OTHER: 10, 42 | } as const; 43 | 44 | export const ENCOUNTER_CONDITION_VALUES = { 45 | SWARM_YES: 1, 46 | SWARM_NO: 2, 47 | TIME_MORNING: 3, 48 | TIME_DAY: 4, 49 | TIME_NIGHT: 5, 50 | RADAR_ON: 6, 51 | RADAR_OFF: 7, 52 | SLOT2_NONE: 8, 53 | SLOT2_RUBY: 9, 54 | SLOT2_SAPHIRE: 10, 55 | SLOT2_EMERALD: 11, 56 | SLOT2_FIRERED: 12, 57 | SLOT2_LEAFGREEN: 13, 58 | RADIO_OFF: 14, 59 | RADIO_HOEN: 15, 60 | RADIO_SINNOH: 16, 61 | SEASON_SPRING: 17, 62 | SEASON_SUMMER: 18, 63 | SWASON_AUTUMN: 19, 64 | SEASON_WINTER: 20, 65 | STARTER_BULBASAUR: 21, 66 | STARTER_SQUIRTLE: 22, 67 | STARTER_CHARMANDER: 23, 68 | STARTER_CHESPIN: 24, 69 | STARTER_FENNEKIN: 25, 70 | STARTER_FROAKIE: 26, 71 | TV_OPTION_BLUE: 27, 72 | TV_OPTION_RED: 28, 73 | STORY_PROGRESS_AWAKENED_BEASTS: 29, 74 | STORY_PROGRESS_BEAT_GALACTIC_CORONET: 30, 75 | STORY_PROGRESS_OAK_ETERNA_CITY: 31, 76 | STORY_PROGRESS_OAK_VERMILION_COPYCAT: 32, 77 | STORY_PROGRESS_MET_TORNADUS_THUNDURUS: 33, 78 | STORY_PROGRESS_BEAT_ELITE_FOUR_ROUND_TWO: 34, 79 | STORY_PROGRESS_HALL_OF_FAME: 35, 80 | STORY_PROGRESS_NONE: 36, 81 | STORY_PROGRESS_NATIONAL_DEX: 37, 82 | OTHER_NONE: 38, 83 | OTHER_SNORLAX_LL_BEAT_LEAGUE: 39, 84 | } as const; 85 | -------------------------------------------------------------------------------- /src/constants/endpoints.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Endpoints of the PokéAPI 3 | */ 4 | export const ENDPOINTS = { 5 | BERRY: "/berry", 6 | BERRY_FIRMNESS: "/berry-firmness", 7 | BERRY_FLAVOR: "/berry-flavor", 8 | CONTEST_TYPE: "/contest-type", 9 | CONTEST_EFFECT: "/contest-effect", 10 | SUPER_CONTEST_EFFECT: "/super-contest-effect", 11 | ENCOUNTER_METHOD: "/encounter-method", 12 | ENCOUNTER_CONDITION: "/encounter-condition", 13 | ENCOUNTER_CONDITION_VALUE: "/encounter-condition-value", 14 | EVOLUTION_CHAIN: "/evolution-chain", 15 | EVOLUTION_TRIGGER: "/evolution-trigger", 16 | GENERATION: "/generation", 17 | POKEDEX: "/pokedex", 18 | VERSION: "/version", 19 | VERSION_GROUP: "/version-group", 20 | ITEM: "/item", 21 | ITEM_ATTRIBUTE: "/item-attribute", 22 | ITEM_CATEGORY: "/item-category", 23 | ITEM_FLING_EFFECT: "/item-fling-effect", 24 | ITEM_POCKET: "/item-pocket", 25 | LOCATION: "/location", 26 | LOCATION_AREA: "/location-area", 27 | PALPARK_AREA: "/pal-park-area", 28 | REGION: "/region", 29 | MACHINE: "/machine", 30 | MOVE: "/move", 31 | MOVE_AILMENT: "/move-ailment", 32 | MOVE_BATTLE_STYLE: "/move-battle-style", 33 | MOVE_CATEGORY: "/move-category", 34 | MOVE_DAMAGE_CLASS: "/move-damage-class", 35 | MOVE_LEARN_METHOD: "/move-learn-method", 36 | MOVE_TARGET: "/move-target", 37 | ABILITY: "/ability", 38 | CHARACTERISTIC: "/characteristic", 39 | EGG_GROUP: "/egg-group", 40 | GENDER: "/gender", 41 | GROWTH_RATE: "/growth-rate", 42 | NATURE: "/nature", 43 | POKEATHLON_STAT: "/pokeathlon-stat", 44 | POKEMON: "/pokemon", 45 | POKEMON_LOCATION_AREA: "/pokemon/:id/encounters", 46 | POKEMON_COLOR: "/pokemon-color", 47 | POKEMON_FORM: "/pokemon-form", 48 | POKEMON_HABITAT: "/pokemon-habitat", 49 | POKEMON_SHAPE: "/pokemon-shape", 50 | POKEMON_SPECIES: "/pokemon-species", 51 | STAT: "/stat", 52 | TYPE: "/type", 53 | LANGUAGE: "/language", 54 | } as const; 55 | 56 | type ObjectValue = T[keyof T]; 57 | export type Endpoint = ObjectValue; 58 | -------------------------------------------------------------------------------- /src/constants/evolutions.ts: -------------------------------------------------------------------------------- 1 | export const EVOLUTION_TRIGGERS = { 2 | LEVEL_UP: 1, 3 | TRADE: 2, 4 | USE_ITEM: 3, 5 | SHED: 4, 6 | SPIN: 5, 7 | TOWER_OF_DARKNESS: 6, 8 | TOWER_OF_WATER: 7, 9 | THREE_CRITICAL_HITS: 8, 10 | TAKE_DAMAGE: 9, 11 | OTHER: 10, 12 | } as const; 13 | -------------------------------------------------------------------------------- /src/constants/games.ts: -------------------------------------------------------------------------------- 1 | export const GENERATIONS = { 2 | GENERATION_I: 1, 3 | GENERATION_II: 2, 4 | GENERATION_III: 3, 5 | GENERATION_IV: 4, 6 | GENERATION_V: 5, 7 | GENERATION_VI: 6, 8 | GENERATION_VII: 7, 9 | GENERATION_VIII: 8, 10 | } as const; 11 | 12 | export const POKEDEXES = { 13 | NATIONAL: 1, 14 | KANTO: 2, 15 | ORIGINAL_JOHTO: 3, 16 | HOENN: 4, 17 | ORIGINAL_SINNOH: 5, 18 | EXTENDED_SINNOH: 6, 19 | UPDATED_JOHTO: 7, 20 | ORIGINAL_UNOVA: 8, 21 | UPDATED_UNOVA: 9, 22 | CONQUEST_GALLERY: 11, 23 | KALOS_CENTRAL: 12, 24 | KALOS_COASTAL: 13, 25 | KALOS_MONTAIN: 14, 26 | UPDATED_HOENN: 15, 27 | ORIGINAL_ALOLA: 16, 28 | ORIGINAL_MELEMELE: 17, 29 | ORIGINAL_AKALA: 18, 30 | ORIGINAL_ULAULA: 19, 31 | ORIGINAL_PONI: 20, 32 | UPDATED_ALOLA: 21, 33 | UPDATED_MELEMELE: 22, 34 | UPDATED_AKALA: 23, 35 | UPDATED_ULAULA: 24, 36 | UPDATED_PONI: 25, 37 | UPDATED_KANTO: 26, 38 | GALAR: 27, 39 | ISLE_OF_ARMOR: 28, 40 | CROWN_TUNDRA: 29, 41 | } as const; 42 | 43 | export const VERSIONS = { 44 | RED: 1, 45 | BLUE: 2, 46 | YELLOW: 3, 47 | GOLD: 4, 48 | SILVER: 5, 49 | CRYSTAL: 6, 50 | RUBY: 7, 51 | SAPPHIRE: 8, 52 | EMERALD: 9, 53 | FIRERED: 10, 54 | LEAFGREEN: 11, 55 | DIAMOND: 12, 56 | PEARL: 13, 57 | PLATINUM: 14, 58 | HEARTGOLD: 15, 59 | SOULSILVER: 16, 60 | BLACK: 17, 61 | WHITE: 18, 62 | COLOSSEUM: 19, 63 | XD: 20, 64 | BLACK_2: 21, 65 | WHITE_2: 22, 66 | X: 23, 67 | Y: 24, 68 | OMEGA_RUBY: 25, 69 | ALPHA_SAPPHIRE: 26, 70 | SUN: 27, 71 | MOON: 28, 72 | ULTRA_SUN: 29, 73 | ULTRA_MOON: 30, 74 | LETS_GO_PIKACHU: 31, 75 | LETS_GO_EEVEE: 32, 76 | SWORD: 33, 77 | SHIELD: 34, 78 | THE_ISLE_OF_ARMOR: 35, 79 | THE_CROWN_TUNDRA: 36, 80 | BRILLIANT_DIAMOND: 37, 81 | SHINING_PEARL: 38, 82 | LEGENDS_ARCEUS: 39, 83 | } as const; 84 | 85 | export const VERSION_GROUPS = { 86 | RED_BLUE: 1, 87 | YELLOW: 2, 88 | GOLD_SILVER: 3, 89 | CRYSTAL: 4, 90 | RUBY_SAPPHIRE: 5, 91 | EMERALD: 6, 92 | FIRERED_LEAFGREEN: 7, 93 | DIAMOND_PEARL: 8, 94 | PLATINUM: 9, 95 | HEARTGOLD_SOULSILVER: 10, 96 | BLACK_WHITE: 11, 97 | COLOSSEUM: 12, 98 | XD: 13, 99 | BLACK_2_WHITE_2: 14, 100 | X_Y: 15, 101 | OMEGA_RUBY_ALPHA_SAPPHIRE: 16, 102 | SUN_MOON: 17, 103 | ULTRA_SUN_ULTRA_MOON: 18, 104 | LETS_GO: 19, 105 | SWORD_SHIELD: 20, 106 | THE_ISLE_OF_ARMOR: 21, 107 | THE_CROWN_TUNDRA: 22, 108 | BRILLIANT_DIAMOND_AND_SHINING_PEARL: 23, 109 | LEGENDS_ARCEUS: 24, 110 | } as const; 111 | -------------------------------------------------------------------------------- /src/constants/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./base"; 2 | export * from "./endpoints"; 3 | export * from "./berries"; 4 | export * from "./contests"; 5 | export * from "./encounters"; 6 | export * from "./evolutions"; 7 | export * from "./games"; 8 | export * from "./locations"; 9 | export * from "./moves"; 10 | export * from "./pokemons"; 11 | export * from "./utilities"; 12 | export * from "./items"; 13 | -------------------------------------------------------------------------------- /src/constants/items.ts: -------------------------------------------------------------------------------- 1 | export const ITEM_ATTRIBUTES = { 2 | COUNTABLE: 1, 3 | CONSUMABLE: 2, 4 | USABLE_OVERWORLD: 3, 5 | USABLE_IN_BATTLE: 4, 6 | HOLDABLE: 5, 7 | HOLDABLE_PASSIVE: 6, 8 | HOLDABLE_ACTIVE: 7, 9 | UNDERGROUND: 8, 10 | } as const; 11 | 12 | export const ITEM_CATEGORIES = { 13 | STAT_BOOSTS: 1, 14 | EFFORT_DROP: 2, 15 | MEDICINE: 3, 16 | OTHER: 4, 17 | IN_A_PINCH: 5, 18 | PICKY_HEALING: 6, 19 | TYPE_PROTECTION: 7, 20 | BAKING_ONLY: 8, 21 | COLLECTIBLES: 9, 22 | EVOLUTION: 10, 23 | SPELUNKING: 11, 24 | HELD_ITEMS: 12, 25 | CHOICE: 13, 26 | EFFORT_TRAINING: 14, 27 | BAD_HELD_ITEMS: 15, 28 | TRAINING: 16, 29 | PLATES: 17, 30 | SPECIES_SPECIFIC: 18, 31 | TYPE_ENHANCEMENT: 19, 32 | EVENT_ITEMS: 20, 33 | GAMEPLAY: 21, 34 | PLOT_ADVANCEMENT: 22, 35 | UNUSED: 23, 36 | LOOT: 24, 37 | ALL_MAIL: 25, 38 | VITAMINS: 26, 39 | HEALING: 27, 40 | PP_RECOVERY: 28, 41 | REVIVAL: 29, 42 | STATUS_CURES: 30, 43 | MULCH: 32, 44 | SPECIAL_BALLS: 33, 45 | STANDARD_BALLS: 34, 46 | DEX_COMPLETION: 35, 47 | SCARVES: 36, 48 | ALL_MACHINES: 37, 49 | FLUTES: 38, 50 | APRICORN_BALLS: 39, 51 | APRICORN_BOX: 40, 52 | DATA_CARDS: 41, 53 | JEWELS: 42, 54 | MIRACLE_SHOOTER: 43, 55 | MEGA_STONES: 44, 56 | MEMORIES: 45, 57 | Z_CRYSTALS: 46, 58 | SPECIES_CANDIES: 47, 59 | CATCHING_BONUS: 48, 60 | DYNAMAX_CRISTALS: 49, 61 | NATURE_MINTS: 50, 62 | CURRY_INGREDIENTS: 51, 63 | } as const; 64 | 65 | export const ITEM_FLING_EFFECTS = { 66 | BADLY_POISON: 1, 67 | BURN: 2, 68 | BERRY_EFFECT: 3, 69 | HERB_EFFECT: 4, 70 | PARALYZE: 5, 71 | POISON: 6, 72 | FLINCH: 7, 73 | } as const; 74 | 75 | export const ITEM_POCKETS = { 76 | MISC: 1, 77 | MEDICINE: 2, 78 | POKEBALLS: 3, 79 | MACHINES: 4, 80 | BERRIES: 5, 81 | MAIL: 6, 82 | BATTLE: 7, 83 | KEY: 8, 84 | } as const; 85 | -------------------------------------------------------------------------------- /src/constants/locations.ts: -------------------------------------------------------------------------------- 1 | export const REGIONS = { 2 | KANTO: 1, 3 | JOHTO: 2, 4 | HOENN: 3, 5 | SINNOH: 4, 6 | UNOVA: 5, 7 | KALOS: 6, 8 | ALOLA: 7, 9 | GALAR: 8, 10 | HISUI: 9, 11 | } as const; 12 | 13 | export const PAL_PARK_AREAS = { 14 | FOREST: 1, 15 | FIELD: 2, 16 | MOUNTAIN: 3, 17 | POND: 4, 18 | SEA: 5, 19 | } as const; 20 | -------------------------------------------------------------------------------- /src/constants/moves.ts: -------------------------------------------------------------------------------- 1 | export const MOVE_AILMENTS = { 2 | UNKNOWN: -1, 3 | NONE: 0, 4 | PARALYSIS: 1, 5 | SLEEP: 2, 6 | FREEZE: 3, 7 | BURN: 4, 8 | POISON: 5, 9 | CONFUSION: 6, 10 | INFATUATION: 7, 11 | TRAP: 8, 12 | NIGHTMARE: 9, 13 | TORMENT: 12, 14 | DISABLE: 13, 15 | YAWN: 14, 16 | HEAL_BLOCK: 15, 17 | NO_TYPE_IMMUNITY: 17, 18 | LEECH_SEED: 18, 19 | EMBARGO: 19, 20 | PERISH_SONG: 20, 21 | INGRAIN: 21, 22 | SILENCE: 24, 23 | TAR_SHOT: 42, 24 | } as const; 25 | 26 | export const MOVE_BATTLE_STYLES = { 27 | ATTACK: 1, 28 | DEFENSE: 2, 29 | SUPPORT: 3, 30 | } as const; 31 | 32 | export const MOVE_CATEGORIES = { 33 | DAMAGE: 0, 34 | AILMENT: 1, 35 | NET_GOOD_STATS: 2, 36 | HEAL: 3, 37 | DAMAGE_AILMENT: 4, 38 | SWAGGER: 5, 39 | DAMAGE_LOWER: 6, 40 | DAMAGE_RAISE: 7, 41 | DAMAGE_HEAL: 8, 42 | OHKO: 9, 43 | WHOLE_FIELD_EFFECT: 10, 44 | FIELD_EFFECT: 11, 45 | FORCE_SWITCH: 12, 46 | UNIQUE: 13, 47 | } as const; 48 | 49 | export const MOVE_DAMAGE_CLASSES = { 50 | STATUS: 1, 51 | PHYSICAL: 2, 52 | SPECIAL: 3, 53 | } as const; 54 | 55 | export const MOVE_LEARN_METHODS = { 56 | LEVEL_UP: 1, 57 | EGG: 2, 58 | TUTOR: 3, 59 | MACHINE: 4, 60 | STADIUM_SURFING_PIKACHU: 5, 61 | LIGHT_BALL_EGG: 6, 62 | COLOSSEUM_PURIFICATION: 7, 63 | XD_SHADOW: 8, 64 | XD_PURIFICATION: 9, 65 | FORM_CHANGE: 10, 66 | } as const; 67 | 68 | export const MOVE_TARGETS = { 69 | SPECIFIC_MOVE: 1, 70 | SELECTED_POKEMON_ME_FIRST: 2, 71 | ALLY: 3, 72 | USERS_FIELD: 4, 73 | USER_OR_ALLY: 5, 74 | OPPONENTS_FIELD: 6, 75 | USER: 7, 76 | RANDOM_OPPONENT: 8, 77 | ALL_OTHER_POKEMON: 9, 78 | SELECTED_POKEMON: 10, 79 | ALL_OPPONENTS: 11, 80 | ENTIRE_FIELD: 12, 81 | USER_AND_ALIES: 13, 82 | ALL_POKEMON: 14, 83 | ALL_ALLIES: 15, 84 | } as const; 85 | -------------------------------------------------------------------------------- /src/constants/pokemons.ts: -------------------------------------------------------------------------------- 1 | export const EGG_GROUPS = { 2 | MONSTER: 1, 3 | WATER1: 2, 4 | BUG: 3, 5 | FLYING: 4, 6 | GROUND: 5, 7 | FAIRY: 6, 8 | PLANT: 7, 9 | HUMANSHAPE: 8, 10 | WATER3: 9, 11 | MINERAL: 10, 12 | INDETERMINATE: 11, 13 | WATER2: 12, 14 | DITTO: 13, 15 | DRAGON: 14, 16 | NO_EGGS: 15, 17 | } as const; 18 | 19 | export const GENDERS = { 20 | FEMALE: 1, 21 | MALE: 2, 22 | GENDERLESS: 3, 23 | } as const; 24 | 25 | export const GROWTH_RATES = { 26 | SLOW: 1, 27 | MEDIUM: 2, 28 | FAST: 3, 29 | MEDIUM_SLOW: 4, 30 | SLOW_THEN_VERY_FAST: 5, 31 | FAST_THEN_VERY_SLOW: 6, 32 | } as const; 33 | 34 | export const NATURES = { 35 | HARDY: 1, 36 | BOLD: 2, 37 | MODEST: 3, 38 | CALM: 4, 39 | TIMID: 5, 40 | LONELY: 6, 41 | DOCILE: 7, 42 | MILD: 8, 43 | GENTLE: 9, 44 | HASTY: 10, 45 | ADAMANT: 11, 46 | IMPISH: 12, 47 | BASHFUL: 13, 48 | CAREFUL: 14, 49 | RASH: 15, 50 | JOLLY: 16, 51 | NAUGHTY: 17, 52 | LAX: 18, 53 | QUIRKY: 19, 54 | NAIVE: 20, 55 | BRAVE: 21, 56 | RELAXED: 22, 57 | QUIET: 23, 58 | SASSY: 24, 59 | SERIOUS: 25, 60 | } as const; 61 | 62 | export const POKEATHLON_STATS = { 63 | SPEED: 1, 64 | POWER: 2, 65 | SKILL: 3, 66 | STAMINA: 4, 67 | JUMP: 5, 68 | } as const; 69 | 70 | export const POKEMON_COLORS = { 71 | BLACK: 1, 72 | BLUE: 2, 73 | BROWN: 3, 74 | GRAY: 4, 75 | GREEN: 5, 76 | PINK: 6, 77 | PURPLE: 7, 78 | RED: 8, 79 | WHITE: 9, 80 | YELLOW: 10, 81 | } as const; 82 | 83 | export const POKEMON_HABITATS = { 84 | CAVE: 1, 85 | FOREST: 2, 86 | GRASSLAND: 3, 87 | MONTAIN: 4, 88 | RARE: 5, 89 | ROUGH_TERRAIN: 6, 90 | SEA: 7, 91 | URBAN: 8, 92 | WATERS_EDGE: 9, 93 | } as const; 94 | 95 | export const POKEMON_SHAPES = { 96 | BALL: 1, 97 | SQUIGGLE: 2, 98 | FISH: 3, 99 | ARMS: 4, 100 | BLOB: 5, 101 | UPRIGHT: 6, 102 | LEGS: 7, 103 | QUADRUPED: 8, 104 | WINGS: 9, 105 | TENTACLES: 10, 106 | HEADS: 11, 107 | HUMANOID: 12, 108 | BUG_WINGS: 13, 109 | ARMOR: 14, 110 | } as const; 111 | 112 | export const STATS = { 113 | HP: 1, 114 | ATTACK: 2, 115 | DEFENSE: 3, 116 | SPECIAL_ATTACK: 4, 117 | SPECIAL_DEFENSE: 5, 118 | SPEED: 6, 119 | ACCURACY: 7, 120 | EVASION: 8, 121 | } as const; 122 | 123 | export const TYPES = { 124 | NORMAL: 1, 125 | FIGHTING: 2, 126 | FLYING: 3, 127 | POISON: 4, 128 | GROUND: 5, 129 | ROCK: 6, 130 | BUG: 7, 131 | GHOST: 8, 132 | STEEL: 9, 133 | FIRE: 10, 134 | WATER: 11, 135 | GRASS: 12, 136 | ELECTRIC: 13, 137 | PSYCHIC: 14, 138 | ICE: 15, 139 | DRAGON: 16, 140 | DARK: 17, 141 | FAIRY: 18, 142 | UNKNOWN: 10_001, 143 | SHADOW: 10_002, 144 | } as const; 145 | -------------------------------------------------------------------------------- /src/constants/utilities.ts: -------------------------------------------------------------------------------- 1 | export const LANGUAGES = { 2 | JA_HRKT: 1, 3 | ROOMAJI: 2, 4 | KO: 3, 5 | ZH_HANT: 4, 6 | FR: 5, 7 | DE: 6, 8 | ES: 7, 9 | IT: 8, 10 | EN: 9, 11 | CS: 10, 12 | JA: 11, 13 | ZH_HANS: 12, 14 | PT_BR: 13, 15 | } as const; 16 | -------------------------------------------------------------------------------- /src/index.ts: -------------------------------------------------------------------------------- 1 | export * from "@models"; 2 | export * from "@clients"; 3 | export * from "@constants"; 4 | export * as CONSTANTS from "@constants"; 5 | -------------------------------------------------------------------------------- /src/models/Berry/berry.ts: -------------------------------------------------------------------------------- 1 | import type { Name, NamedAPIResource } from "../Common"; 2 | 3 | /** 4 | * ## Berry 5 | * Berries are small fruits that can provide HP and status condition restoration, 6 | * stat enhancement, and even damage negation when eaten by Pokémon. 7 | * 8 | * - Check out [Bulbapedia](https://bulbapedia.bulbagarden.net/wiki/Berry) for greater detail 9 | */ 10 | export type Berry = { 11 | /** The identifier for this resource */ 12 | id: number; 13 | /** The name for this resource */ 14 | name: string; 15 | /** Time it takes the tree to grow one stage, in hours. Berry trees go through four of these growth stages before they can be picked */ 16 | growth_time: number; 17 | /** The maximum number of these berries that can grow on one tree in Generation IV */ 18 | max_harvest: number; 19 | /** The power of the move "Natural Gift" when used with this Berry */ 20 | natural_gift_power: number; 21 | /** The size of this Berry, in millimeters */ 22 | size: number; 23 | /** The smoothness of this Berry, used in making Pokéblocks or Poffins */ 24 | smoothness: number; 25 | /** The speed at which this Berry dries out the soil as it grows. A higher rate means the soil dries more quickly */ 26 | soil_dryness: number; 27 | /** The firmness of this berry, used in making Pokéblocks or Poffins */ 28 | firmness: NamedAPIResource; 29 | /** A list of references to each flavor a berry can have and the potency of each of those flavors in regard to this berry */ 30 | flavors: BerryFlavorMap[]; 31 | /** Berries are actually items. This is a reference to the item specific data for this berry */ 32 | item: NamedAPIResource; 33 | /** The type inherited by "Natural Gift" when used with this Berry */ 34 | natural_gift_type: NamedAPIResource; 35 | }; 36 | 37 | /** 38 | * Reference to the flavor a berry can have and the potency of each of those flavors in regard to this berry 39 | */ 40 | export type BerryFlavorMap = { 41 | /** How powerful the referenced flavor is for this berry */ 42 | potency: number; 43 | /** The referenced berry flavor */ 44 | flavor: NamedAPIResource; 45 | }; 46 | 47 | /** 48 | * ## Berry Flavor 49 | * Flavors determine whether a Pokémon will benefit or suffer from eating a berry based on their nature. 50 | * 51 | * - Check out [Bulbapedia](https://bulbapedia.bulbagarden.net/wiki/Flavor) for greater detail. 52 | */ 53 | export type BerryFlavor = { 54 | /** The identifier for this resource */ 55 | id: number; 56 | /** The name for this resource */ 57 | name: "spicy" | "dry" | "sweet" | "bitter" | "sour"; 58 | /** A list of the berries with this flavor */ 59 | berries: FlavorBerryMap[]; 60 | /** The contest type that correlates with this berry flavor */ 61 | contest_type: NamedAPIResource; 62 | /** The name of this resource listed in different languages */ 63 | names: Name[]; 64 | }; 65 | 66 | /** 67 | * Berry with the given flavor 68 | */ 69 | export type FlavorBerryMap = { 70 | /** How powerful the referenced flavor is for this berry */ 71 | potency: number; 72 | /** The berry with the referenced flavor */ 73 | berry: NamedAPIResource; 74 | }; 75 | 76 | /** 77 | * ## Berry Firmness 78 | * Berries can be soft, very soft, hard, super hard or very hard. 79 | * 80 | * - Check out [Bulbapedia](https://bulbapedia.bulbagarden.net/wiki/Category:Berries_by_firmness) for greater detail 81 | */ 82 | export type BerryFirmness = { 83 | /** The identifier for this resource */ 84 | id: number; 85 | /** The name for this resource */ 86 | name: "very-soft" | "soft" | "hard" | "very-hard" | "super-hard"; 87 | /** A list of the berries with this firmness */ 88 | berries: NamedAPIResource[]; 89 | /** The name of this resource listed in different languages */ 90 | names: Name[]; 91 | }; 92 | -------------------------------------------------------------------------------- /src/models/Berry/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./berry"; 2 | -------------------------------------------------------------------------------- /src/models/Common/description.ts: -------------------------------------------------------------------------------- 1 | import type { NamedAPIResource } from "./resource"; 2 | 3 | /** 4 | * The localized description for an API resource in a specific language 5 | */ 6 | export interface Description { 7 | /** The localized description for an API resource in a specific language. */ 8 | description: string; 9 | /** The language this name is in */ 10 | language: NamedAPIResource; 11 | } 12 | -------------------------------------------------------------------------------- /src/models/Common/effect.ts: -------------------------------------------------------------------------------- 1 | import type { NamedAPIResource } from "./resource"; 2 | 3 | /** 4 | * The localized effect text for an API resource in a specific language 5 | */ 6 | export interface Effect { 7 | /** The localized effect text for an API resource in a specific language. */ 8 | effect: string; 9 | /** The language this effect is in */ 10 | language: NamedAPIResource; 11 | } 12 | -------------------------------------------------------------------------------- /src/models/Common/encounter.ts: -------------------------------------------------------------------------------- 1 | import type { NamedAPIResource } from "./resource"; 2 | 3 | /** Information of a pokemon encounter */ 4 | export interface Encounter { 5 | /** The lowest level the Pokémon could be encountered at */ 6 | min_level: number; 7 | /** The highest level the Pokémon could be encountered at */ 8 | max_level: number; 9 | /** A list of condition values that must be in effect for this encounter to occur */ 10 | condition_values: NamedAPIResource[]; 11 | /** Percent chance that this encounter will occur */ 12 | chance: number; 13 | /** The method by which this encounter happens */ 14 | method: NamedAPIResource; 15 | } 16 | -------------------------------------------------------------------------------- /src/models/Common/flavor-text.ts: -------------------------------------------------------------------------------- 1 | import type { NamedAPIResource } from "./resource"; 2 | 3 | /** 4 | * The localized flavor text for an API resource in a specific language 5 | */ 6 | export interface FlavorText { 7 | /** The localized flavor text for an API resource in a specific language */ 8 | flavor_text: string; 9 | /** The language this name is in */ 10 | language: NamedAPIResource; 11 | /** The game version this flavor text appears in */ 12 | version: NamedAPIResource; 13 | } 14 | -------------------------------------------------------------------------------- /src/models/Common/generation.ts: -------------------------------------------------------------------------------- 1 | import type { NamedAPIResource } from "./resource"; 2 | 3 | /** 4 | * The generation relevent to this game index 5 | */ 6 | export interface GenerationGameIndex { 7 | /** The internal id of an API resource within game data */ 8 | game_index: number; 9 | /** The generation relevent to this game index */ 10 | generation: NamedAPIResource; 11 | } 12 | -------------------------------------------------------------------------------- /src/models/Common/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./resource"; 2 | export * from "./language"; 3 | export * from "./name"; 4 | export * from "./description"; 5 | export * from "./effect"; 6 | export * from "./encounter"; 7 | export * from "./flavor-text"; 8 | export * from "./generation"; 9 | export * from "./machine"; 10 | export * from "./verbose"; 11 | export * from "./version"; 12 | -------------------------------------------------------------------------------- /src/models/Common/language.ts: -------------------------------------------------------------------------------- 1 | import type { Name } from "./name"; 2 | 3 | /** 4 | * Languages for translations of API resource information 5 | */ 6 | export interface Language { 7 | /** The identifier for this resource */ 8 | id: number; 9 | /** The name for this resource */ 10 | name: string; 11 | /** Whether or not the games are published in this language */ 12 | official: boolean; 13 | /** The two-letter code of the country where this language is spoken. Note that it is not unique */ 14 | iso639: string; 15 | /** The two-letter code of the language. Note that it is not unique */ 16 | iso3166: string; 17 | /** The name of this resource listed in different languages */ 18 | names: Name[]; 19 | } 20 | -------------------------------------------------------------------------------- /src/models/Common/machine.ts: -------------------------------------------------------------------------------- 1 | import type { APIResource, NamedAPIResource } from "./resource"; 2 | 3 | /** 4 | * The machine that teaches a move from an item 5 | */ 6 | export interface MachineVersionDetail { 7 | /** The machine that teaches a move from an item */ 8 | machine: APIResource; 9 | /** The version group of this specific machine */ 10 | version_group: NamedAPIResource; 11 | } 12 | -------------------------------------------------------------------------------- /src/models/Common/name.ts: -------------------------------------------------------------------------------- 1 | import type { NamedAPIResource } from "./resource"; 2 | 3 | /** 4 | * The localized name for an API resource in a specific language 5 | */ 6 | export interface Name { 7 | /** The localized name for an API resource in a specific language */ 8 | name: string; 9 | /** The language this name is in */ 10 | language: NamedAPIResource; 11 | } 12 | -------------------------------------------------------------------------------- /src/models/Common/resource.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * The name and the URL of the referenced resource 3 | */ 4 | export interface NamedAPIResource { 5 | /** The name of the referenced resource */ 6 | name: string; 7 | /** The URL of the referenced resource */ 8 | url: string; 9 | } 10 | 11 | /** 12 | * Calling any API endpoint without a resource ID or name will return a paginated list of available resources for that API. 13 | * By default, a list "page" will contain up to 20 resources. If you would like to change this just add a 'limit' query parameter 14 | * to the GET request, e.g. ?=60. You can use 'offset' to move to the next page, e.g. ?limit=60&offset=60 15 | */ 16 | export interface NamedAPIResourceList { 17 | /** The total number of resources available from this API */ 18 | count: number; 19 | /** The URL for the next page in the list */ 20 | next: string | null; 21 | /** The URL for the previous page in the list */ 22 | previous: string | null; 23 | /** A list of named API resources */ 24 | results: NamedAPIResource[]; 25 | } 26 | 27 | /** An URL for another resource in the API */ 28 | export interface APIResource { 29 | /** The URL of the referenced resource */ 30 | url: string; 31 | } 32 | -------------------------------------------------------------------------------- /src/models/Common/verbose.ts: -------------------------------------------------------------------------------- 1 | import type { NamedAPIResource } from "./resource"; 2 | 3 | /** 4 | * The localized effect for an API resource 5 | */ 6 | export interface VerboseEffect { 7 | /** The localized effect text for an API resource in a specific language */ 8 | effect: string; 9 | /** The localized effect text in brief */ 10 | short_effect: string; 11 | /** The language this effect is in */ 12 | language: NamedAPIResource; 13 | } 14 | -------------------------------------------------------------------------------- /src/models/Common/version.ts: -------------------------------------------------------------------------------- 1 | import type { Encounter } from "./encounter"; 2 | import type { NamedAPIResource } from "./resource"; 3 | 4 | /** 5 | * Encounters and their specifics details 6 | */ 7 | export interface VersionEncounterDetail { 8 | /** The game version this encounter happens in */ 9 | version: NamedAPIResource; 10 | /** The total percentage of all encounter potential */ 11 | max_chance: number; 12 | /** A list of encounters and their specifics */ 13 | encounter_details: Encounter[]; 14 | } 15 | 16 | /** 17 | * The internal id and version of an API resource 18 | */ 19 | export interface VersionGameIndex { 20 | /** The internal id of an API resource within game data */ 21 | game_index: number; 22 | /** The version relevent to this game index */ 23 | version: NamedAPIResource; 24 | } 25 | 26 | /** 27 | * The flavor text of an API resource 28 | */ 29 | export interface VersionGroupFlavorText { 30 | /** The localized name for an API resource in a specific language */ 31 | text: string; 32 | /** The language this name is in */ 33 | language: NamedAPIResource; 34 | /** The version group which uses this flavor text */ 35 | version_group: NamedAPIResource; 36 | } 37 | -------------------------------------------------------------------------------- /src/models/Contest/contest.ts: -------------------------------------------------------------------------------- 1 | import type { Effect, FlavorText, NamedAPIResource } from "../Common"; 2 | 3 | /** 4 | * ## Contest Type 5 | * Contest types are categories judges used to weigh a Pokémon's condition in Pokémon contests. 6 | * - Check out [Bulbapedia](https://bulbapedia.bulbagarden.net/wiki/Contest_condition) for greater detail 7 | */ 8 | export interface ContestType { 9 | /** The identifier for this resource */ 10 | id: number; 11 | /** The name for this resource */ 12 | name: "cool" | "beauty" | "cute" | "smart" | "tough"; 13 | /** The berry flavor that correlates with this contest type */ 14 | berry_flavor: NamedAPIResource; 15 | /** The name of this contest type listed in different languages */ 16 | names: ContestName[]; 17 | } 18 | 19 | /** 20 | * The name of the given contest type 21 | */ 22 | export interface ContestName { 23 | /** The name for this contest */ 24 | name: string; 25 | /** The color associated with this contest's name */ 26 | color: string; 27 | /** The language that this name is in */ 28 | language: NamedAPIResource; 29 | } 30 | 31 | /** 32 | * ## Contest Effect 33 | * Contest effects refer to the effects of moves when used in contests 34 | */ 35 | export interface ContestEffect { 36 | /** The identifier for this resource */ 37 | id: number; 38 | /** The base number of hearts the user of this move gets */ 39 | appeal: number; 40 | /** The base number of hearts the user's opponent loses */ 41 | jam: number; 42 | /** The result of this contest effect listed in different languages */ 43 | effect_entries: Effect[]; 44 | /** The flavor text of this contest effect listed in different languages */ 45 | flavor_text_entries: FlavorText[]; 46 | } 47 | 48 | /** 49 | * ## Super Contest Effect 50 | * Super contest effects refer to the effects of moves when used in super contests. 51 | * A Pokémon Super Contest is an expanded format of the [Pokémon Contests](https://bulbapedia.bulbagarden.net/wiki/Pok%C3%A9mon_Contest) 52 | * for the Generation IV games, 53 | * specifically in [Diamond, Pearl](https://bulbapedia.bulbagarden.net/wiki/Pok%C3%A9mon_Diamond_and_Pearl_Versions), 54 | * and [Platinum](https://bulbapedia.bulbagarden.net/wiki/Pok%C3%A9mon_Platinum_Version). 55 | * In it, Pokémon are rated on their appearance and performance, rather than strength. 56 | * - Check out [Bulbapedia](https://bulbapedia.bulbagarden.net/wiki/Pok%C3%A9mon_Super_Contest) 57 | */ 58 | export interface SuperContestEffect { 59 | /** The identifier for this resource */ 60 | id: number; 61 | /** The level of appeal this super contest effect has */ 62 | appeal: number; 63 | /** The flavor text of this super contest effect listed in different languages */ 64 | flavor_text_entries: FlavorText[]; 65 | /** A list of moves that have the effect when used in super contests */ 66 | moves: NamedAPIResource[]; 67 | } 68 | -------------------------------------------------------------------------------- /src/models/Contest/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./contest"; 2 | -------------------------------------------------------------------------------- /src/models/Encounter/encounter.ts: -------------------------------------------------------------------------------- 1 | import type { Name, NamedAPIResource } from "../Common"; 2 | 3 | /** 4 | * ## Encounter Method 5 | * Methods by which the player might can encounter Pokémon in the wild, e.g., walking in tall grass. 6 | * - Check out [Bulbapedia](https://bulbapedia.bulbagarden.net/wiki/Wild_Pok%C3%A9mon) for greater detail. 7 | */ 8 | export interface EncounterMethod { 9 | /** The identifier for this resource */ 10 | id: number; 11 | /** The name for this resource */ 12 | name: string; 13 | /** A good value for sorting */ 14 | order: number; 15 | /** The name of this resource listed in different languages */ 16 | names: Name[]; 17 | } 18 | 19 | /** 20 | * ## Encounter Condition 21 | * Conditions which affect what pokemon might appear in the wild, e.g., day or night. 22 | * - Check out [Bulbapedia](https://bulbapedia.bulbagarden.net/wiki/Time) 23 | */ 24 | export interface EncounterCondition { 25 | /** The identifier for this resource */ 26 | id: number; 27 | /** The name for this resource */ 28 | name: string; 29 | /** The name of this resource listed in different languages */ 30 | names: Name[]; 31 | /** A list of possible values for this encounter condition */ 32 | values: NamedAPIResource[]; 33 | } 34 | 35 | /** 36 | * ## Encounter Condition Value 37 | * Encounter condition values are the various states that an encounter 38 | * condition can have, i.e., time of day can be either **day** or **night** 39 | * - Check out [Bulbapedia](https://bulbapedia.bulbagarden.net/wiki/Time) 40 | */ 41 | export interface EncounterConditionValue { 42 | /** The identifier for this resource */ 43 | id: number; 44 | /** The name for this resource */ 45 | name: string; 46 | /** The condition this encounter condition value pertains to */ 47 | condition: NamedAPIResource; 48 | /** The name of this resource listed in different languages */ 49 | names: Name[]; 50 | } 51 | -------------------------------------------------------------------------------- /src/models/Encounter/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./encounter"; 2 | -------------------------------------------------------------------------------- /src/models/Evolution/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./evolution"; 2 | -------------------------------------------------------------------------------- /src/models/Game/generation.ts: -------------------------------------------------------------------------------- 1 | import type { Name, NamedAPIResource } from "../Common"; 2 | 3 | /** 4 | * ## Generation 5 | * A generation is a grouping of the Pokémon games that separates them based on the Pokémon they include. 6 | * In each generation, a new set of Pokémon, Moves, Abilities and Types that did not exist in the previous generation are released. 7 | * - Check out [Bulbapedia](https://bulbapedia.bulbagarden.net/wiki/Generation) for greater details. 8 | */ 9 | export interface Generation { 10 | /** The identifier for this resource */ 11 | id: number; 12 | /** The name for this resource */ 13 | name: string; 14 | /** A list of abilities that were introduced in this generation */ 15 | abilities: NamedAPIResource[]; 16 | /** The name of this resource listed in different languages */ 17 | names: Name[]; 18 | /** The main region travelled in this generation */ 19 | main_region: NamedAPIResource; 20 | /** A list of moves that were introduced in this generation */ 21 | moves: NamedAPIResource[]; 22 | /** A list of Pokémon species that were introduced in this generation */ 23 | pokemon_species: NamedAPIResource[]; 24 | /** A list of types that were introduced in this generation */ 25 | types: NamedAPIResource[]; 26 | /** A list of version groups that were introduced in this generation */ 27 | version_groups: NamedAPIResource[]; 28 | } 29 | -------------------------------------------------------------------------------- /src/models/Game/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./generation"; 2 | export * from "./pokedex"; 3 | export * from "./pokemon-entry"; 4 | export * from "./version"; 5 | -------------------------------------------------------------------------------- /src/models/Game/pokedex.ts: -------------------------------------------------------------------------------- 1 | import type { Description, Name, NamedAPIResource } from "../Common"; 2 | import type { PokemonEntry } from "./pokemon-entry"; 3 | 4 | /** 5 | * ## Pokedex 6 | * A Pokédex is a handheld electronic encyclopedia device; 7 | * one which is capable of recording and retaining information of the various Pokémon in a given region 8 | * with the exception of the national dex and some smaller dexes related to portions of a region. 9 | * - See [Bulbapedia](https://bulbapedia.bulbagarden.net/wiki/Pok%C3%A9dex) for greater detail 10 | */ 11 | export interface Pokedex { 12 | /** The identifier for this resource */ 13 | id: number; 14 | /** The name for this resource */ 15 | name: string; 16 | /** Whether or not this Pokédex originated in the main series of the video games */ 17 | is_main_series: boolean; 18 | /** The description of this resource listed in different languages */ 19 | descriptions: Description[]; 20 | /** The name of this resource listed in different languages */ 21 | names: Name[]; 22 | /** A list of Pokémon catalogued in this Pokédex and their indexes */ 23 | pokemon_entries: PokemonEntry[]; 24 | /** The region this Pokédex catalogues Pokémon for */ 25 | region: NamedAPIResource | null; 26 | /** A list of version groups this Pokédex is relevant to */ 27 | version_groups: NamedAPIResource[]; 28 | } 29 | -------------------------------------------------------------------------------- /src/models/Game/pokemon-entry.ts: -------------------------------------------------------------------------------- 1 | import type { NamedAPIResource } from "../Common"; 2 | 3 | /** 4 | * Catalogued pokémon for pokedex 5 | */ 6 | export interface PokemonEntry { 7 | /** The index of this Pokémon species entry within the Pokédex */ 8 | entry_number: number; 9 | /** The Pokémon species being encountered */ 10 | pokemon_species: NamedAPIResource; 11 | } 12 | -------------------------------------------------------------------------------- /src/models/Game/version.ts: -------------------------------------------------------------------------------- 1 | import type { Name, NamedAPIResource } from "../Common"; 2 | 3 | /** 4 | * ## Version 5 | * Versions of the games, e.g., Red, Blue or Yellow, 6 | * - Check out [Bulbapedia](https://bulbapedia.bulbagarden.net/wiki/Core_series) for greater details. 7 | */ 8 | export interface Version { 9 | /** The identifier for this resource */ 10 | id: number; 11 | /** The name for this resource */ 12 | name: string; 13 | /** The name of this resource listed in different languages */ 14 | names: Name[]; 15 | /** The version group this version belongs to */ 16 | version_group: NamedAPIResource; 17 | } 18 | 19 | /** 20 | * ## Version Group 21 | * Version groups categorize highly similar versions of the games 22 | */ 23 | export interface VersionGroup { 24 | /** The identifier for this resource */ 25 | id: number; 26 | /** The name for this resource */ 27 | name: string; 28 | /** Order for sorting. Almost by date of release, except similar versions are grouped together */ 29 | order: number; 30 | /** The generation this version was introduced in */ 31 | generation: NamedAPIResource; 32 | /** A list of methods in which Pokémon can learn moves in this version group */ 33 | move_learn_methods: NamedAPIResource[]; 34 | /** A list of Pokédexes introduces in this version group */ 35 | pokedexes: NamedAPIResource[]; 36 | /** A list of regions that can be visited in this version group */ 37 | regions: NamedAPIResource[]; 38 | /** The versions this version group owns */ 39 | versions: NamedAPIResource[]; 40 | } 41 | -------------------------------------------------------------------------------- /src/models/Item/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./item"; 2 | -------------------------------------------------------------------------------- /src/models/Location/encounter.ts: -------------------------------------------------------------------------------- 1 | import type { NamedAPIResource, VersionEncounterDetail } from "../Common"; 2 | 3 | /** 4 | * Method in which Pokémon may be encountered in the given area 5 | * and how likely the method will occur depending on the version of the game 6 | */ 7 | export interface EncounterMethodRate { 8 | /** The method in which Pokémon may be encountered in an area */ 9 | encounter_method: NamedAPIResource; 10 | /** The chance of the encounter to occur on a version of the game */ 11 | version_details: EncounterVersionDetails[]; 12 | } 13 | 14 | /** 15 | * The chance of the encounter to occur on a version of the game 16 | */ 17 | export interface EncounterVersionDetails { 18 | /** The chance of an encounter to occur */ 19 | rate: number; 20 | /** The version of the game in which the encounter can occur with the given chance */ 21 | version: NamedAPIResource; 22 | } 23 | 24 | /** 25 | * Describes a pokémon encounter in a given area 26 | */ 27 | export interface PokemonEncounter { 28 | /** The Pokémon being encountered */ 29 | pokemon: NamedAPIResource; 30 | /** A list of versions and encounters with Pokémon that might happen in the referenced location area */ 31 | version_details: VersionEncounterDetail[]; 32 | } 33 | -------------------------------------------------------------------------------- /src/models/Location/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./encounter"; 2 | export * from "./location"; 3 | export * from "./palpark"; 4 | export * from "./region"; 5 | -------------------------------------------------------------------------------- /src/models/Location/location.ts: -------------------------------------------------------------------------------- 1 | import type { GenerationGameIndex, Name, NamedAPIResource } from "../Common"; 2 | import type { EncounterMethodRate, PokemonEncounter } from "./encounter"; 3 | 4 | /** 5 | * ## Location 6 | * Locations that can be visited within the games. 7 | * Locations make up sizable portions of regions, like cities or routes. 8 | * - Check the [List of Locations](https://bulbapedia.bulbagarden.net/wiki/List_of_locations_by_name) 9 | */ 10 | export interface Location { 11 | /** The identifier for this resource */ 12 | id: number; 13 | /** The name for this resource */ 14 | name: string; 15 | /** The region this location can be found in */ 16 | region: NamedAPIResource | null; 17 | /** The name of this resource listed in different languages */ 18 | names: Name[]; 19 | /** A list of game indices relevent to this location by generation */ 20 | game_indices: GenerationGameIndex[]; 21 | /** Areas that can be found within this location */ 22 | areas: NamedAPIResource[]; 23 | } 24 | 25 | /** 26 | * ## Location Area 27 | * Location areas are sections of areas, such as floors in a building or cave. 28 | * Each area has its own set of possible Pokémon encounters. 29 | * - Check out [Bulbapedia](https://bulbapedia.bulbagarden.net/wiki/Area) for more details. 30 | */ 31 | export interface LocationArea { 32 | /** The identifier for this resource */ 33 | id: number; 34 | /** The name for this resource */ 35 | name: string; 36 | /** The internal id of an API resource within game data */ 37 | game_index: number; 38 | /** A list of methods in which Pokémon may be encountered in this area and how likely the method will occur depending on the version of the game */ 39 | encounter_method_rates: EncounterMethodRate[]; 40 | /** The region this location area can be found in */ 41 | location: NamedAPIResource; 42 | /** The name of this resource listed in different languages */ 43 | names: Name[]; 44 | /** A list of Pokémon that can be encountered in this area along with version specific details about the encounter */ 45 | pokemon_encounters: PokemonEncounter[]; 46 | } 47 | -------------------------------------------------------------------------------- /src/models/Location/palpark.ts: -------------------------------------------------------------------------------- 1 | import type { Name, NamedAPIResource } from "../Common"; 2 | 3 | /** 4 | * ## Pal Park Area 5 | * Areas used for grouping Pokémon encounters in Pal Park. 6 | * They're like habitats that are specific to Pal Park. 7 | * Pal Park is divided into five separate areas: 8 | * --- 9 | * - [Field](https://bulbapedia.bulbagarden.net/wiki/List_of_Pok%C3%A9mon_by_Pal_Park_location#Field) 10 | * - [Forest](https://bulbapedia.bulbagarden.net/wiki/List_of_Pok%C3%A9mon_by_Pal_Park_location#Forest) 11 | * - [Mountain](https://bulbapedia.bulbagarden.net/wiki/List_of_Pok%C3%A9mon_by_Pal_Park_location#Mountain) 12 | * - [Pond](https://bulbapedia.bulbagarden.net/wiki/List_of_Pok%C3%A9mon_by_Pal_Park_location#Pound) 13 | * - [Sea](https://bulbapedia.bulbagarden.net/wiki/List_of_Pok%C3%A9mon_by_Pal_Park_location#Sea) 14 | * - [Trivia](https://bulbapedia.bulbagarden.net/wiki/List_of_Pok%C3%A9mon_by_Pal_Park_location#Trivia) 15 | * --- 16 | * Check out [Bulbapedia](https://bulbapedia.bulbagarden.net/wiki/Pal_Park) for greater details. 17 | */ 18 | export interface PalParkArea { 19 | /** The identifier for this resource */ 20 | id: number; 21 | /** The name for this resource */ 22 | name: string; 23 | /** The name of this resource listed in different languages */ 24 | names: Name[]; 25 | /** A list of Pokémon encountered in thi pal park area along with details */ 26 | pokemon_encounters: PalParkEncounterSpecies[]; 27 | } 28 | 29 | /** 30 | * Detais of a Pokémon encountered in thi Pal Park area 31 | */ 32 | export interface PalParkEncounterSpecies { 33 | /** The base score given to the player when this Pokémon is caught during a pal park run */ 34 | base_score: number; 35 | /** The base rate for encountering this Pokémon in this pal park area */ 36 | rate: number; 37 | /** The Pokémon species being encountered */ 38 | pokemon_species: NamedAPIResource; 39 | } 40 | -------------------------------------------------------------------------------- /src/models/Location/region.ts: -------------------------------------------------------------------------------- 1 | import type { Name, NamedAPIResource } from "../Common"; 2 | 3 | /** 4 | * ## Region 5 | * A region is an organized area of the Pokémon world. 6 | * Most often, the main difference between regions is 7 | * the species of Pokémon that can be encountered within them. 8 | * - Check out [Bulbapedia](https://bulbapedia.bulbagarden.net/wiki/Region) for greater details. 9 | */ 10 | export type Region = { 11 | /** The identifier for this resource */ 12 | id: number; 13 | /** A list of locations that can be found in this region */ 14 | locations: NamedAPIResource[]; 15 | /** The name for this resource */ 16 | name: string; 17 | /** The name of this resource listed in different languages */ 18 | names: Name[]; 19 | /** The generation this region was introduced in */ 20 | main_generation: NamedAPIResource; 21 | /** A list of pokédexes that catalogue Pokémon in this region */ 22 | pokedexes: NamedAPIResource[]; 23 | /** A list of version groups where this region can be visited */ 24 | version_groups: NamedAPIResource[]; 25 | }; 26 | -------------------------------------------------------------------------------- /src/models/Machine/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./machine"; 2 | -------------------------------------------------------------------------------- /src/models/Machine/machine.ts: -------------------------------------------------------------------------------- 1 | import type { NamedAPIResource } from "../Common"; 2 | 3 | /** 4 | * ## Machine 5 | * Machines are the representation of items that teach moves to Pokémon. 6 | * They vary from version to version, so it is not certain that one specific 7 | * [TM (Technical Machine)](https://bulbapedia.bulbagarden.net/wiki/TM) or 8 | * [HM (Hidden Machine)](https://bulbapedia.bulbagarden.net/wiki/HM) corresponds to a single Machine. 9 | */ 10 | export type Machine = { 11 | /** The identifier for this resource */ 12 | id: number; 13 | /** The TM or HM item that corresponds to this machine */ 14 | item: NamedAPIResource; 15 | /** The move that is taught by this machine */ 16 | move: NamedAPIResource; 17 | /** The version group that this machine applies to */ 18 | version_group: NamedAPIResource; 19 | }; 20 | -------------------------------------------------------------------------------- /src/models/Moves/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./moves"; 2 | -------------------------------------------------------------------------------- /src/models/Pokemon/ability.ts: -------------------------------------------------------------------------------- 1 | import type { Effect, Name, NamedAPIResource, VerboseEffect } from "../Common"; 2 | 3 | /** 4 | * ## Ability 5 | * Abilities provide passive effects for Pokémon in battle or in the overworld. 6 | * Pokémon have multiple possible abilities but can have only one ability at a time. 7 | * - Check out [Bulbapedia](https://bulbapedia.bulbagarden.net/wiki/Ability) for greater detail. 8 | */ 9 | export interface Ability { 10 | /** The identifier for this resource */ 11 | id: number; 12 | /** The name for this resource */ 13 | name: string; 14 | /** Whether or not this ability originated in the main series of the video games */ 15 | is_main_series: boolean; 16 | /** The generation this ability originated in */ 17 | generation: NamedAPIResource; 18 | /** The name of this resource listed in different languages */ 19 | names: Name[]; 20 | /** The effect of this ability listed in different languages */ 21 | effect_entries: VerboseEffect[]; 22 | /** The list of previous effects this ability has had across version groups */ 23 | effect_changes: AbilityEffectChange[]; 24 | /** The flavor text of this ability listed in different languages */ 25 | flavor_text_entries: AbilityFlavorText[]; 26 | /** A list of Pokémon that could potentially have this ability */ 27 | pokemon: AbilityPokemon[]; 28 | } 29 | 30 | /** 31 | * Previous effects an ability has had across version groups 32 | */ 33 | export interface AbilityEffectChange { 34 | /** The previous effect of this ability listed in different languages */ 35 | effect_entries: Effect[]; 36 | /** The version group in which the previous effect of this ability originated */ 37 | version_group: NamedAPIResource; 38 | } 39 | 40 | /** 41 | * The flavor text of an ability 42 | */ 43 | export interface AbilityFlavorText { 44 | /** The localized name for an API resource in a specific language */ 45 | flavor_text: string; 46 | /** The language this text resource is in */ 47 | language: NamedAPIResource; 48 | /** The version group that uses this flavor text */ 49 | version_group: NamedAPIResource; 50 | } 51 | 52 | /** 53 | * Pokémon that could potentially have the given ability 54 | */ 55 | export interface AbilityPokemon { 56 | /** Whether or not this a hidden ability for the referenced Pokémon */ 57 | is_hidden: boolean; 58 | /** 59 | * Pokémon have 3 ability 'slots' which hold references to possible abilities they could have. 60 | * This is the slot of this ability for the referenced pokemon 61 | */ 62 | slot: number; 63 | /** The Pokémon this ability could belong to */ 64 | pokemon: NamedAPIResource; 65 | } 66 | -------------------------------------------------------------------------------- /src/models/Pokemon/characteristics.ts: -------------------------------------------------------------------------------- 1 | import type { Description, NamedAPIResource } from "../Common"; 2 | 3 | /** 4 | * ## Characteristic 5 | * Characteristics indicate which stat contains a Pokémon's highest IV. 6 | * A Pokémon's Characteristic is determined by the remainder of its highest IV divided by 5 (gene_modulo). 7 | * - Check out [Bulbapedia](https://bulbapedia.bulbagarden.net/wiki/Characteristic) for greater detail 8 | */ 9 | export interface Characteristic { 10 | /** The identifier for this resource */ 11 | id: number; 12 | /** The remainder of the highest stat/IV divided by 5 */ 13 | gene_modulo: number; 14 | /** The possible values of the highest stat that would result in a Pokémon recieving this characteristic when divided by 5 */ 15 | possible_values: number[]; 16 | /** The highest stat for the referenced characteristic */ 17 | highest_stat: NamedAPIResource; 18 | /** Descriptions for the referenced characteristic */ 19 | descriptions: Description[]; 20 | } 21 | -------------------------------------------------------------------------------- /src/models/Pokemon/egg-group.ts: -------------------------------------------------------------------------------- 1 | import type { Name, NamedAPIResource } from "../Common"; 2 | 3 | /** 4 | * ## Egg Group 5 | * Egg Groups are categories which determine which Pokémon are able to interbreed. 6 | * Pokémon may belong to either one or two Egg Groups. 7 | * - Check out [Bulbapedia](https://bulbapedia.bulbagarden.net/wiki/Egg_Group) for greater details. 8 | */ 9 | export interface EggGroup { 10 | /** The identifier for this resource */ 11 | id: number; 12 | /** The name for this resource */ 13 | name: 14 | | "monster" 15 | | "water1" 16 | | "water2" 17 | | "water3" 18 | | "bug" 19 | | "flying" 20 | | "ground" 21 | | "fairy" 22 | | "plant" 23 | | "humanshape" 24 | | "mineral" 25 | | "indeterminate" 26 | | "ditto" 27 | | "dragon" 28 | | "no-eggs"; 29 | /** The name of this resource listed in different languages */ 30 | names: Name[]; 31 | /** A list of all Pokémon species that are members of this egg group */ 32 | pokemon_species: NamedAPIResource[]; 33 | } 34 | -------------------------------------------------------------------------------- /src/models/Pokemon/gender.ts: -------------------------------------------------------------------------------- 1 | import type { NamedAPIResource } from "../Common"; 2 | 3 | /** 4 | * ## Gender 5 | * Genders were introduced in Generation II for the purposes of breeding Pokémon 6 | * but can also result in visual differences or even different evolutionary lines. 7 | * - Check out [Bulbapedia](https://bulbapedia.bulbagarden.net/wiki/Gender) for greater details. 8 | */ 9 | export interface Gender { 10 | /** The identifier for this resource */ 11 | id: number; 12 | /** The name for this resource */ 13 | name: "male" | "female" | "genderless"; 14 | /** A list of Pokémon species that can be this gender and how likely it is that they will be */ 15 | pokemon_species_details: PokemonSpeciesGender[]; 16 | /** A list of Pokémon species that required this gender in order for a Pokémon to evolve into them */ 17 | required_for_evolution: NamedAPIResource[]; 18 | } 19 | 20 | /** 21 | * Pokémon species that can be this gender and how likely it is that they will be 22 | */ 23 | export interface PokemonSpeciesGender { 24 | /** The chance of this Pokémon being female, in eighths; or -1 for genderless */ 25 | rate: number; 26 | /** A Pokémon species that can be the referenced gender */ 27 | pokemon_species: NamedAPIResource; 28 | } 29 | -------------------------------------------------------------------------------- /src/models/Pokemon/growth-rates.ts: -------------------------------------------------------------------------------- 1 | import type { Description, NamedAPIResource } from "../Common"; 2 | 3 | /** 4 | * Levels and the amount of experienced needed to atain them based on the given growth rate. 5 | */ 6 | export interface GrowthRateExperienceLevel { 7 | /** The level gained. */ 8 | level: number; 9 | /** The amount of experience required to reach the referenced level. */ 10 | experience: number; 11 | } 12 | 13 | /** 14 | * ## Growth Rate 15 | * Growth rates are the speed with which Pokémon gain levels through experience. 16 | * - Check out [Bulbapedia](https://bulbapedia.bulbagarden.net/wiki/Experience) for greater details. 17 | */ 18 | export interface GrowthRate { 19 | /** The identifier for this resource */ 20 | id: number; 21 | /** The name for this resource */ 22 | name: "slow" | "medium" | "fast" | "medium-slow" | "slow-then-very-fast" | "fast-then-very-slow"; 23 | /** The formula used to calculate the rate at which the Pokémon species gains level */ 24 | formula: string; 25 | /** The descriptions of this characteristic listed in different languages */ 26 | descriptions: Description[]; 27 | /** A list of levels and the amount of experienced needed to atain them based on this growth rate. */ 28 | levels: GrowthRateExperienceLevel[]; 29 | /** A list of Pokémon species that gain levels at this growth rate */ 30 | pokemon_species: NamedAPIResource[]; 31 | } 32 | -------------------------------------------------------------------------------- /src/models/Pokemon/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./ability"; 2 | export * from "./characteristics"; 3 | export * from "./egg-group"; 4 | export * from "./gender"; 5 | export * from "./growth-rates"; 6 | export * from "./nature"; 7 | export * from "./pokeathlon-stat"; 8 | export * from "./stats"; 9 | export * from "./type"; 10 | export * from "./pokemon"; 11 | -------------------------------------------------------------------------------- /src/models/Pokemon/nature.ts: -------------------------------------------------------------------------------- 1 | import type { Name, NamedAPIResource } from "../Common"; 2 | 3 | /** 4 | * ## Nature 5 | * Natures influence how a Pokémon's stats grow. 6 | * - See [Bulbapedia](https://bulbapedia.bulbagarden.net/wiki/Nature) for greater detail 7 | */ 8 | export interface Nature { 9 | /** The identifier for this resource */ 10 | id: number; 11 | /** The name for this resource */ 12 | name: string; 13 | /** The stat decreased by 10% in Pokémon with this nature */ 14 | decreased_stat: NamedAPIResource | null; 15 | /** The stat increased by 10% in Pokémon with this nature */ 16 | increased_stat: NamedAPIResource | null; 17 | /** The flavor hated by Pokémon with this nature */ 18 | hates_flavor: NamedAPIResource | null; 19 | /** The flavor liked by Pokémon with this nature */ 20 | likes_flavor: NamedAPIResource | null; 21 | /** A list of Pokéathlon stats this nature effects and how much it effects them */ 22 | pokeathlon_stat_changes: NatureStatChange[]; 23 | /** A list of battle styles and how likely a Pokémon with this nature is to use them in the Battle Palace or Battle Tent */ 24 | move_battle_style_preferences: MoveBattleStylePreference[]; 25 | /** The name of this resource listed in different languages */ 26 | names: Name[]; 27 | } 28 | 29 | /** 30 | * Pokéathlon stats a nature effects and how much it effects it 31 | */ 32 | export interface NatureStatChange { 33 | /** The amount of change */ 34 | max_change: -1 | 1 | -2 | 2; 35 | /** The stat being affected */ 36 | pokeathlon_stat: NamedAPIResource; 37 | } 38 | 39 | /** 40 | * Battle Style and how likely a Pokémon with the given nature is to use them 41 | * in the Battle Palace or Battle Tent 42 | */ 43 | export interface MoveBattleStylePreference { 44 | /** Chance of using the move, in percent, if HP is under one half */ 45 | low_hp_preference: number; 46 | /** Chance of using the move, in percent, if HP is over one half */ 47 | high_hp_preference: number; 48 | /** The move battle style */ 49 | move_battle_style: NamedAPIResource; 50 | } 51 | -------------------------------------------------------------------------------- /src/models/Pokemon/pokeathlon-stat.ts: -------------------------------------------------------------------------------- 1 | import type { Name, NamedAPIResource } from "../Common"; 2 | 3 | /** 4 | * ## Pokeathlon Stat 5 | * Pokeathlon Stats are different attributes of a Pokémon's performance in Pokéathlons. 6 | * In Pokéathlons, competitions happen on different courses; one for each of the different Pokéathlon stats. 7 | * - See [Bulbapedia](https://bulbapedia.bulbagarden.net/wiki/Pok%C3%A9athlon) for greater details. 8 | */ 9 | export interface PokeathlonStat { 10 | /** The identifier for this resource */ 11 | id: number; 12 | /** The name for this resource */ 13 | name: "speed" | "power" | "skill" | "stamina" | "jump"; 14 | /** The name of this resource listed in different languages */ 15 | names: Name[]; 16 | /** A detail of natures which affect this Pokéathlon stat positively or negatively */ 17 | affecting_natures: NaturePokeathlonStatAffectSets; 18 | } 19 | 20 | /** 21 | * A nature and how it change the referenced Pokéathlon stat 22 | */ 23 | export interface NaturePokeathlonStatAffect { 24 | /** The maximum amount of change to the referenced Pokéathlon stat. */ 25 | max_change: -1 | -2 | 1 | 2; 26 | /** The nature causing the change */ 27 | nature: NamedAPIResource; 28 | } 29 | 30 | /** 31 | * A detail of natures which affect this Pokéathlon stat positively or negatively 32 | */ 33 | export interface NaturePokeathlonStatAffectSets { 34 | /** A list of natures and how they change the referenced Pokéathlon stat */ 35 | increase: NaturePokeathlonStatAffect[]; 36 | /** A list of natures and how they change the referenced Pokéathlon stat */ 37 | decrease: NaturePokeathlonStatAffect[]; 38 | } 39 | -------------------------------------------------------------------------------- /src/models/Pokemon/stats.ts: -------------------------------------------------------------------------------- 1 | import type { APIResource, Name, NamedAPIResource } from "../Common"; 2 | 3 | /** 4 | * ## Stat 5 | * Stats determine certain aspects of battles. Each Pokémon has a value for each stat 6 | * which grows as they gain levels and can be altered momentarily by effects in battles 7 | */ 8 | export interface Stat { 9 | /** The identifier for this resource */ 10 | id: number; 11 | /** The name for this resource */ 12 | name: 13 | | "hp" 14 | | "attack" 15 | | "defense" 16 | | "special-attack" 17 | | "special-defense" 18 | | "speed" 19 | | "accuracy" 20 | | "evasion"; 21 | /** ID the games use for this stat */ 22 | game_index: number; 23 | /** Whether this stat only exists within a battle */ 24 | is_battle_only: boolean; 25 | /** A detail of moves which affect this stat positively or negatively */ 26 | affecting_moves: MoveStatAffectSets; 27 | /** A detail of natures which affect this stat positively or negatively */ 28 | affecting_natures: NatureStatAffectSets; 29 | /** A list of characteristics that are set on a Pokémon when its highest base stat is this stat */ 30 | characteristics: APIResource[]; 31 | /** The class of damage this stat is directly related to */ 32 | move_damage_class: NamedAPIResource | null; 33 | /** The name of this resource listed in different languages */ 34 | names: Name[]; 35 | } 36 | 37 | /** 38 | * A detail of nature which affect the given stat stat positively or negatively 39 | */ 40 | export interface NatureStatAffectSets { 41 | /** A list of natures and how they change the referenced stat */ 42 | increase: NamedAPIResource[]; 43 | /** A list of nature sand how they change the referenced stat */ 44 | decrease: NamedAPIResource[]; 45 | } 46 | /** 47 | * Move and how it change the referenced stat 48 | */ 49 | export interface MoveStatAffect { 50 | /** The maximum amount of change to the referenced stat */ 51 | change: -1 | -2 | 1 | 2; 52 | /** The move causing the change */ 53 | move: NamedAPIResource; 54 | } 55 | 56 | /** 57 | * A detail of moves which affect an stat positively or negatively 58 | */ 59 | export interface MoveStatAffectSets { 60 | /** A list of moves and how they change the referenced stat */ 61 | increase: MoveStatAffect[]; 62 | /** A list of moves and how they change the referenced stat */ 63 | decrease: MoveStatAffect[]; 64 | } 65 | -------------------------------------------------------------------------------- /src/models/Pokemon/type.ts: -------------------------------------------------------------------------------- 1 | import type { GenerationGameIndex, Name, NamedAPIResource } from "../Common"; 2 | 3 | /** 4 | * Details of Pokémon for a specific type. 5 | */ 6 | export interface TypePokemon { 7 | /** The order the Pokémon's types are listed in */ 8 | slot: number; 9 | /** The Pokémon that has the referenced type */ 10 | pokemon: NamedAPIResource; 11 | } 12 | 13 | /** 14 | * Detail of how effective a type is toward others and vice versa 15 | */ 16 | export interface TypeRelations { 17 | /** A list of types this type has no effect on */ 18 | no_damage_to: NamedAPIResource[]; 19 | /** A list of types this type is not very effect against */ 20 | half_damage_to: NamedAPIResource[]; 21 | /** A list of types this type is very effect against */ 22 | double_damage_to: NamedAPIResource[]; 23 | /** A list of types that have no effect on this type */ 24 | no_damage_from: NamedAPIResource[]; 25 | /** A list of types that are not very effective against this type */ 26 | half_damage_from: NamedAPIResource[]; 27 | /** A list of types that are very effective against this type */ 28 | double_damage_from: NamedAPIResource[]; 29 | } 30 | 31 | /** 32 | * Details of how effective this type was toward others and vice versa in a previous generation 33 | */ 34 | export interface TypeRelationsPast { 35 | /** The last generation in which the referenced type had the listed damage relations */ 36 | generation: NamedAPIResource; 37 | /** The damage relations the referenced type had up to and including the listed generation */ 38 | damage_relations: TypeRelations; 39 | } 40 | 41 | /** 42 | * ## Type 43 | * Types are properties for Pokémon and their moves. 44 | * Each type has three properties: which types of Pokémon it is super effective against, 45 | * which types of Pokémon it is not very effective against, and which types of Pokémon it is completely ineffective against 46 | */ 47 | export interface Type { 48 | /** The identifier for this resource */ 49 | id: number; 50 | /** The name for this resource */ 51 | name: string; 52 | /** A detail of how effective this type is toward others and vice versa */ 53 | damage_relations: TypeRelations; 54 | /** A list of details of how effective this type was toward others and vice versa in previous generations */ 55 | past_damage_relations: TypeRelationsPast[]; 56 | /** A list of game indices relevent to this item by generation */ 57 | game_indices: GenerationGameIndex[]; 58 | /** The generation this type was introduced in */ 59 | generation: NamedAPIResource; 60 | /** The class of damage inflicted by this type */ 61 | move_damage_class: NamedAPIResource; 62 | /** The name of this resource listed in different languages */ 63 | names: Name[]; 64 | /** A list of details of Pokémon that have this type */ 65 | pokemon: TypePokemon[]; 66 | /** A list of moves that have this type */ 67 | moves: NamedAPIResource[]; 68 | } 69 | -------------------------------------------------------------------------------- /src/models/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./Berry"; 2 | export * from "./Common"; 3 | export * from "./Contest"; 4 | export * from "./Encounter"; 5 | export * from "./Evolution"; 6 | export * from "./Game"; 7 | export * from "./Item"; 8 | export * from "./Location"; 9 | export * from "./Machine"; 10 | export * from "./Moves"; 11 | export * from "./Pokemon"; 12 | -------------------------------------------------------------------------------- /tests/berry/berry.spec.ts: -------------------------------------------------------------------------------- 1 | import { BerryClient } from "@clients"; 2 | import { BERRIES, BERRY_FIRMNESSES, BERRY_FLAVORS } from "@constants"; 3 | import { 4 | MOCK_BERRY, 5 | MOCK_BERRY_FIRMNESS, 6 | MOCK_BERRY_FIRMNESS_LIST, 7 | MOCK_BERRY_FLAVOR, 8 | MOCK_BERRY_FLAVOR_LIST, 9 | MOCK_BERRY_LIST, 10 | } from "./mocks/data"; 11 | 12 | describe("Berry Client", () => { 13 | let client: BerryClient; 14 | 15 | beforeAll(() => { 16 | client = new BerryClient(); 17 | }); 18 | 19 | // Client 20 | it("should be instantiated correctly", () => expect(client).toBeDefined()); 21 | 22 | it("should fetch a berry by ID/Name and return the correct data", async () => { 23 | await expect(client.getBerryByName("cheri")).resolves.toEqual(MOCK_BERRY); 24 | await expect(client.getBerryById(BERRIES.CHERI)).resolves.toEqual(MOCK_BERRY); 25 | }); 26 | 27 | it("should fetch a list of berries and return valid results", async () => { 28 | await expect(client.listBerries()).resolves.toEqual(MOCK_BERRY_LIST); 29 | }); 30 | 31 | // Berry Firmness Tests 32 | it("should fetch a berry firmness by name and return the correct data", async () => { 33 | await expect(client.getBerryFirmnessById(BERRY_FIRMNESSES.VERY_SOFT)).resolves.toEqual( 34 | MOCK_BERRY_FIRMNESS, 35 | ); 36 | await expect(client.getBerryFirmnessByName("very-soft")).resolves.toEqual(MOCK_BERRY_FIRMNESS); 37 | }); 38 | 39 | it("should fetch a list of berry firmnesses and return valid results", async () => { 40 | await expect(client.listBerryFirmnesses()).resolves.toEqual(MOCK_BERRY_FIRMNESS_LIST); 41 | }); 42 | 43 | // Berry Flavor Tests 44 | it("should fetch a berry flavor by name and return the correct data", async () => { 45 | await expect(client.getBerryFlavorById(BERRY_FLAVORS.SPICY)).resolves.toEqual( 46 | MOCK_BERRY_FLAVOR, 47 | ); 48 | await expect(client.getBerryFlavorByName("spicy")).resolves.toEqual(MOCK_BERRY_FLAVOR); 49 | }); 50 | 51 | it("should fetch a list of berry flavors and return valid results", async () => { 52 | await expect(client.listBerryFlavors()).resolves.toEqual(MOCK_BERRY_FLAVOR_LIST); 53 | }); 54 | 55 | // Berry - Edge Cases and Errors 56 | it("should handle fetching a non-existing berry by name with an error", async () => { 57 | await expect(client.getBerryByName("nonexistentberry")).rejects.toThrow(); 58 | }); 59 | 60 | it("should handle fetching a non-existing berry by negative ID with an error", async () => { 61 | await expect(client.getBerryById(-1)).rejects.toThrow(); 62 | }); 63 | 64 | // Berry Firmness - Edge Cases and Errors 65 | it("should handle fetching a non-existing berry firmness by name with an error", async () => { 66 | await expect(client.getBerryFirmnessByName("nonexistentfirmness")).rejects.toThrow(); 67 | }); 68 | 69 | it("should handle fetching a non-existing berry firmness by negative ID with an error", async () => { 70 | await expect(client.getBerryFirmnessById(-1)).rejects.toThrow(); 71 | }); 72 | 73 | // Berry Flavor - Edge Cases and Errors 74 | it("should handle fetching a non-existing berry flavor by name with an error", async () => { 75 | await expect(client.getBerryFlavorByName("nonexistentflavor")).rejects.toThrow(); 76 | }); 77 | 78 | it("should handle fetching a non-existing berry flavor by negative ID with an error", async () => { 79 | await expect(client.getBerryFlavorById(-1)).rejects.toThrow(); 80 | }); 81 | 82 | // Common Error Scenarios 83 | it("should handle API errors while fetching a berry with an error", async () => { 84 | await expect(client.getBerryByName("errorberry")).rejects.toThrow(); 85 | }); 86 | 87 | it("should handle API errors while fetching berry firmness with an error", async () => { 88 | await expect(client.getBerryFirmnessById(999)).rejects.toThrow(); 89 | }); 90 | 91 | it("should handle API errors while fetching berry flavors with an error", async () => { 92 | await expect(client.getBerryFlavorByName("errorflavor")).rejects.toThrow(); 93 | }); 94 | }); 95 | -------------------------------------------------------------------------------- /tests/berry/berry.test-d.ts: -------------------------------------------------------------------------------- 1 | import { BerryClient } from "@clients"; 2 | 3 | describe("Berry", () => { 4 | let client: BerryClient; 5 | 6 | beforeAll(() => { 7 | client = new BerryClient(); 8 | }); 9 | 10 | it("should be instantiated correctly", () => { 11 | expectTypeOf(client).toEqualTypeOf(); 12 | expectTypeOf(BerryClient).toBeConstructibleWith({}); 13 | expectTypeOf(BerryClient).toBeConstructibleWith({ logs: true }); 14 | }); 15 | }); 16 | -------------------------------------------------------------------------------- /tests/berry/mocks/data.ts: -------------------------------------------------------------------------------- 1 | import type { Berry, BerryFirmness, BerryFlavor, NamedAPIResourceList } from "@models"; 2 | 3 | export const MOCK_BERRY = { 4 | firmness: { 5 | name: "soft", 6 | url: "https://pokeapi.co/api/v2/berry-firmness/2/", 7 | }, 8 | flavors: [ 9 | { 10 | flavor: { 11 | name: "spicy", 12 | url: "https://pokeapi.co/api/v2/berry-flavor/1/", 13 | }, 14 | potency: 10, 15 | }, 16 | ], 17 | growth_time: 3, 18 | id: 1, 19 | item: { 20 | name: "cheri-berry", 21 | url: "https://pokeapi.co/api/v2/item/126/", 22 | }, 23 | max_harvest: 5, 24 | name: "cheri", 25 | natural_gift_power: 60, 26 | natural_gift_type: { 27 | name: "fire", 28 | url: "https://pokeapi.co/api/v2/type/10/", 29 | }, 30 | size: 20, 31 | smoothness: 25, 32 | soil_dryness: 15, 33 | } as Berry; 34 | 35 | export const MOCK_BERRY_LIST = { 36 | count: 64, 37 | next: "https://pokeapi.co/api/v2/berry?offset=20&limit=20", 38 | previous: null, 39 | results: [ 40 | { 41 | name: "cheri", 42 | url: "https://pokeapi.co/api/v2/berry/1/", 43 | }, 44 | ], 45 | } as NamedAPIResourceList; 46 | 47 | export const MOCK_BERRY_FIRMNESS = { 48 | berries: [ 49 | { 50 | name: "pecha", 51 | url: "https://pokeapi.co/api/v2/berry/3/", 52 | }, 53 | ], 54 | id: 1, 55 | name: "very-soft", 56 | names: [ 57 | { 58 | language: { 59 | name: "ja-Hrkt", 60 | url: "https://pokeapi.co/api/v2/language/1/", 61 | }, 62 | name: "とてもやわらかい", 63 | }, 64 | ], 65 | } as BerryFirmness; 66 | 67 | export const MOCK_BERRY_FIRMNESS_LIST = { 68 | count: 5, 69 | next: null, 70 | previous: null, 71 | results: [ 72 | { 73 | name: "very-soft", 74 | url: "https://pokeapi.co/api/v2/berry-firmness/1/", 75 | }, 76 | { 77 | name: "soft", 78 | url: "https://pokeapi.co/api/v2/berry-firmness/2/", 79 | }, 80 | { 81 | name: "hard", 82 | url: "https://pokeapi.co/api/v2/berry-firmness/3/", 83 | }, 84 | { 85 | name: "very-hard", 86 | url: "https://pokeapi.co/api/v2/berry-firmness/4/", 87 | }, 88 | { 89 | name: "super-hard", 90 | url: "https://pokeapi.co/api/v2/berry-firmness/5/", 91 | }, 92 | ], 93 | } as NamedAPIResourceList; 94 | 95 | export const MOCK_BERRY_FLAVOR = { 96 | berries: [ 97 | { 98 | berry: { 99 | name: "rowap", 100 | url: "https://pokeapi.co/api/v2/berry/64/", 101 | }, 102 | potency: 10, 103 | }, 104 | ], 105 | contest_type: { 106 | name: "cool", 107 | url: "https://pokeapi.co/api/v2/contest-type/1/", 108 | }, 109 | id: 1, 110 | name: "spicy", 111 | names: [ 112 | { 113 | language: { 114 | name: "ja-Hrkt", 115 | url: "https://pokeapi.co/api/v2/language/1/", 116 | }, 117 | name: "からい", 118 | }, 119 | ], 120 | } as BerryFlavor; 121 | 122 | export const MOCK_BERRY_FLAVOR_LIST = { 123 | count: 5, 124 | next: null, 125 | previous: null, 126 | results: [ 127 | { 128 | name: "spicy", 129 | url: "https://pokeapi.co/api/v2/berry-flavor/1/", 130 | }, 131 | ], 132 | } as NamedAPIResourceList; 133 | -------------------------------------------------------------------------------- /tests/berry/mocks/handlers.ts: -------------------------------------------------------------------------------- 1 | import { baseHandler } from "../../utils/base-handler"; 2 | import { 3 | MOCK_BERRY, 4 | MOCK_BERRY_FIRMNESS, 5 | MOCK_BERRY_FIRMNESS_LIST, 6 | MOCK_BERRY_FLAVOR, 7 | MOCK_BERRY_FLAVOR_LIST, 8 | MOCK_BERRY_LIST, 9 | } from "./data"; 10 | 11 | export const BERRY_HANDLERS = [ 12 | baseHandler("/berry", MOCK_BERRY, "cheri"), 13 | baseHandler("/berry", MOCK_BERRY, "1"), 14 | baseHandler("/berry-firmness", MOCK_BERRY_FIRMNESS, "very-soft"), 15 | baseHandler("/berry-firmness", MOCK_BERRY_FIRMNESS, "1"), 16 | baseHandler("/berry-flavor", MOCK_BERRY_FLAVOR, "spicy"), 17 | baseHandler("/berry-flavor", MOCK_BERRY_FLAVOR, "1"), 18 | baseHandler("/berry", MOCK_BERRY_LIST), 19 | baseHandler("/berry-firmness", MOCK_BERRY_FIRMNESS_LIST), 20 | baseHandler("/berry-flavor", MOCK_BERRY_FLAVOR_LIST), 21 | ]; 22 | -------------------------------------------------------------------------------- /tests/contest/contest.spec.ts: -------------------------------------------------------------------------------- 1 | import { ContestClient } from "@clients"; 2 | import { CONTEST_TYPES } from "@constants"; 3 | 4 | describe("Contest Client", () => { 5 | let client: ContestClient; 6 | 7 | beforeAll(() => { 8 | client = new ContestClient(); 9 | }); 10 | 11 | // Client 12 | it("(client) should be instantiated correctly", () => expect(client).toBeDefined()); 13 | 14 | // Contest Type 15 | it("check if it returns a contest type passig a name", async () => { 16 | const data = await client.getContestTypeByName("cool"); 17 | expect(data.id).toBe(CONTEST_TYPES.COOL); 18 | }); 19 | 20 | it("check if it returns a contest type passing an ID", async () => { 21 | const data = await client.getContestTypeById(CONTEST_TYPES.COOL); 22 | expect(data.name).toBe("cool"); 23 | }); 24 | 25 | it("check if it returns a list of contest types", async () => { 26 | const data = await client.listContestTypes(); 27 | 28 | expect(data.results.length).toBeGreaterThan(0); 29 | expect(data.results.length).toBeLessThanOrEqual(20); 30 | }); 31 | 32 | // Contest Effect 33 | it("check if it returns a contest effect passing an ID", async () => { 34 | const data = await client.getContestEffectById(1); 35 | expect(data.effect_entries.length).toBeGreaterThan(0); 36 | }); 37 | 38 | it("check if it returns a list of contest effects", async () => { 39 | const data = await client.listContestEffects(); 40 | expect(data.results.length).toBeGreaterThan(0); 41 | expect(data.results.length).toBeLessThanOrEqual(20); 42 | }); 43 | 44 | // Super Contest Effect 45 | it("check if it returns a super contest effect passing an ID", async () => { 46 | const data = await client.getSuperContestEffectById(1); 47 | expect(data.flavor_text_entries.length).toBeGreaterThan(0); 48 | }); 49 | 50 | it("check if it returns a list of super contest effects", async () => { 51 | const data = await client.listSuperContestEffects(); 52 | expect(data.results.length).toBeGreaterThan(0); 53 | expect(data.results.length).toBeLessThanOrEqual(20); 54 | }); 55 | }); 56 | -------------------------------------------------------------------------------- /tests/contest/contest.test-d.ts: -------------------------------------------------------------------------------- 1 | // WIP 2 | -------------------------------------------------------------------------------- /tests/encounter/encounter.spec.ts: -------------------------------------------------------------------------------- 1 | import { EncounterClient } from "@clients"; 2 | import { ENCOUNTER_CONDITIONS, ENCOUNTER_CONDITION_VALUES, ENCOUNTER_METHODS } from "@constants"; 3 | 4 | describe("Encounter Client", () => { 5 | let client: EncounterClient; 6 | 7 | beforeAll(() => { 8 | client = new EncounterClient(); 9 | }); 10 | 11 | // Client 12 | it("(client) should be instantiated correctly", () => expect(client).toBeDefined()); 13 | 14 | // Encounter Method 15 | it("check if it returns an encounter method passig a name", async () => { 16 | const data = await client.getEncounterMethodByName("walk"); 17 | 18 | expect(data.id).toBe(ENCOUNTER_METHODS.WALK); 19 | }); 20 | 21 | it("check if it returns an encounter method passig an id", async () => { 22 | const data = await client.getEncounterMethodById(ENCOUNTER_METHODS.WALK); 23 | 24 | expect(data.name).toBe("walk"); 25 | }); 26 | 27 | it("check if it returns a list of encounter methods", async () => { 28 | const data = await client.listEncounterMethods(); 29 | 30 | expect(data.results.length).toBeGreaterThan(0); 31 | expect(data.results.length).toBeLessThanOrEqual(20); 32 | }); 33 | 34 | // Encounter Condition 35 | it("check if it returns an encounter condition passig a name", async () => { 36 | const data = await client.getEncounterConditionByName("swarm"); 37 | 38 | expect(data.id).toBe(ENCOUNTER_CONDITIONS.SWARM); 39 | }); 40 | 41 | it("check if it returns an encounter condition passig an id", async () => { 42 | const data = await client.getEncounterConditionById(ENCOUNTER_CONDITIONS.SWARM); 43 | 44 | expect(data.name).toBe("swarm"); 45 | }); 46 | 47 | it("check if it returns a list of encounter conditions", async () => { 48 | const data = await client.listEncounterConditions(); 49 | 50 | expect(data.results.length).toBeGreaterThan(0); 51 | expect(data.results.length).toBeLessThanOrEqual(20); 52 | }); 53 | 54 | // Encounter Condition Values 55 | it("check if it returns an encounter condition values passig a name", async () => { 56 | const data = await client.getEncounterConditionValueByName("swarm-yes"); 57 | 58 | expect(data.id).toBe(ENCOUNTER_CONDITION_VALUES.SWARM_YES); 59 | }); 60 | 61 | it("check if it returns an encounter condition values passig an id", async () => { 62 | const data = await client.getEncounterConditionValueById(ENCOUNTER_CONDITION_VALUES.SWARM_YES); 63 | 64 | expect(data.name).toBe("swarm-yes"); 65 | }); 66 | 67 | it("check if it returns a list of encounter condition values", async () => { 68 | const data = await client.listEncounterConditionValues(); 69 | 70 | expect(data.results.length).toBeGreaterThan(0); 71 | expect(data.results.length).toBeLessThanOrEqual(20); 72 | }); 73 | }); 74 | -------------------------------------------------------------------------------- /tests/encounter/encouter.test-d.ts: -------------------------------------------------------------------------------- 1 | // WIP 2 | -------------------------------------------------------------------------------- /tests/evolution/evolution.spec.ts: -------------------------------------------------------------------------------- 1 | import { EvolutionClient } from "@clients"; 2 | import { EVOLUTION_TRIGGERS } from "@constants"; 3 | 4 | describe("Evolution Client", () => { 5 | let client: EvolutionClient; 6 | 7 | beforeAll(() => { 8 | client = new EvolutionClient(); 9 | }); 10 | 11 | // Client 12 | it("(client) should be instantiated correctly", () => expect(client).toBeDefined()); 13 | 14 | // Evolution Trigger 15 | it("check if it returns an evolution trigger passig an ID", async () => { 16 | const data = await client.getEvolutionTriggerById(EVOLUTION_TRIGGERS.LEVEL_UP); 17 | 18 | expect(data.name).toBe("level-up"); 19 | }); 20 | 21 | it("check if it returns an evolution trigger passing a name", async () => { 22 | const data = await client.getEvolutionTriggerByName("level-up"); 23 | 24 | expect(data.id).toBe(EVOLUTION_TRIGGERS.LEVEL_UP); 25 | }); 26 | 27 | it("check if it returns a list of evolution triggers", async () => { 28 | const data = await client.listEvolutionTriggers(); 29 | 30 | expect(data.results.length).toBeGreaterThan(0); 31 | expect(data.results.length).toBeLessThanOrEqual(20); 32 | }); 33 | 34 | // Evolution Chain 35 | it("check if it returns an evolution chain passig an ID", async () => { 36 | const data = await client.getEvolutionChainById(1); 37 | 38 | expect(data.id).toBe(1); 39 | }); 40 | 41 | it("check if it returns a list of evolution chains", async () => { 42 | const data = await client.listEvolutionChains(); 43 | 44 | expect(data.results.length).toBeGreaterThan(0); 45 | expect(data.results.length).toBeLessThanOrEqual(20); 46 | }); 47 | }); 48 | -------------------------------------------------------------------------------- /tests/evolution/evolution.test-d.ts: -------------------------------------------------------------------------------- 1 | // WIP 2 | -------------------------------------------------------------------------------- /tests/game/game.spec.ts: -------------------------------------------------------------------------------- 1 | import { GameClient } from "@clients"; 2 | import { GENERATIONS, POKEDEXES, VERSIONS, VERSION_GROUPS } from "@constants"; 3 | 4 | describe("Game Client", () => { 5 | let client: GameClient; 6 | 7 | beforeAll(() => { 8 | client = new GameClient(); 9 | }); 10 | 11 | // Client 12 | it("(client) should be instantiated correctly", () => expect(client).toBeDefined()); 13 | 14 | // Generation 15 | it("check if it returns a generation passig a name", async () => { 16 | const data = await client.getGenerationByName("generation-i"); 17 | 18 | expect(data.id).toBe(GENERATIONS.GENERATION_I); 19 | }); 20 | 21 | it("check if it returns a generation passing an ID", async () => { 22 | const data = await client.getGenerationById(GENERATIONS.GENERATION_I); 23 | 24 | expect(data.name).toBe("generation-i"); 25 | }); 26 | 27 | it("check if it returns a list of generations", async () => { 28 | const data = await client.listGenerations(); 29 | 30 | expect(data.results.length).toBeGreaterThan(0); 31 | expect(data.results.length).toBeLessThanOrEqual(20); 32 | }); 33 | 34 | // Pokedex 35 | it("check if it returns a pokedex passig a name", async () => { 36 | const data = await client.getPokedexByName("national"); 37 | 38 | expect(data.id).toBe(POKEDEXES.NATIONAL); 39 | }); 40 | 41 | it("check if it returns a pokedex passing an ID", async () => { 42 | const data = await client.getPokedexById(POKEDEXES.NATIONAL); 43 | 44 | expect(data.name).toBe("national"); 45 | }); 46 | 47 | it("check if it returns a list of pokedexes", async () => { 48 | const data = await client.listPokedexes(); 49 | 50 | expect(data.results.length).toBeGreaterThan(0); 51 | expect(data.results.length).toBeLessThanOrEqual(20); 52 | }); 53 | 54 | // Version 55 | it("check if it returns a version passig a name", async () => { 56 | const data = await client.getVersionByName("red"); 57 | 58 | expect(data.id).toBe(VERSIONS.RED); 59 | }); 60 | 61 | it("check if it returns a version passing an ID", async () => { 62 | const data = await client.getVersionById(VERSIONS.RED); 63 | 64 | expect(data.name).toBe("red"); 65 | }); 66 | 67 | it("check if it returns a list of versions", async () => { 68 | const data = await client.listVersions(); 69 | 70 | expect(data.results.length).toBeGreaterThan(0); 71 | expect(data.results.length).toBeLessThanOrEqual(20); 72 | }); 73 | 74 | // Version Groups 75 | it("check if it returns a version group passig a name", async () => { 76 | const data = await client.getVersionGroupByName("red-blue"); 77 | 78 | expect(data.id).toBe(VERSION_GROUPS.RED_BLUE); 79 | }); 80 | 81 | it("check if it returns a version group passing an ID", async () => { 82 | const data = await client.getVersionGroupById(VERSION_GROUPS.RED_BLUE); 83 | 84 | expect(data.name).toBe("red-blue"); 85 | }); 86 | 87 | it("check if it returns a list of version groups", async () => { 88 | const data = await client.listVersionGroups(); 89 | 90 | expect(data.results.length).toBeGreaterThan(0); 91 | expect(data.results.length).toBeLessThanOrEqual(20); 92 | }); 93 | }); 94 | -------------------------------------------------------------------------------- /tests/game/game.test-d.ts: -------------------------------------------------------------------------------- 1 | // WIP 2 | -------------------------------------------------------------------------------- /tests/item/item.spec.ts: -------------------------------------------------------------------------------- 1 | import { ItemClient } from "@clients"; 2 | import { ITEM_CATEGORIES, ITEM_FLING_EFFECTS, ITEM_POCKETS } from "@constants"; 3 | 4 | describe("Item Client", () => { 5 | let client: ItemClient; 6 | 7 | beforeAll(() => { 8 | client = new ItemClient(); 9 | }); 10 | 11 | // Client 12 | it("(client) should be instantiated correctly", () => expect(client).toBeDefined()); 13 | 14 | // Item 15 | it("check if it returns an item passig a name", async () => { 16 | const data = await client.getItemByName("master-ball"); 17 | 18 | expect(data.name).toBe("master-ball"); 19 | }); 20 | 21 | it("check if it returns an item passing an ID", async () => { 22 | const data = await client.getItemById(1); 23 | 24 | expect(data.name).toBe("master-ball"); 25 | }); 26 | 27 | it("check if it returns a list of Items", async () => { 28 | const data = await client.listItems(); 29 | 30 | expect(data.results.length).toBeGreaterThan(0); 31 | expect(data.results.length).toBeLessThanOrEqual(20); 32 | }); 33 | 34 | // Item Attribute 35 | it("check if it returns an item attribute passig a name", async () => { 36 | const data = await client.getItemAttributeByName("countable"); 37 | 38 | expect(data.name).toBe("countable"); 39 | }); 40 | 41 | it("check if it returns an item attribute passing an ID", async () => { 42 | const data = await client.getItemAttributeById(1); 43 | 44 | expect(data.name).toBe("countable"); 45 | }); 46 | 47 | it("check if it returns a list of item attributes", async () => { 48 | const data = await client.listItemAttributes(); 49 | 50 | expect(data.results.length).toBeGreaterThan(0); 51 | expect(data.results.length).toBeLessThanOrEqual(20); 52 | }); 53 | 54 | // Item Category 55 | it("check if it returns an item category passig a name", async () => { 56 | const data = await client.getItemCategoryByName("choice"); 57 | 58 | expect(data.id).toBe(13); 59 | }); 60 | 61 | it("check if it returns an item category passing an ID", async () => { 62 | const data = await client.getItemCategoryById(ITEM_CATEGORIES.CHOICE); 63 | 64 | expect(data.name).toBe("choice"); 65 | }); 66 | 67 | it("check if it returns a list of item categories", async () => { 68 | const data = await client.listItemCategories(); 69 | 70 | expect(data.results.length).toBeGreaterThan(0); 71 | expect(data.results.length).toBeLessThanOrEqual(20); 72 | }); 73 | 74 | // Item Fling Effects 75 | it("check if it returns an item fling effect passig a name", async () => { 76 | const data = await client.getItemFlingEffectByName("flinch"); 77 | 78 | expect(data.id).toBe(ITEM_FLING_EFFECTS.FLINCH); 79 | }); 80 | 81 | it("check if it returns an item fling effect passing an ID", async () => { 82 | const data = await client.getItemFlingEffectById(ITEM_FLING_EFFECTS.FLINCH); 83 | 84 | expect(data.name).toBe("flinch"); 85 | }); 86 | 87 | it("check if it returns a list of item fling effects", async () => { 88 | const data = await client.listItemFilingEffects(); 89 | 90 | expect(data.results.length).toBeGreaterThan(0); 91 | expect(data.results.length).toBeLessThanOrEqual(20); 92 | }); 93 | 94 | // Item Pocket 95 | it("check if it returns an item pocket passig a name", async () => { 96 | const data = await client.getItemPocketByName("battle"); 97 | 98 | expect(data.id).toBe(ITEM_POCKETS.BATTLE); 99 | }); 100 | 101 | it("check if it returns an item pocket passing an ID", async () => { 102 | const data = await client.getItemPocketById(ITEM_POCKETS.BATTLE); 103 | 104 | expect(data.name).toBe("battle"); 105 | }); 106 | 107 | it("check if it returns a list of item pockets", async () => { 108 | const data = await client.listItemPockets(); 109 | 110 | expect(data.results.length).toBeGreaterThan(0); 111 | expect(data.results.length).toBeLessThanOrEqual(20); 112 | }); 113 | }); 114 | -------------------------------------------------------------------------------- /tests/item/item.test-d.ts: -------------------------------------------------------------------------------- 1 | // WIP 2 | -------------------------------------------------------------------------------- /tests/location/location.spec.ts: -------------------------------------------------------------------------------- 1 | import { LocationClient } from "@clients"; 2 | import { PAL_PARK_AREAS, REGIONS } from "@constants"; 3 | 4 | describe("Location Client", () => { 5 | let client: LocationClient; 6 | 7 | beforeAll(() => { 8 | client = new LocationClient(); 9 | }); 10 | 11 | // Client 12 | it("(client) should be instantiated correctly", () => expect(client).toBeDefined()); 13 | 14 | // Location 15 | it("check if it returns a location passig a name", async () => { 16 | const data = await client.getLocationByName("canalave-city"); 17 | 18 | expect(data.id).toBe(1); 19 | }); 20 | 21 | it("check if it returns a location passing an ID", async () => { 22 | const data = await client.getLocationById(1); 23 | 24 | expect(data.name).toBe("canalave-city"); 25 | }); 26 | 27 | it("check if it returns a list of locations", async () => { 28 | const data = await client.listLocations(); 29 | 30 | expect(data.results.length).toBeGreaterThan(0); 31 | expect(data.results.length).toBeLessThanOrEqual(20); 32 | }); 33 | 34 | // Location Area 35 | it("check if it returns a location area passig a name", async () => { 36 | const data = await client.getLocationAreaByName("canalave-city-area"); 37 | 38 | expect(data.id).toBe(1); 39 | }); 40 | 41 | it("check if it returns a location area passing an ID", async () => { 42 | const data = await client.getLocationAreaById(1); 43 | 44 | expect(data.name).toBe("canalave-city-area"); 45 | }); 46 | 47 | it("check if it returns a list of location areas", async () => { 48 | const data = await client.listLocationAreas(); 49 | 50 | expect(data.results.length).toBeGreaterThan(0); 51 | expect(data.results.length).toBeLessThanOrEqual(20); 52 | }); 53 | 54 | // Pal Park Area 55 | it("check if it returns a pal park area passig a name", async () => { 56 | const data = await client.getPalParkAreaByName("forest"); 57 | 58 | expect(data.id).toBe(PAL_PARK_AREAS.FOREST); 59 | }); 60 | 61 | it("check if it returns a pal park area passing an ID", async () => { 62 | const data = await client.getPalParkAreaById(PAL_PARK_AREAS.FOREST); 63 | 64 | expect(data.name).toBe("forest"); 65 | }); 66 | 67 | it("check if it returns a list of pal park areas", async () => { 68 | const data = await client.listPalParkAreas(); 69 | 70 | expect(data.results.length).toBeGreaterThan(0); 71 | expect(data.results.length).toBeLessThanOrEqual(20); 72 | }); 73 | 74 | // Regions 75 | it("check if it returns a region passig a name", async () => { 76 | const data = await client.getRegionByName("kanto"); 77 | 78 | expect(data.id).toBe(REGIONS.KANTO); 79 | }); 80 | 81 | it("check if it returns a region passing an ID", async () => { 82 | const data = await client.getRegionById(REGIONS.KANTO); 83 | 84 | expect(data.name).toBe("kanto"); 85 | }); 86 | 87 | it("check if it returns a list of regions", async () => { 88 | const data = await client.listRegions(); 89 | 90 | expect(data.results.length).toBeGreaterThan(0); 91 | expect(data.results.length).toBeLessThanOrEqual(20); 92 | }); 93 | }); 94 | -------------------------------------------------------------------------------- /tests/location/location.test-d.ts: -------------------------------------------------------------------------------- 1 | // WIP 2 | -------------------------------------------------------------------------------- /tests/logger/logger.spec.ts: -------------------------------------------------------------------------------- 1 | import { 2 | handleRequest, 3 | handleRequestError, 4 | handleResponse, 5 | handleResponseError, 6 | } from "@config/logger"; 7 | 8 | const consoleLogSpy = vi.spyOn(console, "log"); 9 | const consoleErrorSpy = vi.spyOn(console, "error"); 10 | 11 | afterEach(() => { 12 | consoleLogSpy.mockClear(); 13 | consoleErrorSpy.mockClear(); 14 | }); 15 | 16 | afterAll(() => { 17 | vi.clearAllMocks(); 18 | }); 19 | 20 | describe("Logger", () => { 21 | it("should call the request log", () => { 22 | const handleRequestMock = vi.fn().mockImplementation(handleRequest); 23 | 24 | expect(handleRequestMock({}, true)).toEqual({}); 25 | expect(consoleLogSpy).toHaveBeenCalled(); 26 | expect(handleRequestMock).toHaveBeenCalled(); 27 | }); 28 | 29 | it("should not call the request log", () => { 30 | const handleRequestMock = vi.fn().mockImplementation(handleRequest); 31 | 32 | expect(handleRequestMock({})).toEqual({}); 33 | expect(consoleLogSpy).not.toHaveBeenCalled(); 34 | expect(handleRequestMock).toHaveBeenCalled(); 35 | }); 36 | 37 | it("should call the request error log", async () => { 38 | const handleRequestErrorMock = vi.fn().mockImplementation(handleRequestError); 39 | 40 | await expect(handleRequestErrorMock({}, true)).rejects.toThrowError(); 41 | expect(consoleErrorSpy).toHaveBeenCalled(); 42 | expect(handleRequestErrorMock).toHaveBeenCalled(); 43 | }); 44 | 45 | it("should call the response log", () => { 46 | const handleResponseMock = vi.fn().mockImplementation(handleResponse); 47 | 48 | expect(handleResponseMock({}, true)).toEqual({}); 49 | expect(consoleLogSpy).toHaveBeenCalled(); 50 | expect(handleResponseMock).toHaveBeenCalled(); 51 | }); 52 | 53 | it("should not call the response log", () => { 54 | const handleResponseMock = vi.fn().mockImplementation(handleResponse); 55 | 56 | expect(handleResponseMock({})).toEqual({}); 57 | expect(consoleLogSpy).not.toHaveBeenCalled(); 58 | expect(handleResponseMock).toHaveBeenCalled(); 59 | }); 60 | 61 | it("should call the request error log", async () => { 62 | const handleResponseErrorMock = vi.fn().mockImplementation(handleResponseError); 63 | 64 | await expect(handleResponseErrorMock({}, true)).rejects.toThrowError(); 65 | expect(consoleErrorSpy).toHaveBeenCalled(); 66 | expect(handleResponseErrorMock).toHaveBeenCalled(); 67 | }); 68 | }); 69 | -------------------------------------------------------------------------------- /tests/machine/machine.spec.ts: -------------------------------------------------------------------------------- 1 | import { MachineClient } from "@clients"; 2 | 3 | describe("Machine Client", () => { 4 | let client: MachineClient; 5 | 6 | beforeAll(() => { 7 | client = new MachineClient(); 8 | }); 9 | 10 | // Client 11 | it("(client) should be instantiated correctly", () => expect(client).toBeDefined()); 12 | 13 | // Machine 14 | it("check if it returns a machine passing an ID", async () => { 15 | const data = await client.getMachineById(1); 16 | 17 | expect(data.id).toBe(1); 18 | }); 19 | 20 | it("check if it returns a list of machines", async () => { 21 | const data = await client.listMachines(); 22 | 23 | expect(data.results.length).toBeGreaterThan(0); 24 | expect(data.results.length).toBeLessThanOrEqual(20); 25 | }); 26 | }); 27 | -------------------------------------------------------------------------------- /tests/machine/machine.test-d.ts: -------------------------------------------------------------------------------- 1 | // WIP 2 | -------------------------------------------------------------------------------- /tests/main/main.spec.ts: -------------------------------------------------------------------------------- 1 | import { MainClient } from "@clients"; 2 | import { 3 | BERRIES, 4 | CONTEST_TYPES, 5 | ENCOUNTER_METHODS, 6 | EVOLUTION_TRIGGERS, 7 | GENERATIONS, 8 | } from "@constants"; 9 | 10 | describe("MainClient Client", () => { 11 | let client: MainClient; 12 | 13 | beforeAll(() => { 14 | client = new MainClient(); 15 | }); 16 | 17 | // Main Client 18 | it("(clients) should be instantiated correctly", () => { 19 | expect(client).toBeDefined(); 20 | expect(client.berry).toBeDefined; 21 | expect(client.contest).toBeDefined(); 22 | expect(client.encounter).toBeDefined(); 23 | expect(client.evolution).toBeDefined(); 24 | expect(client.game).toBeDefined(); 25 | expect(client.item).toBeDefined(); 26 | expect(client.location).toBeDefined(); 27 | expect(client.machine).toBeDefined(); 28 | expect(client.move).toBeDefined(); 29 | expect(client.pokemon).toBeDefined(); 30 | }); 31 | 32 | // Berry Client 33 | it("check if it returns a berry passig a name", async () => { 34 | const data = await client.berry.getBerryByName("cheri"); 35 | 36 | expect(data.id).toBe(BERRIES.CHERI); 37 | }); 38 | 39 | // Contest Client 40 | it("check if it returns a contest type passig a name", async () => { 41 | const data = await client.contest.getContestTypeByName("cool"); 42 | 43 | expect(data.id).toBe(CONTEST_TYPES.COOL); 44 | }); 45 | 46 | // Encounter Client 47 | it("check if it returns an encounter method passig a name", async () => { 48 | const data = await client.encounter.getEncounterMethodByName("surf"); 49 | 50 | expect(data.id).toBe(ENCOUNTER_METHODS.SURF); 51 | }); 52 | 53 | // Evolution Client 54 | it("check if it returns an evolution trigger method passig a name", async () => { 55 | const data = await client.evolution.getEvolutionTriggerByName("shed"); 56 | 57 | expect(data.id).toBe(EVOLUTION_TRIGGERS.SHED); 58 | }); 59 | 60 | // Game Client 61 | it("check if it returns a generation method passig a name", async () => { 62 | const data = await client.game.getGenerationByName("generation-i"); 63 | 64 | expect(data.id).toBe(GENERATIONS.GENERATION_I); 65 | }); 66 | 67 | // Item Client 68 | it("check if it returns an item passig a name", async () => { 69 | const data = await client.item.getItemByName("master-ball"); 70 | 71 | expect(data.id).toBe(1); 72 | }); 73 | 74 | // Location Client 75 | it("check if it returns a location passig a name", async () => { 76 | const data = await client.location.getLocationByName("canalave-city"); 77 | 78 | expect(data.id).toBe(1); 79 | }); 80 | 81 | // Machine Client 82 | it("check if it returns a machine passig an ID", async () => { 83 | const data = await client.machine.getMachineById(1); 84 | 85 | expect(data.id).toBe(1); 86 | }); 87 | 88 | // Move Client 89 | it("check if it returns a move passig a name", async () => { 90 | const data = await client.move.getMoveById(1); 91 | 92 | expect(data.id).toBe(1); 93 | }); 94 | 95 | // Pokemon Client 96 | it("check if it returns a pokemon passig a name", async () => { 97 | const data = await client.pokemon.getPokemonByName("luxray"); 98 | 99 | expect(data.id).toBe(405); 100 | }); 101 | }); 102 | -------------------------------------------------------------------------------- /tests/main/main.test-d.ts: -------------------------------------------------------------------------------- 1 | // WIP 2 | -------------------------------------------------------------------------------- /tests/move/move.test-d.ts: -------------------------------------------------------------------------------- 1 | // WIP 2 | -------------------------------------------------------------------------------- /tests/pokemon/pokemon.test-d.ts: -------------------------------------------------------------------------------- 1 | // WIP 2 | -------------------------------------------------------------------------------- /tests/utility/utility.spec.ts: -------------------------------------------------------------------------------- 1 | import { UtilityClient } from "@clients"; 2 | import { LANGUAGES } from "@constants"; 3 | import type { Pokemon } from "@models"; 4 | 5 | describe("Utility Client", () => { 6 | let client: UtilityClient; 7 | 8 | beforeAll(() => { 9 | client = new UtilityClient(); 10 | }); 11 | 12 | // Client 13 | it("(client) should be instantiated correctly", () => expect(client).toBeDefined()); 14 | 15 | // Language 16 | it("check if it returns a language passig a name", async () => { 17 | const data = await client.getLanguageByName("roomaji"); 18 | 19 | expect(data.id).toBe(LANGUAGES.ROOMAJI); 20 | }); 21 | it("check if it returns a language passing an ID", async () => { 22 | const data = await client.getLanguageById(LANGUAGES.FR); 23 | 24 | expect(data.name).toBe("fr"); 25 | }); 26 | it("check if it returns a list of berries", async () => { 27 | const data = await client.listLanguages(); 28 | 29 | expect(data.results.length).toBeGreaterThan(0); 30 | expect(data.results.length).toBeLessThanOrEqual(20); 31 | }); 32 | 33 | // Resource (pokemon) 34 | it("check if it returns a resource (pokemon) passig an url", async () => { 35 | const data = await client.getResourceByUrl("https://pokeapi.co/api/v2/pokemon/luxray"); 36 | 37 | expect(data.id).toBe(405); 38 | }); 39 | }); 40 | -------------------------------------------------------------------------------- /tests/utility/utility.test-d.ts: -------------------------------------------------------------------------------- 1 | // WIP 2 | -------------------------------------------------------------------------------- /tests/utils/base-handler.ts: -------------------------------------------------------------------------------- 1 | import { http, type DefaultBodyType, type HttpHandler, HttpResponse, type PathParams } from "msw"; 2 | 3 | import { BASE_URL, type Endpoint } from "@constants"; 4 | 5 | type PokeApiListRequestParams = { 6 | limit: string; 7 | offset: string; 8 | }; 9 | 10 | /** 11 | * Creates a base handler for API mocking using MSW. 12 | * 13 | * This function provides a reusable foundation for mocking API endpoints, 14 | * simplifying test setup and ensuring consistent mocking patterns. 15 | * 16 | * It constructs a GET request handler for the specified endpoint and response data, 17 | * optionally including a dynamic path segment for flexibility. 18 | */ 19 | export const baseHandler = < 20 | P extends PathParams = PokeApiListRequestParams, 21 | B extends DefaultBodyType = DefaultBodyType, 22 | R extends DefaultBodyType = undefined, 23 | >( 24 | endpoint: Endpoint, 25 | mockResponse: R, 26 | identifier = "", 27 | ): HttpHandler => { 28 | let url = `${BASE_URL.REST}${endpoint}`; 29 | 30 | if (identifier) { 31 | url = `${url}/${identifier}`; 32 | } 33 | 34 | return http.get(url, async () => { 35 | return HttpResponse.json(mockResponse); 36 | }); 37 | }; 38 | -------------------------------------------------------------------------------- /tests/utils/setup.ts: -------------------------------------------------------------------------------- 1 | import { setupServer } from "msw/node"; 2 | 3 | import { BERRY_HANDLERS } from "../berry/mocks/handlers"; 4 | 5 | const HANDLERS = [...BERRY_HANDLERS]; 6 | 7 | const server = setupServer(...HANDLERS); 8 | 9 | // Events 10 | server.events.on("unhandledException", ({ request: { method, url }, error }) => { 11 | console.log(`${method} ${url} errored! See details below.`); 12 | console.error(error); 13 | }); 14 | 15 | // Vitest hooks 16 | beforeAll(() => server.listen({ onUnhandledRequest: "bypass" })); 17 | afterAll(() => server.close()); 18 | afterEach(() => server.resetHandlers()); 19 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | // Specifies the ECMAScript target version (latest features). 4 | "target": "ESNext", 5 | // An array of library files to include in the compilation. 6 | "lib": ["ESNext"], 7 | // Vitest globals 8 | "types": ["vitest/globals"], 9 | // Allows JavaScript files to be included in the project. 10 | "allowJs": true, 11 | // Skips type checking of declaration files. 12 | "skipLibCheck": true, 13 | // Enables all strict type-checking options. 14 | "strict": true, 15 | // Prevents TypeScript from emitting output files (e.g., JavaScript files). 16 | "noEmit": true, 17 | // Adds `undefined` to the type of an indexing operation for possibly undefined objects. 18 | "noUncheckedIndexedAccess": true, 19 | // Ensures that the casing of referenced file names matches the casing of the actual file. 20 | "forceConsistentCasingInFileNames": true, 21 | // Generates corresponding `.d.ts` files for TypeScript files. 22 | "declaration": false, 23 | // Allows default imports from modules with no default export. 24 | "esModuleInterop": true, 25 | // Specifies the module code generation. 26 | "module": "ESNext", 27 | // Specifies how modules are resolved. 28 | "moduleResolution": "Bundler", 29 | // Enables experimental support for decorators. 30 | "experimentalDecorators": true, 31 | // Enables the metadata reflection for decorators. 32 | "emitDecoratorMetadata": true, 33 | // Allows importing JSON files as modules. 34 | "resolveJsonModule": true, 35 | // Transforms each file as a separate module, which can help catch more errors. 36 | "isolatedModules": true, 37 | // Specifies the base directory for resolving non-relative module names. 38 | "baseUrl": ".", 39 | // Defines path mappings for module names. 40 | "paths": { 41 | "@clients": ["src/clients/index.ts"], 42 | "@config/*": ["src/config/*"], 43 | "@constants": ["src/constants/index.ts"], 44 | "@models": ["src/models/index.ts"], 45 | "@package": ["package.json"] 46 | } 47 | }, 48 | // Specifies the files to include in the compilation. 49 | "include": ["src/**/*.ts", "tests/**/*.ts"], 50 | // Specifies files to be excluded from the compilation. 51 | "exclude": ["node_modules"] 52 | } 53 | -------------------------------------------------------------------------------- /tsup.config.ts: -------------------------------------------------------------------------------- 1 | import isCI from "is-ci"; 2 | import { defineConfig } from "tsup"; 3 | import { author, description, license, peerDependencies, version } from "./package.json"; 4 | 5 | // Extract peerDependencies from package.json 6 | const EXTERNAL_DEPS = Object.keys(peerDependencies as Record); 7 | 8 | // Custom banner with improved formatting 9 | const myBanner = ` 10 | /** 11 | * _ 12 | * |_) _ | _ _ _ _| _ __ _|_ _ 13 | * | (_) |< (/_ | | (_) (_| (/_ |_ _> 14 | * 15 | * ${description} 16 | * Author: ${author.name} <${author.url}> 17 | * Version: ${version} | Build Date: ${new Date().toLocaleDateString("en-us")} 18 | * Build Environment: Node ${process.version} 19 | * License: ${license} 20 | **/ 21 | `; 22 | 23 | export default defineConfig({ 24 | // Entry file(s) for the bundling process 25 | entry: ["src/index.ts"], 26 | // Output directory for the bundled code 27 | outDir: "lib", 28 | // Enable code splitting for better performance 29 | splitting: true, 30 | // Specify external dependencies to exclude from the bundle 31 | external: EXTERNAL_DEPS, 32 | // Generate source maps if not running in a continuous integration environment 33 | sourcemap: !isCI, 34 | // Clean the output directory before each build if not in a continuous integration environment 35 | clean: !isCI, 36 | // Generate declaration files (.d.ts) 37 | dts: true, 38 | // Output formats: CommonJS and ECMAScript modules 39 | format: ["cjs", "esm"], 40 | // Minify the code if in a continuous integration environment 41 | minify: isCI, 42 | // Add a custom banner to the top of each bundled file 43 | banner: { js: myBanner }, 44 | }); 45 | -------------------------------------------------------------------------------- /vitest.config.ts: -------------------------------------------------------------------------------- 1 | import tsconfigPaths from "vite-tsconfig-paths"; 2 | import { defineConfig } from "vitest/config"; 3 | 4 | export default defineConfig({ 5 | plugins: [tsconfigPaths()], 6 | esbuild: { target: "ESNext" }, 7 | test: { 8 | setupFiles: "tests/utils/setup.ts", 9 | globals: true, 10 | testTimeout: 10_000, 11 | retry: 3, 12 | coverage: { 13 | provider: "v8", 14 | include: ["src/**/*"], 15 | exclude: ["src/models/*"], 16 | }, 17 | }, 18 | }); 19 | --------------------------------------------------------------------------------