├── .gitignore ├── src ├── interfaces │ ├── Pokemon │ │ ├── Characteristic.ts │ │ ├── EggGroup.ts │ │ ├── PokemonColor.ts │ │ ├── PokemonHabitat.ts │ │ ├── Gender.ts │ │ ├── GrowthRate.ts │ │ ├── PokemonShape.ts │ │ ├── PokeathlonStat.ts │ │ ├── PokemonForm.ts │ │ ├── Nature.ts │ │ ├── Stat.ts │ │ ├── Ability.ts │ │ ├── Type.ts │ │ ├── PokemonSpecies.ts │ │ └── Pokemon.ts │ ├── Moves │ │ ├── MoveBattleStyle.ts │ │ ├── MoveAilment.ts │ │ ├── MoveCategory.ts │ │ ├── MoveTarget.ts │ │ ├── MoveDamageClass.ts │ │ ├── MoveLearnMethod.ts │ │ └── Move.ts │ ├── Encounters │ │ ├── EncounterMethod.ts │ │ ├── EncounterConditionValue.ts │ │ └── EncounterCondition.ts │ ├── Utility │ │ ├── Language.ts │ │ ├── NamedApiResourceList.ts │ │ ├── ApiResourceList.ts │ │ └── CommonModels.ts │ ├── Contests │ │ ├── ContestEffect.ts │ │ ├── SuperContestEffect.ts │ │ └── ContestType.ts │ ├── Items │ │ ├── ItemPocket.ts │ │ ├── ItemFlingEffect.ts │ │ ├── ItemAttribute.ts │ │ ├── ItemCategory.ts │ │ └── Item.ts │ ├── Berries │ │ ├── BerryFirmness.ts │ │ ├── BerryFlavor.ts │ │ └── Berry.ts │ ├── Games │ │ ├── Version.ts │ │ ├── VersionGroup.ts │ │ ├── Pokedex.ts │ │ └── Generation.ts │ ├── Evolution │ │ ├── EvolutionTrigger.ts │ │ └── EvolutionChain.ts │ ├── Machines │ │ └── Machine.ts │ └── Locations │ │ ├── Location.ts │ │ ├── PalParkArea.ts │ │ ├── Region.ts │ │ └── LocationArea.ts ├── lib │ ├── Endpoint.ts │ └── NamedEndpoint.ts └── index.ts ├── eslint.config.js ├── package.json ├── README.md └── tsconfig.json /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | dist 3 | .editorconfig 4 | .npmignore -------------------------------------------------------------------------------- /src/interfaces/Pokemon/Characteristic.ts: -------------------------------------------------------------------------------- 1 | export type Characteristic = { 2 | gene_modulo: number; 3 | id: number; 4 | possible_values: number[]; 5 | }; 6 | -------------------------------------------------------------------------------- /src/interfaces/Moves/MoveBattleStyle.ts: -------------------------------------------------------------------------------- 1 | import type { Name } from "../Utility/CommonModels"; 2 | 3 | export type MoveBattleStyle = { 4 | id: number; 5 | name: string; 6 | names: Name[]; 7 | }; 8 | -------------------------------------------------------------------------------- /src/interfaces/Encounters/EncounterMethod.ts: -------------------------------------------------------------------------------- 1 | import type { Name } from "../Utility/CommonModels"; 2 | 3 | export type EncounterMethod = { 4 | id: number; 5 | name: string; 6 | names: Name[]; 7 | order: number; 8 | }; 9 | -------------------------------------------------------------------------------- /src/interfaces/Utility/Language.ts: -------------------------------------------------------------------------------- 1 | import type { Name } from "./CommonModels"; 2 | 3 | export type Language = { 4 | id: number; 5 | iso3166: string; 6 | iso639: string; 7 | name: string; 8 | names: Name[]; 9 | official: boolean; 10 | }; 11 | -------------------------------------------------------------------------------- /src/interfaces/Utility/NamedApiResourceList.ts: -------------------------------------------------------------------------------- 1 | export type NamedApiResource = { 2 | name: string; 3 | url: string; 4 | }; 5 | 6 | export type NamedApiResourceList = { 7 | count: number; 8 | next: string; 9 | previous: string; 10 | results: T[]; 11 | }; 12 | -------------------------------------------------------------------------------- /src/interfaces/Contests/ContestEffect.ts: -------------------------------------------------------------------------------- 1 | import type { Effect, FlavorText } from "../Utility/CommonModels"; 2 | 3 | export type ContestEffect = { 4 | appeal: number; 5 | effect_entries: Effect[]; 6 | flavor_text_entries: FlavorText[]; 7 | id: number; 8 | jam: number; 9 | }; 10 | -------------------------------------------------------------------------------- /src/interfaces/Items/ItemPocket.ts: -------------------------------------------------------------------------------- 1 | import type { NamedApiResource } from "../Utility/NamedApiResourceList"; 2 | import type { ItemCategory } from "./ItemCategory"; 3 | 4 | export type ItemPocket = { 5 | categories: NamedApiResource[]; 6 | id: number; 7 | name: string; 8 | }; 9 | -------------------------------------------------------------------------------- /src/interfaces/Moves/MoveAilment.ts: -------------------------------------------------------------------------------- 1 | import type { Name } from "../Utility/CommonModels"; 2 | import type { NamedApiResource } from "../Utility/NamedApiResourceList"; 3 | import type { Move } from "./Move"; 4 | 5 | export type MoveAilment = { 6 | id: number; 7 | moves: NamedApiResource[]; 8 | name: string; 9 | names: Name[]; 10 | }; 11 | -------------------------------------------------------------------------------- /src/interfaces/Berries/BerryFirmness.ts: -------------------------------------------------------------------------------- 1 | import type { Name } from "../Utility/CommonModels"; 2 | import type { NamedApiResource } from "../Utility/NamedApiResourceList"; 3 | import type { Berry } from "./Berry"; 4 | 5 | export type BerryFirmness = { 6 | berries: NamedApiResource[]; 7 | id: number; 8 | name: string; 9 | names: Name[]; 10 | }; 11 | -------------------------------------------------------------------------------- /src/interfaces/Games/Version.ts: -------------------------------------------------------------------------------- 1 | import type { Name } from "../Utility/CommonModels"; 2 | import type { NamedApiResource } from "../Utility/NamedApiResourceList"; 3 | import type { VersionGroup } from "./VersionGroup"; 4 | 5 | export type Version = { 6 | id: number; 7 | name: string; 8 | names: Name[]; 9 | version_group: NamedApiResource; 10 | }; 11 | -------------------------------------------------------------------------------- /src/interfaces/Items/ItemFlingEffect.ts: -------------------------------------------------------------------------------- 1 | import type { Effect } from "../Utility/CommonModels"; 2 | import type { NamedApiResource } from "../Utility/NamedApiResourceList"; 3 | import type { Item } from "./Item"; 4 | 5 | export type ItemFlingEffect = { 6 | effect_entries: Effect[]; 7 | id: number; 8 | items: NamedApiResource[]; 9 | name: string; 10 | }; 11 | -------------------------------------------------------------------------------- /src/interfaces/Moves/MoveCategory.ts: -------------------------------------------------------------------------------- 1 | import type { Description } from "../Utility/CommonModels"; 2 | import type { NamedApiResource } from "../Utility/NamedApiResourceList"; 3 | import type { Move } from "./Move"; 4 | 5 | export type MoveCategory = { 6 | descriptions: Description[]; 7 | id: number; 8 | moves: NamedApiResource[]; 9 | name: string; 10 | }; 11 | -------------------------------------------------------------------------------- /src/interfaces/Pokemon/EggGroup.ts: -------------------------------------------------------------------------------- 1 | import type { Name } from "../Utility/CommonModels"; 2 | import type { NamedApiResource } from "../Utility/NamedApiResourceList"; 3 | import type { PokemonSpecies } from "./PokemonSpecies"; 4 | 5 | export type EggGroup = { 6 | id: number; 7 | name: string; 8 | names: Name[]; 9 | pokemon_species: NamedApiResource[]; 10 | }; 11 | -------------------------------------------------------------------------------- /src/interfaces/Pokemon/PokemonColor.ts: -------------------------------------------------------------------------------- 1 | import type { Name } from "../Utility/CommonModels"; 2 | import type { NamedApiResource } from "../Utility/NamedApiResourceList"; 3 | import type { PokemonSpecies } from "./PokemonSpecies"; 4 | 5 | export type PokemonColor = { 6 | id: number; 7 | name: string; 8 | names: Name[]; 9 | pokemon_species: NamedApiResource; 10 | }; 11 | -------------------------------------------------------------------------------- /src/interfaces/Moves/MoveTarget.ts: -------------------------------------------------------------------------------- 1 | import type { Description, Name } from "../Utility/CommonModels"; 2 | import type { NamedApiResource } from "../Utility/NamedApiResourceList"; 3 | import type { Move } from "./Move"; 4 | 5 | export type MoveTarget = { 6 | descriptions: Description[]; 7 | id: number; 8 | moves: NamedApiResource[]; 9 | name: string; 10 | names: Name[]; 11 | }; 12 | -------------------------------------------------------------------------------- /src/interfaces/Pokemon/PokemonHabitat.ts: -------------------------------------------------------------------------------- 1 | import type { Name } from "../Utility/CommonModels"; 2 | import type { NamedApiResource } from "../Utility/NamedApiResourceList"; 3 | import type { PokemonSpecies } from "./PokemonSpecies"; 4 | 5 | export type PokemonHabitat = { 6 | id: number; 7 | name: string; 8 | names: Name[]; 9 | pokemon_species: NamedApiResource[]; 10 | }; 11 | -------------------------------------------------------------------------------- /src/interfaces/Items/ItemAttribute.ts: -------------------------------------------------------------------------------- 1 | import type { Description, Name } from "../Utility/CommonModels"; 2 | import type { NamedApiResource } from "../Utility/NamedApiResourceList"; 3 | import type { Item } from "./Item"; 4 | 5 | export type ItemAttribute = { 6 | descriptions: Description[]; 7 | id: number; 8 | items: NamedApiResource[]; 9 | name: string; 10 | names: Name[]; 11 | }; 12 | -------------------------------------------------------------------------------- /src/interfaces/Contests/SuperContestEffect.ts: -------------------------------------------------------------------------------- 1 | import type { Move } from "../Moves/Move.js"; 2 | import type { FlavorText } from "../Utility/CommonModels.js"; 3 | import type { NamedApiResource } from "../Utility/NamedApiResourceList.js"; 4 | 5 | export type SuperContestEffect = { 6 | flavor_text_entries: FlavorText[]; 7 | id: number; 8 | moves: NamedApiResource[]; 9 | name: string; 10 | }; 11 | -------------------------------------------------------------------------------- /src/interfaces/Moves/MoveDamageClass.ts: -------------------------------------------------------------------------------- 1 | import type { Description, Name } from "../Utility/CommonModels"; 2 | import type { NamedApiResource } from "../Utility/NamedApiResourceList"; 3 | import type { Move } from "./Move"; 4 | 5 | export type MoveDamageClass = { 6 | descriptions: Description[]; 7 | id: number; 8 | moves: NamedApiResource[]; 9 | name: string; 10 | names: Name[]; 11 | }; 12 | -------------------------------------------------------------------------------- /src/interfaces/Evolution/EvolutionTrigger.ts: -------------------------------------------------------------------------------- 1 | import type { PokemonSpecies } from "../Pokemon/PokemonSpecies"; 2 | import type { Name } from "../Utility/CommonModels"; 3 | import type { NamedApiResource } from "../Utility/NamedApiResourceList"; 4 | 5 | export type EvolutionTrigger = { 6 | id: number; 7 | name: string; 8 | names: Name[]; 9 | pokemon_species: NamedApiResource[]; 10 | }; 11 | -------------------------------------------------------------------------------- /src/interfaces/Encounters/EncounterConditionValue.ts: -------------------------------------------------------------------------------- 1 | import type { Name } from "../Utility/CommonModels"; 2 | import type { NamedApiResource } from "../Utility/NamedApiResourceList"; 3 | import type { EncounterCondition } from "./EncounterCondition"; 4 | 5 | export type EncounterConditionValue = { 6 | condition: NamedApiResource; 7 | id: number; 8 | name: string; 9 | names: Name[]; 10 | }; 11 | -------------------------------------------------------------------------------- /src/interfaces/Encounters/EncounterCondition.ts: -------------------------------------------------------------------------------- 1 | import type { Name } from "../Utility/CommonModels"; 2 | import type { NamedApiResource } from "../Utility/NamedApiResourceList"; 3 | import type { EncounterConditionValue } from "./EncounterConditionValue"; 4 | 5 | export type EncounterCondition = { 6 | id: number; 7 | name: string; 8 | names: Name[]; 9 | values: NamedApiResource[]; 10 | }; 11 | -------------------------------------------------------------------------------- /src/interfaces/Items/ItemCategory.ts: -------------------------------------------------------------------------------- 1 | import type { Name } from "../Utility/CommonModels"; 2 | import type { NamedApiResource } from "../Utility/NamedApiResourceList"; 3 | import type { Item } from "./Item"; 4 | import type { ItemPocket } from "./ItemPocket"; 5 | 6 | export type ItemCategory = { 7 | id: number; 8 | items: NamedApiResource[]; 9 | name: string; 10 | names: Name[]; 11 | pocket: NamedApiResource; 12 | }; 13 | -------------------------------------------------------------------------------- /src/interfaces/Moves/MoveLearnMethod.ts: -------------------------------------------------------------------------------- 1 | import type { VersionGroup } from "../Games/VersionGroup"; 2 | import type { Description, Name } from "../Utility/CommonModels"; 3 | import type { NamedApiResource } from "../Utility/NamedApiResourceList"; 4 | 5 | export type MoveLearnMethod = { 6 | descriptions: Description[]; 7 | id: number; 8 | name: string; 9 | names: Name[]; 10 | version_groups: NamedApiResource[]; 11 | }; 12 | -------------------------------------------------------------------------------- /src/interfaces/Machines/Machine.ts: -------------------------------------------------------------------------------- 1 | import type { VersionGroup } from "../Games/VersionGroup"; 2 | import type { Item } from "../Items/Item"; 3 | import type { Move } from "../Moves/Move"; 4 | import type { NamedApiResource } from "../Utility/NamedApiResourceList"; 5 | 6 | export type Machine = { 7 | id: number; 8 | item: NamedApiResource; 9 | move: NamedApiResource; 10 | version_group: NamedApiResource; 11 | }; 12 | -------------------------------------------------------------------------------- /src/interfaces/Utility/ApiResourceList.ts: -------------------------------------------------------------------------------- 1 | import type { Endpoint } from "../../lib/Endpoint"; 2 | 3 | export type Base = { id: number; }; 4 | 5 | export type NamedBase = Base & { name: string; }; 6 | 7 | export type ApiResource = { 8 | endpoint?: Endpoint; 9 | url: string; 10 | }; 11 | 12 | export type ApiResourceList = { 13 | count: number; 14 | next: string; 15 | previous: string; 16 | results: T[]; 17 | }; 18 | -------------------------------------------------------------------------------- /src/interfaces/Pokemon/Gender.ts: -------------------------------------------------------------------------------- 1 | import type { NamedApiResource } from "../Utility/NamedApiResourceList"; 2 | import type { PokemonSpecies } from "./PokemonSpecies"; 3 | 4 | export type Gender = { 5 | id: number; 6 | name: string; 7 | pokemon_species_details: PokemonSpeciesGender[]; 8 | required_for_evolution: NamedApiResource[]; 9 | }; 10 | 11 | export type PokemonSpeciesGender = { 12 | pokemon_species: NamedApiResource; 13 | rate: number; 14 | }; 15 | -------------------------------------------------------------------------------- /src/interfaces/Locations/Location.ts: -------------------------------------------------------------------------------- 1 | import type { GenerationGameIndex, Name } from "../Utility/CommonModels"; 2 | import type { NamedApiResource } from "../Utility/NamedApiResourceList"; 3 | import type { LocationArea } from "./LocationArea"; 4 | import type { Region } from "./Region"; 5 | 6 | export type Location = { 7 | areas: NamedApiResource[]; 8 | game_indices: GenerationGameIndex[]; 9 | id: number; 10 | name: string; 11 | names: Name[]; 12 | region: NamedApiResource; 13 | }; 14 | -------------------------------------------------------------------------------- /src/interfaces/Contests/ContestType.ts: -------------------------------------------------------------------------------- 1 | import type { BerryFlavor } from "../Berries/BerryFlavor"; 2 | import type { Language } from "../Utility/Language"; 3 | import type { NamedApiResource } from "../Utility/NamedApiResourceList"; 4 | 5 | export type ContestType = { 6 | berry_flavor: NamedApiResource; 7 | id: number; 8 | name: string; 9 | names: ContestName[]; 10 | }; 11 | 12 | export type ContestName = { 13 | color: string; 14 | language: NamedApiResource; 15 | name: string; 16 | }; 17 | -------------------------------------------------------------------------------- /src/interfaces/Locations/PalParkArea.ts: -------------------------------------------------------------------------------- 1 | import type { PokemonSpecies } from "../Pokemon/PokemonSpecies"; 2 | import type { Name } from "../Utility/CommonModels"; 3 | import type { NamedApiResource } from "../Utility/NamedApiResourceList"; 4 | 5 | export type PalParkArea = { 6 | id: number; 7 | name: string; 8 | names: Name[]; 9 | pokemon_encounters: PalParkEncounterSpecies[]; 10 | }; 11 | 12 | export type PalParkEncounterSpecies = { 13 | base_socre: number; 14 | pokemon_species: NamedApiResource; 15 | rate: number; 16 | }; 17 | -------------------------------------------------------------------------------- /src/interfaces/Berries/BerryFlavor.ts: -------------------------------------------------------------------------------- 1 | import type { ContestType } from "../Contests/ContestType"; 2 | import type { Name } from "../Utility/CommonModels"; 3 | import type { NamedApiResource } from "../Utility/NamedApiResourceList"; 4 | import type { Berry } from "./Berry"; 5 | 6 | export type BerryFlavor = { 7 | berries: FlavorBerryMap[]; 8 | contest_type: NamedApiResource; 9 | id: number; 10 | name: string; 11 | names: Name[]; 12 | }; 13 | 14 | export type FlavorBerryMap = { 15 | berry: NamedApiResource; 16 | potency: number; 17 | }; 18 | -------------------------------------------------------------------------------- /src/interfaces/Pokemon/GrowthRate.ts: -------------------------------------------------------------------------------- 1 | import type { Description } from "../Utility/CommonModels"; 2 | import type { NamedApiResource } from "../Utility/NamedApiResourceList"; 3 | import type { PokemonSpecies } from "./PokemonSpecies"; 4 | 5 | export type GrowthRate = { 6 | descriptions: Description[]; 7 | formula: string; 8 | id: number; 9 | levels: GrowthRateExperienceLevel[]; 10 | name: string; 11 | pokemon_species: NamedApiResource[]; 12 | }; 13 | 14 | export type GrowthRateExperienceLevel = { 15 | experience: number; 16 | level: number; 17 | }; 18 | -------------------------------------------------------------------------------- /src/interfaces/Pokemon/PokemonShape.ts: -------------------------------------------------------------------------------- 1 | import type { Name } from "../Utility/CommonModels"; 2 | import type { Language } from "../Utility/Language"; 3 | import type { NamedApiResource } from "../Utility/NamedApiResourceList"; 4 | import type { PokemonSpecies } from "./PokemonSpecies"; 5 | 6 | export type PokemonShape = { 7 | awesome_names: AwesomeName[]; 8 | id: number; 9 | name: string; 10 | names: Name[]; 11 | pokemons_species: PokemonSpecies; 12 | }; 13 | 14 | export type AwesomeName = { 15 | awesome_name: string; 16 | language: NamedApiResource; 17 | }; 18 | -------------------------------------------------------------------------------- /eslint.config.js: -------------------------------------------------------------------------------- 1 | import { common, typescript } from "eslint-config-neon"; 2 | import merge from "lodash.merge"; 3 | 4 | /** @type {import('eslint').Linter.Config[]} */ 5 | export default [ 6 | ...[...common, ...typescript].map((config) => merge(config, { 7 | files: ["**/*.ts"], 8 | rules: { 9 | "import-x/no-extraneous-dependencies": "off", 10 | "@stylistic/js/object-property-newline": ["error", { allowAllPropertiesOnSameLine: true }], 11 | }, 12 | languageOptions: { 13 | parserOptions: { 14 | projectService: true, 15 | tsconfigRootDir: import.meta.dirname, 16 | } 17 | } 18 | })) 19 | ]; -------------------------------------------------------------------------------- /src/interfaces/Pokemon/PokeathlonStat.ts: -------------------------------------------------------------------------------- 1 | import type { Name } from "../Utility/CommonModels"; 2 | import type { NamedApiResource } from "../Utility/NamedApiResourceList"; 3 | import type { Nature } from "./Nature"; 4 | 5 | export type PokeathlonStat = { 6 | affecting_natures: NaturePokeathlonStatAffectSets; 7 | id: number; 8 | name: string; 9 | names: Name[]; 10 | }; 11 | 12 | export type NaturePokeathlonStatAffectSets = { 13 | decrease: NaturePokeathlonStatAffect[]; 14 | increase: NaturePokeathlonStatAffect[]; 15 | }; 16 | 17 | export type NaturePokeathlonStatAffect = { 18 | max_change: number; 19 | nature: NamedApiResource; 20 | }; 21 | -------------------------------------------------------------------------------- /src/interfaces/Locations/Region.ts: -------------------------------------------------------------------------------- 1 | import type { Generation } from "../Games/Generation"; 2 | import type { Pokedex } from "../Games/Pokedex"; 3 | import type { VersionGroup } from "../Games/VersionGroup"; 4 | import type { Name } from "../Utility/CommonModels"; 5 | import type { NamedApiResource } from "../Utility/NamedApiResourceList"; 6 | import type { Location } from "./Location"; 7 | 8 | export type Region = { 9 | id: number; 10 | locations: NamedApiResource[]; 11 | main_generation: NamedApiResource; 12 | name: string; 13 | names: Name[]; 14 | pokedexes: NamedApiResource[]; 15 | version_groups: NamedApiResource[]; 16 | }; 17 | -------------------------------------------------------------------------------- /src/interfaces/Games/VersionGroup.ts: -------------------------------------------------------------------------------- 1 | import type { Region } from "../Locations/Region"; 2 | import type { MoveLearnMethod } from "../Moves/MoveLearnMethod"; 3 | import type { NamedApiResource } from "../Utility/NamedApiResourceList"; 4 | import type { Generation } from "./Generation"; 5 | import type { Pokedex } from "./Pokedex"; 6 | import type { Version } from "./Version"; 7 | 8 | export type VersionGroup = { 9 | generation: NamedApiResource; 10 | id: number; 11 | move_learn_methods: NamedApiResource[]; 12 | name: string; 13 | order: number; 14 | pokedexes: NamedApiResource[]; 15 | regions: NamedApiResource[]; 16 | versions: NamedApiResource[]; 17 | }; 18 | -------------------------------------------------------------------------------- /src/interfaces/Games/Pokedex.ts: -------------------------------------------------------------------------------- 1 | import type { Region } from "../Locations/Region"; 2 | import type { PokemonSpecies } from "../Pokemon/PokemonSpecies"; 3 | import type { Description, Name } from "../Utility/CommonModels"; 4 | import type { NamedApiResource } from "../Utility/NamedApiResourceList"; 5 | import type { VersionGroup } from "./VersionGroup"; 6 | 7 | export type Pokedex = { 8 | descriptions: Description[]; 9 | id: number; 10 | is_main_series: boolean; 11 | name: string; 12 | names: Name[]; 13 | pokemon_entries: PokemonEntry[]; 14 | region: NamedApiResource; 15 | version_groups: NamedApiResource[]; 16 | }; 17 | 18 | export type PokemonEntry = { 19 | entry_number: number; 20 | pokemon_species: NamedApiResource; 21 | }; 22 | -------------------------------------------------------------------------------- /src/interfaces/Berries/Berry.ts: -------------------------------------------------------------------------------- 1 | import type { Item } from "../Items/Item"; 2 | import type { Type } from "../Pokemon/Type"; 3 | import type { NamedApiResource } from "../Utility/NamedApiResourceList"; 4 | import type { BerryFirmness } from "./BerryFirmness"; 5 | import type { BerryFlavor } from "./BerryFlavor"; 6 | 7 | export type Berry = { 8 | firmness: NamedApiResource; 9 | flavors: BerryFlavorMap[]; 10 | growth_time: number; 11 | id: number; 12 | item: NamedApiResource; 13 | max_harvest: number; 14 | name: string; 15 | natural_gift_power: number; 16 | natural_gift_type: NamedApiResource; 17 | size: number; 18 | smoothness: number; 19 | soil_dryness: number; 20 | }; 21 | 22 | export type BerryFlavorMap = { 23 | flavor: NamedApiResource; 24 | potency: number; 25 | }; 26 | -------------------------------------------------------------------------------- /src/interfaces/Pokemon/PokemonForm.ts: -------------------------------------------------------------------------------- 1 | import type { VersionGroup } from "../Games/VersionGroup"; 2 | import type { Name } from "../Utility/CommonModels"; 3 | import type { NamedApiResource } from "../Utility/NamedApiResourceList"; 4 | import type { Pokemon } from "./Pokemon"; 5 | 6 | export type PokemonForm = { 7 | form_name: string; 8 | form_names: Name[]; 9 | form_order: number; 10 | id: number; 11 | is_battle_only: boolean; 12 | is_default: boolean; 13 | is_mega: boolean; 14 | name: string; 15 | names: Name[]; 16 | order: number; 17 | pokemon: NamedApiResource; 18 | sprites: PokemonFormSprites; 19 | version_group: NamedApiResource; 20 | }; 21 | 22 | export type PokemonFormSprites = { 23 | back_default: string; 24 | back_shiny: string; 25 | front_default: string; 26 | front_shiny: string; 27 | }; 28 | -------------------------------------------------------------------------------- /src/interfaces/Games/Generation.ts: -------------------------------------------------------------------------------- 1 | import type { Region } from "../Locations/Region"; 2 | import type { Move } from "../Moves/Move"; 3 | import type { Ability } from "../Pokemon/Ability"; 4 | import type { PokemonSpecies } from "../Pokemon/PokemonSpecies"; 5 | import type { Type } from "../Pokemon/Type"; 6 | import type { Name } from "../Utility/CommonModels"; 7 | import type { NamedApiResource } from "../Utility/NamedApiResourceList"; 8 | import type { VersionGroup } from "./VersionGroup"; 9 | 10 | export type Generation = { 11 | abilities: NamedApiResource[]; 12 | id: number; 13 | main_region: NamedApiResource; 14 | moves: NamedApiResource[]; 15 | name: string; 16 | names: Name[]; 17 | pokemon_species: NamedApiResource[]; 18 | types: NamedApiResource[]; 19 | version_groups: NamedApiResource[]; 20 | }; 21 | -------------------------------------------------------------------------------- /src/interfaces/Pokemon/Nature.ts: -------------------------------------------------------------------------------- 1 | import type { BerryFlavor } from "../Berries/BerryFlavor"; 2 | import type { MoveBattleStyle } from "../Moves/MoveBattleStyle"; 3 | import type { Name } from "../Utility/CommonModels"; 4 | import type { NamedApiResource } from "../Utility/NamedApiResourceList"; 5 | import type { PokeathlonStat } from "./PokeathlonStat"; 6 | import type { Stat } from "./Stat"; 7 | 8 | export type Nature = { 9 | decreased_stat: NamedApiResource; 10 | hates_flavor: NamedApiResource; 11 | id: number; 12 | increased_stat: NamedApiResource; 13 | likes_flavor: NamedApiResource; 14 | move_battle_style_preference: MoveBattleStylePreference[]; 15 | name: string; 16 | names: Name[]; 17 | pokeathlon_stat_changes: NatureStatChange[]; 18 | }; 19 | 20 | export type NatureStatChange = { 21 | max_change: number; 22 | pokeathlon_stat: NamedApiResource; 23 | }; 24 | 25 | export type MoveBattleStylePreference = { 26 | high_hp_preference: number; 27 | low_hp_preference: number; 28 | move_battle_style: NamedApiResource; 29 | }; 30 | -------------------------------------------------------------------------------- /src/interfaces/Locations/LocationArea.ts: -------------------------------------------------------------------------------- 1 | import type { EncounterMethod } from "../Encounters/EncounterMethod"; 2 | import type { Version } from "../Games/Version"; 3 | import type { Pokemon } from "../Pokemon/Pokemon"; 4 | import type { Name, VersionEncounterDetail } from "../Utility/CommonModels"; 5 | import type { NamedApiResource } from "../Utility/NamedApiResourceList"; 6 | import type { Location } from "./Location"; 7 | 8 | export type LocationArea = { 9 | encounter_method_rates: EncounterMethodRate[]; 10 | game_index: number; 11 | id: number; 12 | location: NamedApiResource; 13 | name: string; 14 | names: Name[]; 15 | pokemon_encounters: PokemonEncounter[]; 16 | }; 17 | 18 | export type EncounterMethodRate = { 19 | encounter_method: NamedApiResource; 20 | version_details: EncounterVersionDetails[]; 21 | }; 22 | 23 | export type EncounterVersionDetails = { 24 | rate: number; 25 | version_details: NamedApiResource; 26 | }; 27 | 28 | export type PokemonEncounter = { 29 | pokemon: NamedApiResource; 30 | version_details: VersionEncounterDetail[]; 31 | }; 32 | -------------------------------------------------------------------------------- /src/interfaces/Pokemon/Stat.ts: -------------------------------------------------------------------------------- 1 | import type { Move } from "../Moves/Move"; 2 | import type { MoveDamageClass } from "../Moves/MoveDamageClass"; 3 | import type { ApiResource } from "../Utility/ApiResourceList"; 4 | import type { Name } from "../Utility/CommonModels"; 5 | import type { NamedApiResource } from "../Utility/NamedApiResourceList"; 6 | import type { Characteristic } from "./Characteristic"; 7 | import type { Nature } from "./Nature"; 8 | 9 | export type Stat = { 10 | affecting_moves: MoveStatAffectSets; 11 | affecting_natures: NatureStatAffectSets; 12 | characteristics: ApiResource; 13 | id: number; 14 | is_battle_only: boolean; 15 | move_damage_class: NamedApiResource; 16 | name: string; 17 | name_index: number; 18 | names: Name[]; 19 | }; 20 | 21 | export type MoveStatAffectSets = { 22 | decrease: MoveStatAffect[]; 23 | increase: MoveStatAffect[]; 24 | }; 25 | 26 | export type MoveStatAffect = { 27 | change: number; 28 | move: NamedApiResource; 29 | }; 30 | 31 | export type NatureStatAffectSets = { 32 | decrease: Nature; 33 | increase: Nature; 34 | }; 35 | -------------------------------------------------------------------------------- /src/interfaces/Pokemon/Ability.ts: -------------------------------------------------------------------------------- 1 | import type { Generation } from "../Games/Generation"; 2 | import type { VersionGroup } from "../Games/VersionGroup"; 3 | import type { Effect, Name, VerboseEffect } from "../Utility/CommonModels"; 4 | import type { Language } from "../Utility/Language"; 5 | import type { NamedApiResource } from "../Utility/NamedApiResourceList"; 6 | import type { Pokemon } from "./Pokemon"; 7 | 8 | export type Ability = { 9 | effect_changes: AbilityEffectChange[]; 10 | effect_entries: VerboseEffect[]; 11 | flavor_text_entries: AbilityFlavorText[]; 12 | generation: NamedApiResource; 13 | id: number; 14 | is_main_series: boolean; 15 | name: string; 16 | names: Name[]; 17 | pokemon: AbilityPokemon[]; 18 | }; 19 | 20 | export type AbilityEffectChange = { 21 | effect_entries: Effect[]; 22 | version_group: NamedApiResource; 23 | }; 24 | 25 | export type AbilityFlavorText = { 26 | flavor_text: string; 27 | language: NamedApiResource; 28 | version_group: NamedApiResource; 29 | }; 30 | 31 | export type AbilityPokemon = { 32 | is_hidden: boolean; 33 | pokemon: NamedApiResource; 34 | slot: number; 35 | }; 36 | -------------------------------------------------------------------------------- /src/interfaces/Pokemon/Type.ts: -------------------------------------------------------------------------------- 1 | import type { Generation } from "../Games/Generation"; 2 | import type { Move } from "../Moves/Move"; 3 | import type { MoveDamageClass } from "../Moves/MoveDamageClass"; 4 | import type { GenerationGameIndex, Name } from "../Utility/CommonModels"; 5 | import type { NamedApiResource } from "../Utility/NamedApiResourceList"; 6 | import type { Pokemon } from "./Pokemon"; 7 | 8 | export type Type = { 9 | damage_relations: TypeRelations; 10 | game_indices: GenerationGameIndex[]; 11 | generation: NamedApiResource; 12 | id: number; 13 | move_damage_class: NamedApiResource; 14 | moves: NamedApiResource; 15 | name: string; 16 | names: Name[]; 17 | pokemon: TypePokemon[]; 18 | }; 19 | 20 | export type TypePokemon = { 21 | pokemon: NamedApiResource; 22 | slot: number; 23 | }; 24 | 25 | export type TypeRelations = { 26 | double_damage_from: NamedApiResource[]; 27 | double_damage_to: NamedApiResource[]; 28 | half_damage_from: NamedApiResource[]; 29 | half_damage_to: NamedApiResource[]; 30 | no_damage_from: NamedApiResource[]; 31 | no_damage_to: NamedApiResource[]; 32 | }; 33 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "pokeapi-typescript", 3 | "version": "3.0.3", 4 | "description": "Typescript SDK for PokeAPI (https://pokeapi.co)", 5 | "type": "module", 6 | "files": [ 7 | "dist/**/*" 8 | ], 9 | "main": "dist/index.js", 10 | "types": "dist/index.d.ts", 11 | "keywords": [ 12 | "Pokemon", 13 | "PokeAPI", 14 | "Typescript", 15 | "API" 16 | ], 17 | "scripts": { 18 | "build": "tsc -p tsconfig.json", 19 | "clean": "npx rimraf dist", 20 | "lint": "npx eslint src/**/*.ts", 21 | "lint:fix": "npx eslint src/**/*.ts --fix", 22 | "prebuild": "npm run clean", 23 | "preversion": "npm run lint", 24 | "version": "git add -A src", 25 | "postversion": "git push && git push --tags" 26 | }, 27 | "author": "Monbrey", 28 | "license": "MIT", 29 | "repository": { 30 | "type": "git", 31 | "url": "git+https://github.com/Monbrey/pokeapi-typescript.git" 32 | }, 33 | "bugs": { 34 | "url": "https://github.com/Monbrey/pokeapi-typescript/issues" 35 | }, 36 | "homepage": "https://github.com/Monbrey/pokeapi-typescript#readme", 37 | "devDependencies": { 38 | "@eslint/js": "^9.22.0", 39 | "@types/node": "^22.13.10", 40 | "eslint": "^9.22.0", 41 | "eslint-config-neon": "^0.2.4", 42 | "typescript": "^5.8.2", 43 | "typescript-eslint": "^8.26.1" 44 | }, 45 | "dependencies": { 46 | "@discordjs/collection": "^2.1.1", 47 | "pokeapi-typescript": "^3.0.0" 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/interfaces/Evolution/EvolutionChain.ts: -------------------------------------------------------------------------------- 1 | import type { Item } from "../Items/Item"; 2 | import type { Location } from "../Locations/Location"; 3 | import type { Move } from "../Moves/Move"; 4 | import type { PokemonSpecies } from "../Pokemon/PokemonSpecies"; 5 | import type { Type } from "../Pokemon/Type"; 6 | import type { NamedApiResource } from "../Utility/NamedApiResourceList"; 7 | import type { EvolutionTrigger } from "./EvolutionTrigger"; 8 | 9 | export type EvolutionChain = { 10 | baby_trigger_item: NamedApiResource; 11 | chain: ChainLink; 12 | id: number; 13 | }; 14 | 15 | export type ChainLink = { 16 | evolution_details: EvolutionDetail[]; 17 | evolves_to: ChainLink[]; 18 | is_baby: boolean; 19 | species: NamedApiResource; 20 | }; 21 | 22 | export type EvolutionDetail = { 23 | gender: number; 24 | held_item: NamedApiResource; 25 | item: NamedApiResource; 26 | known_move_type: NamedApiResource; 27 | location: NamedApiResource; 28 | min_affection: number; 29 | min_beauty: number; 30 | min_happiness: number; 31 | min_level: number; 32 | move: NamedApiResource; 33 | needs_overworld_rain: boolean; 34 | party_species: NamedApiResource; 35 | party_type: NamedApiResource; 36 | relative_physical_stats: number; 37 | time_of_day: string; 38 | trade_species: NamedApiResource; 39 | trigger: NamedApiResource; 40 | turn_upside_down: boolean; 41 | }; 42 | -------------------------------------------------------------------------------- /src/interfaces/Items/Item.ts: -------------------------------------------------------------------------------- 1 | import type { EvolutionChain } from "../Evolution/EvolutionChain"; 2 | import type { Version } from "../Games/Version"; 3 | import type { ApiResource } from "../Utility/ApiResourceList"; 4 | import type { 5 | GenerationGameIndex, 6 | MachineVersionDetail, 7 | Name, 8 | VerboseEffect, 9 | VersionGroupFlavorText, 10 | } from "../Utility/CommonModels"; 11 | import type { NamedApiResource } from "../Utility/NamedApiResourceList"; 12 | import type { ItemAttribute } from "./ItemAttribute"; 13 | import type { ItemCategory } from "./ItemCategory"; 14 | import type { ItemFlingEffect } from "./ItemFlingEffect"; 15 | 16 | export type Item = { 17 | attributes: NamedApiResource[]; 18 | baby_trigger_for: ApiResource; 19 | category: ItemCategory; 20 | cost: number; 21 | effect_entries: VerboseEffect[]; 22 | flavor_text_entries: VersionGroupFlavorText[]; 23 | fling_effect: NamedApiResource; 24 | fling_power: number; 25 | game_indices: GenerationGameIndex[]; 26 | held_by_pokemon: ItemHolderPokemon[]; 27 | id: number; 28 | machines: MachineVersionDetail[]; 29 | name: string; 30 | names: Name[]; 31 | sprites: ItemSprites; 32 | }; 33 | 34 | export type ItemSprites = { default: string; }; 35 | 36 | export type ItemHolderPokemon = { 37 | pokemon: string; 38 | version_details: ItemHolderPokemonVersionDetail[]; 39 | }; 40 | 41 | export type ItemHolderPokemonVersionDetail = { 42 | rarity: string; 43 | version: NamedApiResource; 44 | }; 45 | -------------------------------------------------------------------------------- /src/interfaces/Utility/CommonModels.ts: -------------------------------------------------------------------------------- 1 | import type { EncounterConditionValue } from "../Encounters/EncounterConditionValue"; 2 | import type { EncounterMethod } from "../Encounters/EncounterMethod"; 3 | import type { Generation } from "../Games/Generation"; 4 | import type { Version } from "../Games/Version"; 5 | import type { VersionGroup } from "../Games/VersionGroup"; 6 | import type { Machine } from "../Machines/Machine"; 7 | import type { ApiResource } from "./ApiResourceList"; 8 | import type { Language } from "./Language"; 9 | import type { NamedApiResource } from "./NamedApiResourceList"; 10 | 11 | export type CacheableResource = { 12 | id: number; 13 | name: string; 14 | }; 15 | 16 | export type Description = { 17 | description: string; 18 | language: NamedApiResource; 19 | }; 20 | 21 | export type Effect = { 22 | effet: string; 23 | language: NamedApiResource; 24 | }; 25 | 26 | export type Encounter = { 27 | chance: number; 28 | condition_values: NamedApiResource[]; 29 | max_level: number; 30 | method: NamedApiResource; 31 | min_level: number; 32 | }; 33 | 34 | export type FlavorText = { 35 | flavor_text: string; 36 | language: NamedApiResource; 37 | version: NamedApiResource; 38 | }; 39 | 40 | export type GenerationGameIndex = { 41 | game_index: number; 42 | generation: NamedApiResource; 43 | }; 44 | 45 | export type MachineVersionDetail = { 46 | machine: ApiResource; 47 | version_group: NamedApiResource; 48 | }; 49 | 50 | export type Name = { 51 | language: NamedApiResource; 52 | name: string; 53 | }; 54 | 55 | export type VerboseEffect = { 56 | effect: string; 57 | language: NamedApiResource; 58 | short_effect: string; 59 | }; 60 | 61 | export type VersionEncounterDetail = { 62 | encounter_details: Encounter[]; 63 | max_chance: number; 64 | version: NamedApiResource; 65 | }; 66 | 67 | export type VersionGameIndex = { 68 | game_index: number; 69 | version: NamedApiResource; 70 | }; 71 | 72 | export type VersionGroupFlavorText = { 73 | language: NamedApiResource; 74 | text: string; 75 | version_group: NamedApiResource; 76 | }; 77 | -------------------------------------------------------------------------------- /src/interfaces/Pokemon/PokemonSpecies.ts: -------------------------------------------------------------------------------- 1 | import type { EvolutionChain } from "../Evolution/EvolutionChain"; 2 | import type { Generation } from "../Games/Generation"; 3 | import type { Pokedex } from "../Games/Pokedex"; 4 | import type { PalParkArea } from "../Locations/PalParkArea"; 5 | import type { ApiResource } from "../Utility/ApiResourceList"; 6 | import type { Description, FlavorText, Name } from "../Utility/CommonModels"; 7 | import type { Language } from "../Utility/Language"; 8 | import type { NamedApiResource } from "../Utility/NamedApiResourceList"; 9 | import type { EggGroup } from "./EggGroup"; 10 | import type { GrowthRate } from "./GrowthRate"; 11 | import type { Pokemon } from "./Pokemon"; 12 | import type { PokemonColor } from "./PokemonColor"; 13 | import type { PokemonHabitat } from "./PokemonHabitat"; 14 | import type { PokemonShape } from "./PokemonShape"; 15 | 16 | export type PokemonSpecies = { 17 | base_happiness: number; 18 | capture_rate: number; 19 | color: NamedApiResource; 20 | egg_groups: NamedApiResource[]; 21 | evolution_chain: ApiResource; 22 | evolves_from_species: NamedApiResource; 23 | flavor_text_entries: FlavorText[]; 24 | form_descriptions: Description[]; 25 | forms_switchable: boolean; 26 | gender_rate: number; 27 | genera: Genus[]; 28 | generation: NamedApiResource; 29 | growth_rate: NamedApiResource; 30 | habitat: NamedApiResource; 31 | has_gender_differences: boolean; 32 | hatch_counter: number; 33 | id: number; 34 | is_baby: boolean; 35 | name: string; 36 | names: Name[]; 37 | order: number; 38 | pal_park_encounters: PalParkEnounterArea[]; 39 | pokedex_numbers: PokemonSpeciesDexEntry[]; 40 | shape: NamedApiResource; 41 | varieties: PokemonSpeciesVariety[]; 42 | }; 43 | 44 | export type Genus = { 45 | genus: string; 46 | language: NamedApiResource; 47 | }; 48 | 49 | export type PokemonSpeciesDexEntry = { 50 | entry_number: number; 51 | pokedex: NamedApiResource; 52 | }; 53 | 54 | export type PalParkEnounterArea = { 55 | area: NamedApiResource; 56 | base_score: number; 57 | rate: number; 58 | }; 59 | 60 | export type PokemonSpeciesVariety = { 61 | is_default: boolean; 62 | pokemon: NamedApiResource; 63 | }; 64 | -------------------------------------------------------------------------------- /src/lib/Endpoint.ts: -------------------------------------------------------------------------------- 1 | import { Collection } from "@discordjs/collection"; 2 | import type { ApiResourceList, Base } from "../interfaces/Utility/ApiResourceList.js"; 3 | 4 | type EndpointParam = number; 5 | 6 | const BASE_URI = "https://pokeapi.co/api/v2"; 7 | 8 | class Endpoint { 9 | protected resource: string; 10 | 11 | protected _list?: ApiResourceList; 12 | 13 | protected cache: Collection; 14 | 15 | public constructor(resource: string) { 16 | this.resource = resource; 17 | this.cache = new Collection(); 18 | } 19 | 20 | public get(param: EndpointParam): T | undefined { 21 | return this.cache.get(param); 22 | } 23 | 24 | public async resolve(param: EndpointParam): Promise { 25 | return this.get(param) ?? this.fetch(param); 26 | } 27 | 28 | public async fetch(param: EndpointParam, cache: boolean = true): Promise { 29 | const data = await fetch(`${BASE_URI}/${this.resource}/${param}`).then(async (res) => res.json()); 30 | 31 | if (!this._isT(data)) { 32 | throw new Error(`Invalid data received from ${BASE_URI}/${this.resource}/${param}`); 33 | } 34 | 35 | this._cache(data); 36 | return data; 37 | } 38 | 39 | public async list(limit: number = 20, offset: number = 0): Promise> { 40 | if (this._list) { 41 | const results = this._list.results.slice(offset, limit); 42 | const { count, next, previous } = this._list; 43 | return { count, next, previous, results }; 44 | } 45 | 46 | const params = new URLSearchParams({ limit: `${limit}`, offset: `${offset}` }); 47 | const data = await fetch(`${BASE_URI}/${this.resource}?${params}`).then(async (res) => res.json()); 48 | 49 | if (!this._isListT(data)) { 50 | throw new Error(`Invalid data received from ${BASE_URI}/${this.resource}?${params}`); 51 | } 52 | 53 | return data; 54 | } 55 | 56 | public async listAll(cache: boolean = true): Promise> { 57 | if (this._list) { 58 | return this._list; 59 | } 60 | 61 | const first = await fetch(`${BASE_URI}/${this.resource}?limit=1`).then(async (res) => res.json()); 62 | if (!this._isListT(first)) { 63 | throw new Error(`Invalid data received from ${BASE_URI}/${this.resource}?limit=1`); 64 | } 65 | 66 | const data = await fetch(`${BASE_URI}/${this.resource}?limit=${first.count}`).then(async (res) => res.json()); 67 | if (!this._isListT(data)) { 68 | throw new Error(`Invalid data received from ${BASE_URI}/${this.resource}?limit=${first.count}`); 69 | } 70 | 71 | if (cache) { 72 | this._list = data; 73 | } 74 | 75 | return data; 76 | } 77 | 78 | protected _cache(data: T) { 79 | this.cache.set(data.id, data); 80 | } 81 | 82 | protected _isT(data: any): data is T { 83 | return "id" in data; 84 | } 85 | 86 | protected _isListT(data: any): data is ApiResourceList { 87 | return Array.isArray(data) && this._isT(data[0]); 88 | } 89 | } 90 | 91 | export { Endpoint, type EndpointParam }; 92 | -------------------------------------------------------------------------------- /src/interfaces/Moves/Move.ts: -------------------------------------------------------------------------------- 1 | import type { ContestEffect } from "../Contests/ContestEffect"; 2 | import type { ContestType } from "../Contests/ContestType"; 3 | import type { SuperContestEffect } from "../Contests/SuperContestEffect"; 4 | import type { Generation } from "../Games/Generation"; 5 | import type { VersionGroup } from "../Games/VersionGroup"; 6 | import type { AbilityEffectChange } from "../Pokemon/Ability"; 7 | import type { Stat } from "../Pokemon/Stat"; 8 | import type { Type } from "../Pokemon/Type"; 9 | import type { ApiResource } from "../Utility/ApiResourceList"; 10 | import type { MachineVersionDetail, Name, VerboseEffect } from "../Utility/CommonModels"; 11 | import type { Language } from "../Utility/Language"; 12 | import type { NamedApiResource } from "../Utility/NamedApiResourceList"; 13 | import type { MoveAilment } from "./MoveAilment"; 14 | import type { MoveCategory } from "./MoveCategory"; 15 | import type { MoveDamageClass } from "./MoveDamageClass"; 16 | import type { MoveTarget } from "./MoveTarget"; 17 | 18 | export type Move = { 19 | accuracy: number; 20 | contest_combos: ContestComboSets; 21 | contest_effect: ApiResource; 22 | contest_type: NamedApiResource; 23 | damage_class: NamedApiResource; 24 | effect_chance: number; 25 | effect_changes: AbilityEffectChange[]; 26 | effect_entries: VerboseEffect[]; 27 | flavor_text_entries: MoveFlavorText[]; 28 | generation: NamedApiResource; 29 | id: number; 30 | machines: MachineVersionDetail[]; 31 | meta: MoveMetaData; 32 | name: string; 33 | names: Name[]; 34 | past_values: PastMoveStatValues[]; 35 | power: number; 36 | pp: number; 37 | priority: number; 38 | stat_changes: MoveStatChange[]; 39 | super_contest_effect: ApiResource; 40 | target: NamedApiResource; 41 | type: NamedApiResource; 42 | }; 43 | 44 | export type ContestComboSets = { 45 | normal: ContestComboDetail; 46 | super: ContestComboDetail; 47 | }; 48 | 49 | export type ContestComboDetail = { 50 | use_after: NamedApiResource[]; 51 | use_before: NamedApiResource[]; 52 | }; 53 | 54 | export type MoveFlavorText = { 55 | flavor_text: string; 56 | language: NamedApiResource; 57 | version_group: NamedApiResource; 58 | }; 59 | 60 | export type MoveMetaData = { 61 | ailment: NamedApiResource; 62 | ailment_chance: number; 63 | category: NamedApiResource; 64 | crit_rate: number; 65 | drain: number; 66 | flinch_chance: number; 67 | healing: number; 68 | max_hits: number; 69 | max_turns: number; 70 | min_hits: number; 71 | min_turns: number; 72 | stat_chance: number; 73 | }; 74 | 75 | export type MoveStatChange = { 76 | change: number; 77 | stat: NamedApiResource; 78 | }; 79 | 80 | export type PastMoveStatValues = { 81 | accuracy: number; 82 | effect_chance: number; 83 | effect_entries: VerboseEffect[]; 84 | power: number; 85 | pp: number; 86 | type: NamedApiResource; 87 | version_group: NamedApiResource; 88 | }; 89 | -------------------------------------------------------------------------------- /src/lib/NamedEndpoint.ts: -------------------------------------------------------------------------------- 1 | import type { NamedBase } from "../interfaces/Utility/ApiResourceList.js"; 2 | import type { NamedApiResourceList } from "../interfaces/Utility/NamedApiResourceList.js"; 3 | import { Endpoint, type EndpointParam } from "./Endpoint.js"; 4 | 5 | export type NamedEndpointParam = EndpointParam | string; 6 | 7 | const BASE_URI = "https://pokeapi.co/api/v2"; 8 | 9 | export class NamedEndpoint extends Endpoint { 10 | declare protected _list?: NamedApiResourceList; 11 | 12 | private readonly _nameMap: Map; 13 | 14 | public constructor(resource: string) { 15 | super(resource); 16 | this._nameMap = new Map(); 17 | } 18 | 19 | public get(param: NamedEndpointParam): T | undefined { 20 | return typeof param === "number" ? this.cache.get(param) : this.cache.get(this._nameMap.get(param.toLowerCase()) ?? 0); 21 | } 22 | 23 | public async fetch(param: NamedEndpointParam, cache: boolean = true): Promise { 24 | const _param = typeof param === "string" ? param.toLowerCase() : param; 25 | 26 | const data = await fetch(`${BASE_URI}/${this.resource}/${_param}`).then(async (res) => res.json()); 27 | 28 | if (!this._isT(data)) { 29 | throw new Error(`Invalid data received from ${BASE_URI}/${this.resource}/${_param}`); 30 | } 31 | 32 | this._cache(data); 33 | return data; 34 | } 35 | 36 | public async resolve(param: NamedEndpointParam): Promise { 37 | return this.get(param) ?? this.fetch(param); 38 | } 39 | 40 | public async list(limit: number = 20, offset: number = 0): Promise> { 41 | if (this._list) { 42 | const results = this._list.results.slice(offset, limit); 43 | const { count, next, previous } = this._list; 44 | return { count, next, previous, results }; 45 | } 46 | 47 | const params = new URLSearchParams({ limit: `${limit}`, offset: `${offset}` }); 48 | const data = await fetch(`${BASE_URI}/${this.resource}?${params}`).then(async (res) => res.json()); 49 | 50 | if (!this._isListT(data)) { 51 | throw new Error(`Invalid data received from ${BASE_URI}/${this.resource}?${params}`); 52 | } 53 | 54 | return data; 55 | } 56 | 57 | public async listAll(cache: boolean = true): Promise> { 58 | if (this._list) { 59 | return this._list; 60 | } 61 | 62 | const first = await fetch(`${BASE_URI}/${this.resource}?limit=1`).then(async (res) => res.json()); 63 | if (!this._isListT(first)) { 64 | throw new Error(`Invalid data received from ${BASE_URI}/${this.resource}?limit=1`); 65 | } 66 | 67 | const data = await fetch(`${BASE_URI}/${this.resource}?limit=${first.count}`).then(async (res) => res.json()); 68 | if (!this._isListT(data)) { 69 | throw new Error(`Invalid data received from ${BASE_URI}/${this.resource}?limit=${first.count}`); 70 | } 71 | 72 | if (cache) { 73 | this._list = data; 74 | } 75 | 76 | return data; 77 | } 78 | 79 | protected _cache(data: T) { 80 | this.cache.set(data.id, data); 81 | this._nameMap.set(data.name, data.id); 82 | } 83 | 84 | protected _isT(data: any): data is T { 85 | return "id" in data && "name" in data; 86 | } 87 | 88 | protected _isListT(data: any): data is NamedApiResourceList { 89 | return Array.isArray(data) && this._isT(data[0]); 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # pokeapi-typescript 2 | 3 | ## About 4 | 5 | pokeapi-typescript is a fully-typed SDK for the [PokeAPI](https://pokeapi.co) using Promises, featuring an easy to manage cache which utilises [Collections](https://github.com/discordjs/collection) 6 | 7 | ## Installation 8 | 9 | via yarn: `yarn add pokeapi-typescript` 10 | 11 | via npm: `npm install pokeapi-typescript` 12 | 13 | ## Getting Started 14 | 15 | To start using the PokeAPI, import the module. All available endpoints are mounted as static properties of the module. 16 | ```js 17 | // ES6 imports 18 | import { PokeAPI } from "pokeapi-typescript"; 19 | ``` 20 | 21 | ### Endpoints 22 | 23 | Every endpoint documented in the [PokeAPI Docs](https://pokeapi.co/docs/v2.html) is available. By default, any data that is fetched will be cached in-memory. 24 | 25 | ### .resolve() 26 | 27 | `PokeAPI..resolve()` retrieves a resource, first checking the internal cache to see if it is available. If no cached resource exists, it will be fetched via the API. 28 | 29 | #### By ID 30 | ```js 31 | // Using .then() 32 | PokeAPI.Pokemon.resolve(25).then(result => console.log(result)); 33 | 34 | // Using async/await 35 | const result = await PokeAPI.Pokemon.resolve(25); 36 | ``` 37 | 38 | #### By Name 39 | ```js 40 | // Using.then() 41 | PokeAPI.Pokemon.resolve("pikachu").then(result => console.log(result)); 42 | 43 | // Using async/await 44 | const result = await PokeAPI.Pokemon.resolve("pikachu"); 45 | ``` 46 | 47 | ### .fetch() 48 | 49 | `PokeAPI..fetch()` will always retrieve a resource via the API, updating any cached resources in the process. 50 | 51 | #### By ID 52 | ```js 53 | // Using .then() 54 | PokeAPI.Pokemon.fetch(25).then(result => console.log(result)); 55 | 56 | // Using async/await 57 | const result = await PokeAPI.Pokemon.fetch(25); 58 | ``` 59 | 60 | #### By Name 61 | ```js 62 | // Using.then() 63 | PokeAPI.Pokemon.fetch("pikachu").then(result => console.log(result)); 64 | 65 | // Using async/await 66 | const result = await PokeAPI.Pokemon.fetch("pikachu"); 67 | ``` 68 | 69 | ### .get() 70 | 71 | `PokeAPI..get()` will always retrieve a cached resource, returning null if one could not be found. `.get()` is synchronous and does not return a Promise. 72 | 73 | #### By ID 74 | ```js 75 | const result = PokeAPI.Pokemon.get(25); 76 | ``` 77 | 78 | #### By Name 79 | ```js 80 | const result = PokeAPI.Pokemon.get("pikachu"); 81 | ``` 82 | 83 | ### .list() 84 | 85 | `PokeAPI..list()` retrieves the [IApiResourceList](https://pokeapi.co/docs/v2.html#un-named) or [INamedApiResourceList](https://pokeapi.co/docs/v2.html#named) for an endpoint. 86 | 87 | `list()` accepts two parameters for pagination 88 | - `limit` - Number of results to list. Default 20 89 | - `offset` - Index of result to start listing from. Default 0 90 | 91 | ```js 92 | // Fetch 1000 Pokemon (all) in a NamedApiResourceList 93 | const resourceList = await PokeAPI.Pokemon.list(1000, 0); 94 | ``` 95 | `resourceList.results` will contain an array of `IApiResource` or `INamedApiResource` objects depending on the type of list. 96 | 97 | ### .listAll() 98 | 99 | `PokeAPI..listAll()` functions like the above, but will return the complete list for an endpoint. This is done by making two API calls. 100 | ```js 101 | // Fetch 1000 Pokemon (all) in a NamedApiResourceList 102 | const completeResourceList = await PokeAPI.Pokemon.listAll(); 103 | ``` 104 | 105 | ## Endpoint List 106 | 107 | #### Berries 108 | 109 | - Berry 110 | - BerryFirmness 111 | - BerryFlavors 112 | 113 | #### Contests 114 | 115 | - ContestType 116 | - ContestEffect 117 | - SuperContestEffect 118 | 119 | #### Encounters 120 | 121 | - EncounterMethod 122 | - EncounterCondition 123 | - EncounterConditionValue 124 | 125 | #### Evolution 126 | 127 | - EvolutionChain 128 | - EvolutionTrigger 129 | 130 | #### Games 131 | 132 | - Generation 133 | - Pokedex 134 | - Version 135 | - VersionGroup 136 | 137 | #### Items 138 | 139 | - Item 140 | - ItemAttribute 141 | - ItemCategory 142 | - ItemFlingEffect 143 | - ItemPocket 144 | 145 | ##### Locations 146 | 147 | - Location 148 | - LocationArea 149 | - PalParkArea 150 | - Region 151 | 152 | #### Machines 153 | 154 | - Machine 155 | 156 | #### Moves 157 | 158 | - Move 159 | - MoveAilment 160 | - MoveBattleStyle 161 | - MoveCategory 162 | - MoveDamageClass 163 | - MoveLearnMethod 164 | - MoveTarget 165 | 166 | #### Pokemon 167 | 168 | - Ability 169 | - Characteristic 170 | - EggGroup 171 | - Gender 172 | - GrowthRate 173 | - Nature 174 | - PokeathlonStat 175 | - Pokemon 176 | - PokemonColor 177 | - PokemonForm 178 | - PokemonHabitat 179 | - PokemonShape 180 | - PokemonSpecies 181 | - Stat 182 | - Type 183 | 184 | #### Utility 185 | 186 | - Language -------------------------------------------------------------------------------- /src/interfaces/Pokemon/Pokemon.ts: -------------------------------------------------------------------------------- 1 | import type { Generation } from "../Games/Generation.js"; 2 | import type { Version } from "../Games/Version"; 3 | import type { VersionGroup } from "../Games/VersionGroup"; 4 | import type { Item } from "../Items/Item"; 5 | import type { Location } from "../Locations/Location"; 6 | import type { Move } from "../Moves/Move"; 7 | import type { MoveLearnMethod } from "../Moves/MoveLearnMethod"; 8 | import type { VersionEncounterDetail, VersionGameIndex } from "../Utility/CommonModels"; 9 | import type { NamedApiResource } from "../Utility/NamedApiResourceList"; 10 | import type { Ability } from "./Ability"; 11 | import type { PokemonForm } from "./PokemonForm"; 12 | import type { PokemonSpecies } from "./PokemonSpecies"; 13 | import type { Stat } from "./Stat"; 14 | import type { Type } from "./Type"; 15 | 16 | export type Pokemon = { 17 | abilities: PokemonAbility[]; 18 | base_experience: number; 19 | forms: NamedApiResource[]; 20 | game_indices: VersionGameIndex[]; 21 | height: number; 22 | held_items: PokemonHeldItem[]; 23 | id: number; 24 | is_default: boolean; 25 | location_area_encounters: string; 26 | moves: PokemonMove[]; 27 | name: string; 28 | order: number; 29 | past_types: PokemonTypePast[]; 30 | species: NamedApiResource; 31 | sprites: PokemonSprites; 32 | stats: PokemonStat[]; 33 | types: PokemonType[]; 34 | weight: number; 35 | }; 36 | 37 | export type PokemonAbility = { 38 | ability: NamedApiResource; 39 | is_hidden: true; 40 | slot: number; 41 | }; 42 | 43 | export type PokemonType = { 44 | slot: number; 45 | type: NamedApiResource; 46 | }; 47 | 48 | export type PokemonFormType = { 49 | slot: number; 50 | type: NamedApiResource; 51 | }; 52 | 53 | export type PokemonTypePast = { 54 | generation: NamedApiResource; 55 | type: PokemonType[]; 56 | }; 57 | 58 | export type PokemonHeldItem = { 59 | item: NamedApiResource; 60 | version_details: PokemonHeldItemVersion[]; 61 | }; 62 | 63 | export type PokemonHeldItemVersion = { 64 | rarity: number; 65 | version: NamedApiResource; 66 | }; 67 | 68 | export type PokemonMove = { 69 | move: NamedApiResource; 70 | version_group_details: PokemonMoveVersion[]; 71 | }; 72 | 73 | export type PokemonMoveVersion = { 74 | level_learned_at: number; 75 | move_learn_method: NamedApiResource; 76 | version_group: NamedApiResource; 77 | }; 78 | 79 | export type PokemonStat = { 80 | base_stat: number; 81 | effort: number; 82 | stat: NamedApiResource; 83 | }; 84 | 85 | export type PokemonSprites = { 86 | back_default: string; 87 | back_female: string; 88 | back_shiny: string; 89 | back_shiny_female: string; 90 | front_default: string; 91 | front_female: string; 92 | front_shiny: string; 93 | front_shiny_female: string; 94 | other: PokemonSpriteOther; 95 | versions: PokemonSpriteVersion; 96 | }; 97 | 98 | type SpriteVariant = { 99 | back_default: string | null; 100 | back_female: string | null; 101 | back_gray: string | null; 102 | back_shiny: string | null; 103 | back_shiny_female: string | null; 104 | front_default: string | null; 105 | front_female: string | null; 106 | front_gray: string | null; 107 | front_shiny: string | null; 108 | front_shiny_female: string | null; 109 | }; 110 | 111 | export type PokemonSpriteOther = { 112 | dream_world: Pick; 113 | "official-artwork": { front_default: string; }; 114 | }; 115 | 116 | type Generation1Sprite = { 117 | "red-blue": Pick; 118 | yellow: Pick; 119 | }; 120 | 121 | type Generation2Sprite = { 122 | crystal: Pick; 123 | gold: Pick; 124 | silver: Pick; 125 | }; 126 | 127 | type Generation3Sprite = { 128 | emerald: Pick; 129 | "firered-leafgreen": Pick; 130 | "ruby-sapphire": Pick; 131 | }; 132 | 133 | type Generation4Sprite = { 134 | "diamond-pearl": Pick< 135 | SpriteVariant, 136 | "back_default" | "back_female" | "back_shiny_female" | "back_shiny" | "front_default" | "front_female" | "front_shiny_female" | "front_shiny" 137 | >; 138 | "heartgold-soulsilver": Pick< 139 | SpriteVariant, 140 | "back_default" | "back_female" | "back_shiny_female" | "back_shiny" | "front_default" | "front_female" | "front_shiny_female" | "front_shiny" 141 | >; 142 | platinum: Pick< 143 | SpriteVariant, 144 | "back_default" | "back_female" | "back_shiny_female" | "back_shiny" | "front_default" | "front_female" | "front_shiny_female" | "front_shiny" 145 | >; 146 | }; 147 | 148 | type BlackWhiteSprite = Pick< 149 | SpriteVariant, 150 | "back_default" | "back_female" | "back_shiny_female" | "back_shiny" | "front_default" | "front_female" | "front_shiny_female" | "front_shiny" 151 | >; 152 | 153 | type Generation5Sprite = { "black-white": BlackWhiteSprite & { animated: BlackWhiteSprite; }; }; 154 | 155 | type Generation6Sprite = { 156 | "omegaruby-alphasapphire": Pick< 157 | SpriteVariant, 158 | "front_default" | "front_female" | "front_shiny_female" | "front_shiny" 159 | >; 160 | "x-y": Pick< 161 | SpriteVariant, 162 | "front_default" | "front_female" | "front_shiny_female" | "front_shiny" 163 | >; 164 | }; 165 | 166 | type Generation7Sprite = { 167 | icons: Pick; 168 | "ultra-sun-ultra-moon": Pick< 169 | SpriteVariant, 170 | "front_default" | "front_female" | "front_shiny_female" | "front_shiny" 171 | >; 172 | }; 173 | 174 | type Generation8Sprite = { icons: Pick; }; 175 | 176 | type PokemonSpriteVersion = { 177 | "generation-i": Generation1Sprite; 178 | "generation-ii": Generation2Sprite; 179 | "generation-iii": Generation3Sprite; 180 | "generation-iv": Generation4Sprite; 181 | "generation-v": Generation5Sprite; 182 | "generation-vi": Generation6Sprite; 183 | "generation-vii": Generation7Sprite; 184 | "generation-viii": Generation8Sprite; 185 | }; 186 | 187 | export type LocationAreaEncounter = { 188 | location_area: NamedApiResource; 189 | version_details: VersionEncounterDetail[]; 190 | }; 191 | -------------------------------------------------------------------------------- /src/index.ts: -------------------------------------------------------------------------------- 1 | import type { Berry } from "./interfaces/Berries/Berry"; 2 | import type { BerryFirmness } from "./interfaces/Berries/BerryFirmness"; 3 | import type { BerryFlavor } from "./interfaces/Berries/BerryFlavor"; 4 | import type { ContestEffect } from "./interfaces/Contests/ContestEffect"; 5 | import type { ContestType } from "./interfaces/Contests/ContestType"; 6 | import type { SuperContestEffect } from "./interfaces/Contests/SuperContestEffect"; 7 | import type { EncounterCondition } from "./interfaces/Encounters/EncounterCondition"; 8 | import type { EncounterConditionValue } from "./interfaces/Encounters/EncounterConditionValue"; 9 | import type { EncounterMethod } from "./interfaces/Encounters/EncounterMethod"; 10 | import type { EvolutionChain } from "./interfaces/Evolution/EvolutionChain"; 11 | import type { EvolutionTrigger } from "./interfaces/Evolution/EvolutionTrigger"; 12 | import type { Generation } from "./interfaces/Games/Generation"; 13 | import type { Pokedex } from "./interfaces/Games/Pokedex"; 14 | import type { Version } from "./interfaces/Games/Version"; 15 | import type { VersionGroup } from "./interfaces/Games/VersionGroup"; 16 | import type { Item } from "./interfaces/Items/Item"; 17 | import type { ItemAttribute } from "./interfaces/Items/ItemAttribute"; 18 | import type { ItemCategory } from "./interfaces/Items/ItemCategory"; 19 | import type { ItemFlingEffect } from "./interfaces/Items/ItemFlingEffect"; 20 | import type { ItemPocket } from "./interfaces/Items/ItemPocket"; 21 | import type { Location } from "./interfaces/Locations/Location"; 22 | import type { LocationArea } from "./interfaces/Locations/LocationArea"; 23 | import type { PalParkArea } from "./interfaces/Locations/PalParkArea"; 24 | import type { Region } from "./interfaces/Locations/Region"; 25 | import type { Machine } from "./interfaces/Machines/Machine"; 26 | import type { Move } from "./interfaces/Moves/Move"; 27 | import type { MoveAilment } from "./interfaces/Moves/MoveAilment"; 28 | import type { MoveBattleStyle } from "./interfaces/Moves/MoveBattleStyle"; 29 | import type { MoveCategory } from "./interfaces/Moves/MoveCategory"; 30 | import type { MoveDamageClass } from "./interfaces/Moves/MoveDamageClass"; 31 | import type { MoveLearnMethod } from "./interfaces/Moves/MoveLearnMethod"; 32 | import type { MoveTarget } from "./interfaces/Moves/MoveTarget"; 33 | import type { Ability } from "./interfaces/Pokemon/Ability"; 34 | import type { Characteristic } from "./interfaces/Pokemon/Characteristic"; 35 | import type { EggGroup } from "./interfaces/Pokemon/EggGroup"; 36 | import type { Gender } from "./interfaces/Pokemon/Gender"; 37 | import type { GrowthRate } from "./interfaces/Pokemon/GrowthRate"; 38 | import type { Nature } from "./interfaces/Pokemon/Nature"; 39 | import type { PokeathlonStat } from "./interfaces/Pokemon/PokeathlonStat"; 40 | import type { Pokemon } from "./interfaces/Pokemon/Pokemon"; 41 | import type { PokemonColor } from "./interfaces/Pokemon/PokemonColor"; 42 | import type { PokemonForm } from "./interfaces/Pokemon/PokemonForm"; 43 | import type { PokemonHabitat } from "./interfaces/Pokemon/PokemonHabitat"; 44 | import type { PokemonShape } from "./interfaces/Pokemon/PokemonShape"; 45 | import type { PokemonSpecies } from "./interfaces/Pokemon/PokemonSpecies"; 46 | import type { Stat } from "./interfaces/Pokemon/Stat"; 47 | import type { Type } from "./interfaces/Pokemon/Type"; 48 | import type { Language } from "./interfaces/Utility/Language"; 49 | import { Endpoint } from "./lib/Endpoint.js"; 50 | import { NamedEndpoint } from "./lib/NamedEndpoint.js"; 51 | 52 | export type * from "./interfaces/Berries/Berry"; 53 | export type * from "./interfaces/Berries/BerryFirmness"; 54 | export type * from "./interfaces/Berries/BerryFlavor"; 55 | export type * from "./interfaces/Contests/ContestEffect"; 56 | export type * from "./interfaces/Contests/ContestType"; 57 | export type * from "./interfaces/Contests/SuperContestEffect"; 58 | export type * from "./interfaces/Encounters/EncounterCondition"; 59 | export type * from "./interfaces/Encounters/EncounterConditionValue"; 60 | export type * from "./interfaces/Encounters/EncounterMethod"; 61 | export type * from "./interfaces/Evolution/EvolutionChain"; 62 | export type * from "./interfaces/Evolution/EvolutionTrigger"; 63 | export type * from "./interfaces/Games/Generation"; 64 | export type * from "./interfaces/Games/Pokedex"; 65 | export type * from "./interfaces/Games/Version"; 66 | export type * from "./interfaces/Games/VersionGroup"; 67 | export type * from "./interfaces/Items/Item"; 68 | export type * from "./interfaces/Items/ItemAttribute"; 69 | export type * from "./interfaces/Items/ItemCategory"; 70 | export type * from "./interfaces/Items/ItemFlingEffect"; 71 | export type * from "./interfaces/Items/ItemPocket"; 72 | export type * from "./interfaces/Locations/Location"; 73 | export type * from "./interfaces/Locations/LocationArea"; 74 | export type * from "./interfaces/Locations/PalParkArea"; 75 | export type * from "./interfaces/Locations/Region"; 76 | export type * from "./interfaces/Machines/Machine"; 77 | export type * from "./interfaces/Moves/Move"; 78 | export type * from "./interfaces/Moves/MoveAilment"; 79 | export type * from "./interfaces/Moves/MoveBattleStyle"; 80 | export type * from "./interfaces/Moves/MoveCategory"; 81 | export type * from "./interfaces/Moves/MoveDamageClass"; 82 | export type * from "./interfaces/Moves/MoveLearnMethod"; 83 | export type * from "./interfaces/Moves/MoveTarget"; 84 | export type * from "./interfaces/Pokemon/Ability"; 85 | export type * from "./interfaces/Pokemon/Characteristic"; 86 | export type * from "./interfaces/Pokemon/EggGroup"; 87 | export type * from "./interfaces/Pokemon/Gender"; 88 | export type * from "./interfaces/Pokemon/GrowthRate"; 89 | export type * from "./interfaces/Pokemon/Nature"; 90 | export type * from "./interfaces/Pokemon/PokeathlonStat"; 91 | export type * from "./interfaces/Pokemon/Pokemon"; 92 | export type * from "./interfaces/Pokemon/PokemonColor"; 93 | export type * from "./interfaces/Pokemon/PokemonForm"; 94 | export type * from "./interfaces/Pokemon/PokemonHabitat"; 95 | export type * from "./interfaces/Pokemon/PokemonShape"; 96 | export type * from "./interfaces/Pokemon/PokemonSpecies"; 97 | export type * from "./interfaces/Pokemon/Stat"; 98 | export type * from "./interfaces/Pokemon/Type"; 99 | export type * from "./interfaces/Utility/Language"; 100 | export type * from "./interfaces/Utility/CommonModels"; 101 | export type * from "./interfaces/Utility/ApiResourceList"; 102 | export type * from "./interfaces/Utility/NamedApiResourceList"; 103 | 104 | export class PokeAPI { 105 | public static Berry = new NamedEndpoint("berry"); 106 | 107 | public static BerryFirmness = new NamedEndpoint("berry-firmness"); 108 | 109 | public static BerryFlavor = new NamedEndpoint("berry-flavor"); 110 | 111 | public static ContestType = new NamedEndpoint("contest-type"); 112 | 113 | public static ContestEffect = new Endpoint("contest-effect"); 114 | 115 | public static SuperContestEffect = new Endpoint("super-contest-effect"); 116 | 117 | public static EncounterMethod = new NamedEndpoint("encounter-method"); 118 | 119 | public static EncounterCondition = new NamedEndpoint("encounter-condition"); 120 | 121 | public static EncounterConditionValue = new NamedEndpoint("encounter-condition-value"); 122 | 123 | public static EvolutionChain = new Endpoint("evolution-chain"); 124 | 125 | public static EvolutionTrigger = new NamedEndpoint("evolution-trigger"); 126 | 127 | public static Generation = new NamedEndpoint("generation"); 128 | 129 | public static Pokedex = new NamedEndpoint("pokedex"); 130 | 131 | public static Version = new NamedEndpoint("version"); 132 | 133 | public static VerionGroup = new NamedEndpoint("version-group"); 134 | 135 | public static Item = new NamedEndpoint("item"); 136 | 137 | public static ItemAttribute = new NamedEndpoint("item-attribute"); 138 | 139 | public static ItemCategory = new NamedEndpoint("item-category"); 140 | 141 | public static ItemFlingEffect = new NamedEndpoint("item-fling-effect"); 142 | 143 | public static ItemPocket = new NamedEndpoint("item-pocket"); 144 | 145 | public static Location = new NamedEndpoint("location"); 146 | 147 | public static LocationArea = new NamedEndpoint("location-area"); 148 | 149 | public static PalParkArea = new NamedEndpoint("pal-park-area"); 150 | 151 | public static Region = new NamedEndpoint("region"); 152 | 153 | public static Machine = new Endpoint("machine"); 154 | 155 | public static Move = new NamedEndpoint("move"); 156 | 157 | public static MoveAilment = new NamedEndpoint("move-ailment"); 158 | 159 | public static MoveBattleStyle = new NamedEndpoint("move-battle-style"); 160 | 161 | public static MoveCategory = new NamedEndpoint("move-category"); 162 | 163 | public static MoveDamageClass = new NamedEndpoint("move-damage-class"); 164 | 165 | public static MoveLearnMethod = new NamedEndpoint("move-learn-method"); 166 | 167 | public static MoveTarget = new NamedEndpoint("move-target"); 168 | 169 | public static Ability = new NamedEndpoint("ability"); 170 | 171 | public static Characteristic = new Endpoint("characteristic"); 172 | 173 | public static EggGroup = new NamedEndpoint("egg-group"); 174 | 175 | public static Gender = new NamedEndpoint("gender"); 176 | 177 | public static GrowthRate = new NamedEndpoint("growth-rate"); 178 | 179 | public static Nature = new NamedEndpoint("nature"); 180 | 181 | public static PokeathlonStat = new NamedEndpoint("pokeathlon-stat"); 182 | 183 | public static Pokemon = new NamedEndpoint("pokemon"); 184 | 185 | public static PokemonColor = new NamedEndpoint("pokemon-color"); 186 | 187 | public static PokemonForm = new NamedEndpoint("pokemon-form"); 188 | 189 | public static PokemonHabitat = new NamedEndpoint("pokemon-habitat"); 190 | 191 | public static PokemonShape = new NamedEndpoint("pokemon-shape"); 192 | 193 | public static PokemonSpecies = new NamedEndpoint("pokemon-species"); 194 | 195 | public static Stat = new NamedEndpoint("stat"); 196 | 197 | public static Type = new NamedEndpoint("type"); 198 | 199 | public static Language = new NamedEndpoint("language"); 200 | } 201 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | /* Visit https://aka.ms/tsconfig to read more about this file */ 4 | 5 | /* Projects */ 6 | // "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */ 7 | // "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */ 8 | // "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */ 9 | // "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */ 10 | // "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */ 11 | // "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */ 12 | 13 | /* Language and Environment */ 14 | "target": "ES2024", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */ 15 | // "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */ 16 | // "jsx": "preserve", /* Specify what JSX code is generated. */ 17 | // "libReplacement": true, /* Enable lib replacement. */ 18 | // "experimentalDecorators": true, /* Enable experimental support for legacy experimental decorators. */ 19 | // "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */ 20 | // "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */ 21 | // "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */ 22 | // "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */ 23 | // "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */ 24 | "noLib": false, /* Disable including any library files, including the default lib.d.ts. */ 25 | // "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */ 26 | // "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */ 27 | 28 | /* Modules */ 29 | "module": "ESNext", /* Specify what module code is generated. */ 30 | // "rootDir": "./", /* Specify the root folder within your source files. */ 31 | "moduleResolution": "node", /* Specify how TypeScript looks up a file from a given module specifier. */ 32 | // "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */ 33 | // "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */ 34 | // "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */ 35 | // "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */ 36 | // "types": [], /* Specify type package names to be included without being referenced in a source file. */ 37 | // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ 38 | // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */ 39 | // "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution bundler' and either '--noEmit' or '--emitDeclarationOnly' to be set. */ 40 | // "rewriteRelativeImportExtensions": true, /* Rewrite '.ts', '.tsx', '.mts', and '.cts' file extensions in relative import paths to their JavaScript equivalent in output files. */ 41 | // "resolvePackageJsonExports": true, /* Use the package.json 'exports' field when resolving package imports. */ 42 | // "resolvePackageJsonImports": true, /* Use the package.json 'imports' field when resolving imports. */ 43 | // "customConditions": [], /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */ 44 | // "noUncheckedSideEffectImports": true, /* Check side effect imports. */ 45 | // "resolveJsonModule": true, /* Enable importing .json files. */ 46 | // "allowArbitraryExtensions": true, /* Enable importing files with any extension, provided a declaration file is present. */ 47 | // "noResolve": true, /* Disallow 'import's, 'require's or ''s from expanding the number of files TypeScript should add to a project. */ 48 | 49 | /* JavaScript Support */ 50 | // "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */ 51 | // "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */ 52 | // "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */ 53 | 54 | /* Emit */ 55 | "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */ 56 | // "declarationMap": true, /* Create sourcemaps for d.ts files. */ 57 | // "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */ 58 | // "sourceMap": true, /* Create source map files for emitted JavaScript files. */ 59 | // "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */ 60 | // "noEmit": true, /* Disable emitting files from a compilation. */ 61 | // "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */ 62 | "outDir": "./dist", /* Specify an output folder for all emitted files. */ 63 | // "removeComments": true, /* Disable emitting comments. */ 64 | // "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */ 65 | // "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */ 66 | // "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */ 67 | // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */ 68 | // "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */ 69 | // "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */ 70 | // "newLine": "crlf", /* Set the newline character for emitting files. */ 71 | // "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */ 72 | // "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */ 73 | // "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */ 74 | // "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */ 75 | // "declarationDir": "./", /* Specify the output directory for generated declaration files. */ 76 | 77 | /* Interop Constraints */ 78 | // "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */ 79 | // "verbatimModuleSyntax": true, /* Do not transform or elide any imports or exports not marked as type-only, ensuring they are written in the output file's format based on the 'module' setting. */ 80 | // "isolatedDeclarations": true, /* Require sufficient annotation on exports so other tools can trivially generate declaration files. */ 81 | // "erasableSyntaxOnly": true, /* Do not allow runtime constructs that are not part of ECMAScript. */ 82 | // "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */ 83 | "esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */ 84 | // "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */ 85 | "forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */ 86 | 87 | /* Type Checking */ 88 | "strict": true, /* Enable all strict type-checking options. */ 89 | // "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */ 90 | // "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */ 91 | // "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */ 92 | // "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */ 93 | // "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */ 94 | // "strictBuiltinIteratorReturn": true, /* Built-in iterators are instantiated with a 'TReturn' type of 'undefined' instead of 'any'. */ 95 | // "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */ 96 | // "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */ 97 | "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */ 98 | // "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */ 99 | // "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */ 100 | // "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */ 101 | // "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */ 102 | // "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */ 103 | // "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */ 104 | // "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */ 105 | // "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */ 106 | // "allowUnusedLabels": true, /* Disable error reporting for unused labels. */ 107 | // "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */ 108 | 109 | /* Completeness */ 110 | // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */ 111 | "skipLibCheck": true /* Skip type checking all .d.ts files. */ 112 | } 113 | } 114 | --------------------------------------------------------------------------------