pokenode-ts 2.1.0 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.cjs +3 -3
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +534 -173
- package/lib/index.d.ts +534 -173
- package/lib/index.js +3 -3
- package/lib/index.js.map +1 -1
- package/lib/{rolldown-runtime-C_bSAL1r.js → rolldown-runtime-DR5ThJ0q.js} +2 -2
- package/package.json +4 -4
package/lib/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
//#endregion
|
|
2
|
-
//#region src/models/
|
|
2
|
+
//#region src/models/common/resource.d.ts
|
|
3
3
|
/**
|
|
4
4
|
* Marks what a link points at.
|
|
5
5
|
*
|
|
@@ -78,7 +78,7 @@ interface APIResourceList<T = unknown> {
|
|
|
78
78
|
results: APIResource<T>[];
|
|
79
79
|
}
|
|
80
80
|
//#endregion
|
|
81
|
-
//#region src/models/
|
|
81
|
+
//#region src/models/common/name.d.ts
|
|
82
82
|
/**
|
|
83
83
|
* The localized name for an API resource in a specific language.
|
|
84
84
|
*/
|
|
@@ -89,7 +89,7 @@ interface Name {
|
|
|
89
89
|
language: NamedAPIResource<Language>;
|
|
90
90
|
}
|
|
91
91
|
//#endregion
|
|
92
|
-
//#region src/models/
|
|
92
|
+
//#region src/models/common/language.d.ts
|
|
93
93
|
/**
|
|
94
94
|
* Languages for translations of API resource information.
|
|
95
95
|
*/
|
|
@@ -108,7 +108,7 @@ interface Language {
|
|
|
108
108
|
names: Name[];
|
|
109
109
|
}
|
|
110
110
|
//#endregion
|
|
111
|
-
//#region src/models/
|
|
111
|
+
//#region src/models/common/description.d.ts
|
|
112
112
|
/**
|
|
113
113
|
* The localized description for an API resource in a specific language.
|
|
114
114
|
*/
|
|
@@ -119,7 +119,7 @@ interface Description {
|
|
|
119
119
|
language: NamedAPIResource<Language>;
|
|
120
120
|
}
|
|
121
121
|
//#endregion
|
|
122
|
-
//#region src/models/
|
|
122
|
+
//#region src/models/common/effect.d.ts
|
|
123
123
|
/**
|
|
124
124
|
* The localized effect text for an API resource in a specific language.
|
|
125
125
|
*/
|
|
@@ -130,10 +130,11 @@ interface Effect {
|
|
|
130
130
|
language: NamedAPIResource<Language>;
|
|
131
131
|
}
|
|
132
132
|
//#endregion
|
|
133
|
-
//#region src/models/
|
|
133
|
+
//#region src/models/encounter/encounter.d.ts
|
|
134
134
|
/**
|
|
135
135
|
* ## Encounter Method
|
|
136
136
|
* Methods by which the player can encounter Pokémon in the wild, e.g., walking in tall grass.
|
|
137
|
+
*
|
|
137
138
|
* - See [Bulbapedia](https://bulbapedia.bulbagarden.net/wiki/Wild_Pok%C3%A9mon) for greater detail.
|
|
138
139
|
*/
|
|
139
140
|
interface EncounterMethod {
|
|
@@ -149,7 +150,8 @@ interface EncounterMethod {
|
|
|
149
150
|
/**
|
|
150
151
|
* ## Encounter Condition
|
|
151
152
|
* Conditions which affect what Pokémon might appear in the wild, e.g., day or night.
|
|
152
|
-
*
|
|
153
|
+
*
|
|
154
|
+
* - See [Bulbapedia](https://bulbapedia.bulbagarden.net/wiki/Time).
|
|
153
155
|
*/
|
|
154
156
|
interface EncounterCondition {
|
|
155
157
|
/** The identifier for this resource. */
|
|
@@ -165,6 +167,7 @@ interface EncounterCondition {
|
|
|
165
167
|
* ## Encounter Condition Value
|
|
166
168
|
* Encounter condition values are the various states that an encounter
|
|
167
169
|
* condition can have, i.e., time of day can be either **day** or **night**
|
|
170
|
+
*
|
|
168
171
|
* - See [Bulbapedia](https://bulbapedia.bulbagarden.net/wiki/Time).
|
|
169
172
|
*/
|
|
170
173
|
interface EncounterConditionValue {
|
|
@@ -178,7 +181,7 @@ interface EncounterConditionValue {
|
|
|
178
181
|
names: Name[];
|
|
179
182
|
}
|
|
180
183
|
//#endregion
|
|
181
|
-
//#region src/models/
|
|
184
|
+
//#region src/models/common/encounter.d.ts
|
|
182
185
|
/**
|
|
183
186
|
* How the encountered Pokémon itself is generated, where a game constrains it.
|
|
184
187
|
*
|
|
@@ -211,10 +214,11 @@ interface Encounter {
|
|
|
211
214
|
pokemon_details: EncounterPokemonDetail | null;
|
|
212
215
|
}
|
|
213
216
|
//#endregion
|
|
214
|
-
//#region src/models/
|
|
217
|
+
//#region src/models/contest/contest.d.ts
|
|
215
218
|
/**
|
|
216
219
|
* ## Contest Type
|
|
217
220
|
* Contest types are categories judges used to weigh a Pokémon's condition in Pokémon contests.
|
|
221
|
+
*
|
|
218
222
|
* - See [Bulbapedia](https://bulbapedia.bulbagarden.net/wiki/Contest_condition) for greater detail.
|
|
219
223
|
*/
|
|
220
224
|
interface ContestType {
|
|
@@ -274,6 +278,7 @@ interface ContestEffect {
|
|
|
274
278
|
* specifically in [Diamond, Pearl](https://bulbapedia.bulbagarden.net/wiki/Pok%C3%A9mon_Diamond_and_Pearl_Versions),
|
|
275
279
|
* and [Platinum](https://bulbapedia.bulbagarden.net/wiki/Pok%C3%A9mon_Platinum_Version).
|
|
276
280
|
* In it, Pokémon are rated on their appearance and performance, rather than strength.
|
|
281
|
+
*
|
|
277
282
|
* - See [Bulbapedia](https://bulbapedia.bulbagarden.net/wiki/Pok%C3%A9mon_Super_Contest).
|
|
278
283
|
*/
|
|
279
284
|
interface SuperContestEffect {
|
|
@@ -287,12 +292,13 @@ interface SuperContestEffect {
|
|
|
287
292
|
moves: NamedAPIResource<Move>[];
|
|
288
293
|
}
|
|
289
294
|
//#endregion
|
|
290
|
-
//#region src/models/
|
|
295
|
+
//#region src/models/currency/currency.d.ts
|
|
291
296
|
/**
|
|
292
297
|
* ## Currency
|
|
293
298
|
* Currencies are what items are bought and sold with. Most items are priced in
|
|
294
299
|
* Pokémon Dollars, but a shop can trade in anything from Battle Points to
|
|
295
300
|
* Volcanic Ash.
|
|
301
|
+
*
|
|
296
302
|
* - See [Bulbapedia](https://bulbapedia.bulbagarden.net/wiki/Currency) for greater detail.
|
|
297
303
|
*/
|
|
298
304
|
interface Currency {
|
|
@@ -304,7 +310,7 @@ interface Currency {
|
|
|
304
310
|
names: Name[];
|
|
305
311
|
}
|
|
306
312
|
//#endregion
|
|
307
|
-
//#region src/models/
|
|
313
|
+
//#region src/models/item/item.d.ts
|
|
308
314
|
/**
|
|
309
315
|
* Sprites used to depict the given item in the game.
|
|
310
316
|
*/
|
|
@@ -405,6 +411,7 @@ interface ItemPrice {
|
|
|
405
411
|
* ## Item
|
|
406
412
|
* An item is an object in the games which the player can pick up, keep in their bag, and use in some manner.
|
|
407
413
|
* They have various uses, including healing, powering up, helping catch Pokémon, or to access a new area.
|
|
414
|
+
*
|
|
408
415
|
* - See [Bulbapedia](https://bulbapedia.bulbagarden.net/wiki/Item).
|
|
409
416
|
*/
|
|
410
417
|
interface Item {
|
|
@@ -440,7 +447,7 @@ interface Item {
|
|
|
440
447
|
machines: MachineVersionDetail[];
|
|
441
448
|
}
|
|
442
449
|
//#endregion
|
|
443
|
-
//#region src/models/
|
|
450
|
+
//#region src/models/location/encounter.d.ts
|
|
444
451
|
/**
|
|
445
452
|
* Method in which Pokémon may be encountered in the given area
|
|
446
453
|
* and how likely the method will occur depending on the version of the game.
|
|
@@ -470,11 +477,12 @@ interface PokemonEncounter {
|
|
|
470
477
|
version_details: VersionEncounterDetail[];
|
|
471
478
|
}
|
|
472
479
|
//#endregion
|
|
473
|
-
//#region src/models/
|
|
480
|
+
//#region src/models/location/location.d.ts
|
|
474
481
|
/**
|
|
475
482
|
* ## Location
|
|
476
483
|
* Locations that can be visited within the games.
|
|
477
484
|
* Locations make up sizable portions of regions, like cities or routes.
|
|
485
|
+
*
|
|
478
486
|
* - See the [List of Locations](https://bulbapedia.bulbagarden.net/wiki/List_of_locations_by_name).
|
|
479
487
|
*/
|
|
480
488
|
interface Location {
|
|
@@ -495,6 +503,7 @@ interface Location {
|
|
|
495
503
|
* ## Location Area
|
|
496
504
|
* Location areas are sections of areas, such as floors in a building or cave.
|
|
497
505
|
* Each area has its own set of possible Pokémon encounters.
|
|
506
|
+
*
|
|
498
507
|
* - See [Bulbapedia](https://bulbapedia.bulbagarden.net/wiki/Area) for greater detail.
|
|
499
508
|
*/
|
|
500
509
|
interface LocationArea {
|
|
@@ -514,7 +523,7 @@ interface LocationArea {
|
|
|
514
523
|
pokemon_encounters: PokemonEncounter[];
|
|
515
524
|
}
|
|
516
525
|
//#endregion
|
|
517
|
-
//#region src/models/
|
|
526
|
+
//#region src/models/pokemon/type.d.ts
|
|
518
527
|
/**
|
|
519
528
|
* Details of Pokémon for a specific type.
|
|
520
529
|
*/
|
|
@@ -654,7 +663,7 @@ interface Type {
|
|
|
654
663
|
sprites: TypeSprites;
|
|
655
664
|
}
|
|
656
665
|
//#endregion
|
|
657
|
-
//#region src/models/
|
|
666
|
+
//#region src/models/evolution/evolution.d.ts
|
|
658
667
|
/**
|
|
659
668
|
* ## Evolution Detail
|
|
660
669
|
* All details regarding the specific details of the referenced Pokémon species evolution.
|
|
@@ -773,6 +782,7 @@ interface EvolutionChain {
|
|
|
773
782
|
* There are numerous methods of evolution which define how and when Pokémon evolve.
|
|
774
783
|
* Most Pokémon will evolve by leveling up while others evolve through specific means,
|
|
775
784
|
* such as being traded, achieving a certain amount of friendship or leveling at certain times, among others.
|
|
785
|
+
*
|
|
776
786
|
* - See [Bulbapedia](https://bulbapedia.bulbagarden.net/wiki/Methods_of_evolution) for greater detail.
|
|
777
787
|
*/
|
|
778
788
|
interface EvolutionTrigger {
|
|
@@ -786,7 +796,7 @@ interface EvolutionTrigger {
|
|
|
786
796
|
pokemon_species: NamedAPIResource<PokemonSpecies>[];
|
|
787
797
|
}
|
|
788
798
|
//#endregion
|
|
789
|
-
//#region src/models/
|
|
799
|
+
//#region src/models/game/pokemon-entry.d.ts
|
|
790
800
|
/**
|
|
791
801
|
* A Pokémon catalogued in a Pokédex.
|
|
792
802
|
*/
|
|
@@ -797,12 +807,13 @@ interface PokemonEntry {
|
|
|
797
807
|
pokemon_species: NamedAPIResource<PokemonSpecies>;
|
|
798
808
|
}
|
|
799
809
|
//#endregion
|
|
800
|
-
//#region src/models/
|
|
810
|
+
//#region src/models/game/pokedex.d.ts
|
|
801
811
|
/**
|
|
802
812
|
* ## Pokédex
|
|
803
813
|
* A Pokédex is a handheld electronic encyclopedia device;
|
|
804
814
|
* one which is capable of recording and retaining information of the various Pokémon in a given region
|
|
805
815
|
* with the exception of the national dex and some smaller dexes related to portions of a region.
|
|
816
|
+
*
|
|
806
817
|
* - See [Bulbapedia](https://bulbapedia.bulbagarden.net/wiki/Pok%C3%A9dex) for greater detail.
|
|
807
818
|
*/
|
|
808
819
|
interface Pokedex {
|
|
@@ -824,20 +835,20 @@ interface Pokedex {
|
|
|
824
835
|
version_groups: NamedAPIResource<VersionGroup>[];
|
|
825
836
|
}
|
|
826
837
|
//#endregion
|
|
827
|
-
//#region src/models/
|
|
838
|
+
//#region src/models/location/palpark.d.ts
|
|
828
839
|
/**
|
|
829
840
|
* ## Pal Park Area
|
|
830
841
|
* Areas used for grouping Pokémon encounters in Pal Park.
|
|
831
842
|
* They're like habitats that are specific to Pal Park.
|
|
832
843
|
* Pal Park is divided into five separate areas:
|
|
833
|
-
*
|
|
844
|
+
*
|
|
834
845
|
* - [Field](https://bulbapedia.bulbagarden.net/wiki/List_of_Pok%C3%A9mon_by_Pal_Park_location#Field)
|
|
835
846
|
* - [Forest](https://bulbapedia.bulbagarden.net/wiki/List_of_Pok%C3%A9mon_by_Pal_Park_location#Forest)
|
|
836
847
|
* - [Mountain](https://bulbapedia.bulbagarden.net/wiki/List_of_Pok%C3%A9mon_by_Pal_Park_location#Mountain)
|
|
837
848
|
* - [Pond](https://bulbapedia.bulbagarden.net/wiki/List_of_Pok%C3%A9mon_by_Pal_Park_location#Pound)
|
|
838
849
|
* - [Sea](https://bulbapedia.bulbagarden.net/wiki/List_of_Pok%C3%A9mon_by_Pal_Park_location#Sea)
|
|
839
850
|
* - [Trivia](https://bulbapedia.bulbagarden.net/wiki/List_of_Pok%C3%A9mon_by_Pal_Park_location#Trivia)
|
|
840
|
-
*
|
|
851
|
+
*
|
|
841
852
|
* See [Bulbapedia](https://bulbapedia.bulbagarden.net/wiki/Pal_Park) for greater detail.
|
|
842
853
|
*/
|
|
843
854
|
interface PalParkArea {
|
|
@@ -862,11 +873,12 @@ interface PalParkEncounterSpecies {
|
|
|
862
873
|
pokemon_species: NamedAPIResource<PokemonSpecies>;
|
|
863
874
|
}
|
|
864
875
|
//#endregion
|
|
865
|
-
//#region src/models/
|
|
876
|
+
//#region src/models/pokemon/egg-group.d.ts
|
|
866
877
|
/**
|
|
867
878
|
* ## Egg Group
|
|
868
879
|
* Egg Groups are categories which determine which Pokémon are able to interbreed.
|
|
869
880
|
* Pokémon may belong to either one or two Egg Groups.
|
|
881
|
+
*
|
|
870
882
|
* - See [Bulbapedia](https://bulbapedia.bulbagarden.net/wiki/Egg_Group) for greater detail.
|
|
871
883
|
*/
|
|
872
884
|
interface EggGroup {
|
|
@@ -880,7 +892,7 @@ interface EggGroup {
|
|
|
880
892
|
pokemon_species: NamedAPIResource<PokemonSpecies>[];
|
|
881
893
|
}
|
|
882
894
|
//#endregion
|
|
883
|
-
//#region src/models/
|
|
895
|
+
//#region src/models/pokemon/growth-rate.d.ts
|
|
884
896
|
/**
|
|
885
897
|
* Levels and the amount of experience needed to attain them based on the given growth rate.
|
|
886
898
|
*/
|
|
@@ -893,6 +905,7 @@ interface GrowthRateExperienceLevel {
|
|
|
893
905
|
/**
|
|
894
906
|
* ## Growth Rate
|
|
895
907
|
* Growth rates are the speed with which Pokémon gain levels through experience.
|
|
908
|
+
*
|
|
896
909
|
* - See [Bulbapedia](https://bulbapedia.bulbagarden.net/wiki/Experience) for greater detail.
|
|
897
910
|
*/
|
|
898
911
|
interface GrowthRate {
|
|
@@ -910,11 +923,12 @@ interface GrowthRate {
|
|
|
910
923
|
pokemon_species: NamedAPIResource<PokemonSpecies>[];
|
|
911
924
|
}
|
|
912
925
|
//#endregion
|
|
913
|
-
//#region src/models/
|
|
926
|
+
//#region src/models/pokemon/characteristic.d.ts
|
|
914
927
|
/**
|
|
915
928
|
* ## Characteristic
|
|
916
929
|
* Characteristics indicate which stat contains a Pokémon's highest IV.
|
|
917
930
|
* A Pokémon's Characteristic is determined by the remainder of its highest IV divided by 5 (gene_modulo).
|
|
931
|
+
*
|
|
918
932
|
* - See [Bulbapedia](https://bulbapedia.bulbagarden.net/wiki/Characteristic) for greater detail.
|
|
919
933
|
*/
|
|
920
934
|
interface Characteristic {
|
|
@@ -930,11 +944,12 @@ interface Characteristic {
|
|
|
930
944
|
descriptions: Description[];
|
|
931
945
|
}
|
|
932
946
|
//#endregion
|
|
933
|
-
//#region src/models/
|
|
947
|
+
//#region src/models/pokemon/pokeathlon-stat.d.ts
|
|
934
948
|
/**
|
|
935
949
|
* ## Pokéathlon Stat
|
|
936
950
|
* Pokéathlon Stats are different attributes of a Pokémon's performance in Pokéathlons.
|
|
937
951
|
* In Pokéathlons, competitions happen on different courses; one for each of the different Pokéathlon stats.
|
|
952
|
+
*
|
|
938
953
|
* - See [Bulbapedia](https://bulbapedia.bulbagarden.net/wiki/Pok%C3%A9athlon) for greater detail.
|
|
939
954
|
*/
|
|
940
955
|
interface PokeathlonStat {
|
|
@@ -966,10 +981,11 @@ interface NaturePokeathlonStatAffectSets {
|
|
|
966
981
|
decrease: NaturePokeathlonStatAffect[];
|
|
967
982
|
}
|
|
968
983
|
//#endregion
|
|
969
|
-
//#region src/models/
|
|
984
|
+
//#region src/models/pokemon/nature.d.ts
|
|
970
985
|
/**
|
|
971
986
|
* ## Nature
|
|
972
987
|
* Natures influence how a Pokémon's stats grow.
|
|
988
|
+
*
|
|
973
989
|
* - See [Bulbapedia](https://bulbapedia.bulbagarden.net/wiki/Nature) for greater detail.
|
|
974
990
|
*/
|
|
975
991
|
interface Nature {
|
|
@@ -1014,7 +1030,7 @@ interface MoveBattleStylePreference {
|
|
|
1014
1030
|
move_battle_style: NamedAPIResource<MoveBattleStyle>;
|
|
1015
1031
|
}
|
|
1016
1032
|
//#endregion
|
|
1017
|
-
//#region src/models/
|
|
1033
|
+
//#region src/models/pokemon/stat.d.ts
|
|
1018
1034
|
/**
|
|
1019
1035
|
* ## Stat
|
|
1020
1036
|
* Stats determine certain aspects of battles. Each Pokémon has a value for each stat
|
|
@@ -1070,13 +1086,14 @@ interface MoveStatAffectSets {
|
|
|
1070
1086
|
decrease: MoveStatAffect[];
|
|
1071
1087
|
}
|
|
1072
1088
|
//#endregion
|
|
1073
|
-
//#region src/models/
|
|
1089
|
+
//#region src/models/pokemon/pokemon.d.ts
|
|
1074
1090
|
/**
|
|
1075
1091
|
* ## Pokémon
|
|
1076
1092
|
* Pokémon are the creatures that inhabit the world of the Pokémon games.
|
|
1077
1093
|
* They can be caught using Pokéballs and trained by battling with other Pokémon.
|
|
1078
1094
|
* Each Pokémon belongs to a specific species but may take on a variant
|
|
1079
1095
|
* which makes it differ from other Pokémon of the same species, such as base stats, available abilities and typings.
|
|
1096
|
+
*
|
|
1080
1097
|
* - See [Bulbapedia](https://bulbapedia.bulbagarden.net/wiki/Pok%C3%A9mon_(species)) for greater detail.
|
|
1081
1098
|
*/
|
|
1082
1099
|
interface Pokemon {
|
|
@@ -1924,11 +1941,12 @@ interface PokemonSpeciesVariety {
|
|
|
1924
1941
|
pokemon: NamedAPIResource<Pokemon>;
|
|
1925
1942
|
}
|
|
1926
1943
|
//#endregion
|
|
1927
|
-
//#region src/models/
|
|
1944
|
+
//#region src/models/pokemon/ability.d.ts
|
|
1928
1945
|
/**
|
|
1929
1946
|
* ## Ability
|
|
1930
1947
|
* Abilities provide passive effects for Pokémon in battle or in the overworld.
|
|
1931
1948
|
* Pokémon have multiple possible abilities but can have only one ability at a time.
|
|
1949
|
+
*
|
|
1932
1950
|
* - See [Bulbapedia](https://bulbapedia.bulbagarden.net/wiki/Ability) for greater detail.
|
|
1933
1951
|
*/
|
|
1934
1952
|
interface Ability {
|
|
@@ -1986,11 +2004,12 @@ interface AbilityPokemon {
|
|
|
1986
2004
|
pokemon: NamedAPIResource<Pokemon>;
|
|
1987
2005
|
}
|
|
1988
2006
|
//#endregion
|
|
1989
|
-
//#region src/models/
|
|
2007
|
+
//#region src/models/pokemon/gender.d.ts
|
|
1990
2008
|
/**
|
|
1991
2009
|
* ## Gender
|
|
1992
2010
|
* Genders were introduced in Generation II for the purposes of breeding Pokémon
|
|
1993
2011
|
* but can also result in visual differences or even different evolutionary lines.
|
|
2012
|
+
*
|
|
1994
2013
|
* - See [Bulbapedia](https://bulbapedia.bulbagarden.net/wiki/Gender) for greater detail.
|
|
1995
2014
|
*/
|
|
1996
2015
|
interface Gender {
|
|
@@ -2013,7 +2032,7 @@ interface PokemonSpeciesGender {
|
|
|
2013
2032
|
pokemon_species: NamedAPIResource<PokemonSpecies>;
|
|
2014
2033
|
}
|
|
2015
2034
|
//#endregion
|
|
2016
|
-
//#region src/models/
|
|
2035
|
+
//#region src/models/move/move.d.ts
|
|
2017
2036
|
/**
|
|
2018
2037
|
* ## Move Target
|
|
2019
2038
|
* Targets moves can be directed at during battle. Targets can be Pokémon, environments or even other moves.
|
|
@@ -2079,6 +2098,7 @@ interface MoveCategory {
|
|
|
2079
2098
|
/**
|
|
2080
2099
|
* ## Move Battle Style
|
|
2081
2100
|
* Styles of moves when used in the Battle Palace.
|
|
2101
|
+
*
|
|
2082
2102
|
* - See [Bulbapedia](https://bulbapedia.bulbagarden.net/wiki/Battle_Frontier_(Generation_III)) for greater detail.
|
|
2083
2103
|
*/
|
|
2084
2104
|
interface MoveBattleStyle {
|
|
@@ -2092,6 +2112,7 @@ interface MoveBattleStyle {
|
|
|
2092
2112
|
/**
|
|
2093
2113
|
* ## Move Ailment
|
|
2094
2114
|
* Move Ailments are status conditions caused by moves used during battle.
|
|
2115
|
+
*
|
|
2095
2116
|
* - See [Bulbapedia](https://bulbapedia.bulbagarden.net/wiki/Status_condition) for greater detail.
|
|
2096
2117
|
*/
|
|
2097
2118
|
interface MoveAilment {
|
|
@@ -2189,6 +2210,7 @@ interface ContestComboSets {
|
|
|
2189
2210
|
* Moves are the skills of Pokémon in battle. In battle, a Pokémon uses one move each turn.
|
|
2190
2211
|
* Some moves (including those learned by Hidden Machine) can be used outside of battle as well,
|
|
2191
2212
|
* usually for the purpose of removing obstacles or exploring new areas.
|
|
2213
|
+
*
|
|
2192
2214
|
* - See [Bulbapedia](https://bulbapedia.bulbagarden.net/wiki/Move) for greater detail.
|
|
2193
2215
|
*/
|
|
2194
2216
|
interface Move {
|
|
@@ -2245,11 +2267,12 @@ interface Move {
|
|
|
2245
2267
|
learned_by_pokemon: NamedAPIResource<Pokemon>[];
|
|
2246
2268
|
}
|
|
2247
2269
|
//#endregion
|
|
2248
|
-
//#region src/models/
|
|
2270
|
+
//#region src/models/game/generation.d.ts
|
|
2249
2271
|
/**
|
|
2250
2272
|
* ## Generation
|
|
2251
2273
|
* A generation is a grouping of the Pokémon games that separates them based on the Pokémon they include.
|
|
2252
2274
|
* In each generation, a new set of Pokémon, Moves, Abilities and Types that did not exist in the previous generation are released.
|
|
2275
|
+
*
|
|
2253
2276
|
* - See [Bulbapedia](https://bulbapedia.bulbagarden.net/wiki/Generation) for greater detail.
|
|
2254
2277
|
*/
|
|
2255
2278
|
interface Generation {
|
|
@@ -2273,12 +2296,13 @@ interface Generation {
|
|
|
2273
2296
|
version_groups: NamedAPIResource<VersionGroup>[];
|
|
2274
2297
|
}
|
|
2275
2298
|
//#endregion
|
|
2276
|
-
//#region src/models/
|
|
2299
|
+
//#region src/models/location/region.d.ts
|
|
2277
2300
|
/**
|
|
2278
2301
|
* ## Region
|
|
2279
2302
|
* A region is an organized area of the Pokémon world.
|
|
2280
2303
|
* Most often, the main difference between regions is
|
|
2281
2304
|
* the species of Pokémon that can be encountered within them.
|
|
2305
|
+
*
|
|
2282
2306
|
* - See [Bulbapedia](https://bulbapedia.bulbagarden.net/wiki/Region) for greater detail.
|
|
2283
2307
|
*/
|
|
2284
2308
|
type Region = {
|
|
@@ -2298,10 +2322,11 @@ type Region = {
|
|
|
2298
2322
|
version_groups: NamedAPIResource<VersionGroup>[];
|
|
2299
2323
|
};
|
|
2300
2324
|
//#endregion
|
|
2301
|
-
//#region src/models/
|
|
2325
|
+
//#region src/models/game/version.d.ts
|
|
2302
2326
|
/**
|
|
2303
2327
|
* ## Version
|
|
2304
2328
|
* Versions of the games, e.g. Red, Blue or Yellow.
|
|
2329
|
+
*
|
|
2305
2330
|
* - See [Bulbapedia](https://bulbapedia.bulbagarden.net/wiki/Core_series) for greater detail.
|
|
2306
2331
|
*/
|
|
2307
2332
|
interface Version {
|
|
@@ -2337,7 +2362,7 @@ interface VersionGroup {
|
|
|
2337
2362
|
versions: NamedAPIResource<Version>[];
|
|
2338
2363
|
}
|
|
2339
2364
|
//#endregion
|
|
2340
|
-
//#region src/models/
|
|
2365
|
+
//#region src/models/common/flavor-text.d.ts
|
|
2341
2366
|
/**
|
|
2342
2367
|
* The localized flavor text for an API resource in a specific language.
|
|
2343
2368
|
*/
|
|
@@ -2350,7 +2375,7 @@ interface FlavorText {
|
|
|
2350
2375
|
version: NamedAPIResource<Version>;
|
|
2351
2376
|
}
|
|
2352
2377
|
//#endregion
|
|
2353
|
-
//#region src/models/
|
|
2378
|
+
//#region src/models/common/generation.d.ts
|
|
2354
2379
|
/**
|
|
2355
2380
|
* The generation relevant to this game index.
|
|
2356
2381
|
*/
|
|
@@ -2361,7 +2386,7 @@ interface GenerationGameIndex {
|
|
|
2361
2386
|
generation: NamedAPIResource<Generation>;
|
|
2362
2387
|
}
|
|
2363
2388
|
//#endregion
|
|
2364
|
-
//#region src/models/
|
|
2389
|
+
//#region src/models/machine/machine.d.ts
|
|
2365
2390
|
/**
|
|
2366
2391
|
* ## Machine
|
|
2367
2392
|
* Machines are the representation of items that teach moves to Pokémon.
|
|
@@ -2380,7 +2405,7 @@ type Machine = {
|
|
|
2380
2405
|
version_group: NamedAPIResource<VersionGroup>;
|
|
2381
2406
|
};
|
|
2382
2407
|
//#endregion
|
|
2383
|
-
//#region src/models/
|
|
2408
|
+
//#region src/models/common/machine.d.ts
|
|
2384
2409
|
/**
|
|
2385
2410
|
* The machine that teaches a move from an item.
|
|
2386
2411
|
*/
|
|
@@ -2391,7 +2416,7 @@ interface MachineVersionDetail {
|
|
|
2391
2416
|
version_group: NamedAPIResource<VersionGroup>;
|
|
2392
2417
|
}
|
|
2393
2418
|
//#endregion
|
|
2394
|
-
//#region src/models/
|
|
2419
|
+
//#region src/models/common/verbose.d.ts
|
|
2395
2420
|
/**
|
|
2396
2421
|
* The localized effect for an API resource.
|
|
2397
2422
|
*/
|
|
@@ -2404,7 +2429,7 @@ interface VerboseEffect {
|
|
|
2404
2429
|
language: NamedAPIResource<Language>;
|
|
2405
2430
|
}
|
|
2406
2431
|
//#endregion
|
|
2407
|
-
//#region src/models/
|
|
2432
|
+
//#region src/models/common/version.d.ts
|
|
2408
2433
|
/**
|
|
2409
2434
|
* Encounters and their specific details.
|
|
2410
2435
|
*/
|
|
@@ -2437,7 +2462,7 @@ interface VersionGroupFlavorText {
|
|
|
2437
2462
|
version_group: NamedAPIResource<VersionGroup>;
|
|
2438
2463
|
}
|
|
2439
2464
|
//#endregion
|
|
2440
|
-
//#region src/models/
|
|
2465
|
+
//#region src/models/berry/berry.d.ts
|
|
2441
2466
|
/**
|
|
2442
2467
|
* ## Berry
|
|
2443
2468
|
* Berries are small fruits that can provide HP and status condition restoration,
|
|
@@ -2546,7 +2571,10 @@ interface CacheStore {
|
|
|
2546
2571
|
interface MemoryCacheOptions {
|
|
2547
2572
|
/** How long a cached response stays fresh, in milliseconds. Defaults to 5 minutes. */
|
|
2548
2573
|
ttl?: number;
|
|
2549
|
-
/**
|
|
2574
|
+
/**
|
|
2575
|
+
* Maximum number of responses kept. The least recently used entry is evicted.
|
|
2576
|
+
* Defaults to 500; zero keeps none.
|
|
2577
|
+
*/
|
|
2550
2578
|
maxEntries?: number;
|
|
2551
2579
|
}
|
|
2552
2580
|
/**
|
|
@@ -2566,6 +2594,50 @@ declare class MemoryCache implements CacheStore {
|
|
|
2566
2594
|
delete(key: string): void;
|
|
2567
2595
|
clear(): void;
|
|
2568
2596
|
}
|
|
2597
|
+
/**
|
|
2598
|
+
* ## Etag Entry
|
|
2599
|
+
* What a URL last answered with, and the validator that says so.
|
|
2600
|
+
*/
|
|
2601
|
+
interface EtagEntry {
|
|
2602
|
+
/** The `ETag` the response carried. */
|
|
2603
|
+
etag: string;
|
|
2604
|
+
/** The parsed body that `etag` identifies. */
|
|
2605
|
+
value: unknown;
|
|
2606
|
+
}
|
|
2607
|
+
/**
|
|
2608
|
+
* ## Etag Store Options
|
|
2609
|
+
* Used to configure an {@link EtagStore}.
|
|
2610
|
+
*/
|
|
2611
|
+
interface EtagStoreOptions {
|
|
2612
|
+
/**
|
|
2613
|
+
* How many URLs to remember. The least recently used is evicted. Defaults to
|
|
2614
|
+
* 500; zero remembers none.
|
|
2615
|
+
*/
|
|
2616
|
+
maxEntries?: number;
|
|
2617
|
+
}
|
|
2618
|
+
/**
|
|
2619
|
+
* ## Etag Store
|
|
2620
|
+
* Remembers the `ETag` each URL answered with, and the body it identified, so an
|
|
2621
|
+
* expired cache entry can be revalidated instead of downloaded again.
|
|
2622
|
+
*
|
|
2623
|
+
* Deliberately not a {@link CacheStore}: the two answer different questions. A
|
|
2624
|
+
* `CacheStore` says "this response is still fresh, use it"; this says "here is
|
|
2625
|
+
* what the response was last time, ask the server whether it still holds". They
|
|
2626
|
+
* are kept apart so that a store someone else owns — a shared Redis — is never
|
|
2627
|
+
* given a second key shape, and `cache.get(url)` keeps returning the resource
|
|
2628
|
+
* itself.
|
|
2629
|
+
*
|
|
2630
|
+
* Entries live in memory and are never persisted: an `ETag` is only worth what
|
|
2631
|
+
* the body beside it is, and the body is what would cost memory to keep.
|
|
2632
|
+
*/
|
|
2633
|
+
declare class EtagStore {
|
|
2634
|
+
private readonly entries;
|
|
2635
|
+
private readonly maxEntries;
|
|
2636
|
+
constructor(options?: EtagStoreOptions);
|
|
2637
|
+
get(url: string): EtagEntry | undefined;
|
|
2638
|
+
set(url: string, entry: EtagEntry): void;
|
|
2639
|
+
clear(): void;
|
|
2640
|
+
}
|
|
2569
2641
|
/**
|
|
2570
2642
|
* ## Web Storage Like
|
|
2571
2643
|
* The part of the browser's `Storage` interface a {@link WebStorageCache} uses.
|
|
@@ -2665,7 +2737,7 @@ declare class WebStorageCache implements CacheStore {
|
|
|
2665
2737
|
*/
|
|
2666
2738
|
interface LogFields {
|
|
2667
2739
|
/** Which point of the request lifecycle this is, for filtering. */
|
|
2668
|
-
event: "request" | "response" | "error";
|
|
2740
|
+
event: "request" | "response" | "retry" | "cancelled" | "error";
|
|
2669
2741
|
msg: string;
|
|
2670
2742
|
message: string;
|
|
2671
2743
|
/** The request URL, with any credentials the base URL carried removed. */
|
|
@@ -2694,15 +2766,50 @@ interface LogResponsePayload extends LogFields {
|
|
|
2694
2766
|
* - `cache` — served by the {@link CacheStore}; nothing left the process.
|
|
2695
2767
|
* - `in-flight` — an identical request was already on the wire and this caller
|
|
2696
2768
|
* shared it, so it made no round trip of its own.
|
|
2769
|
+
* - `revalidated` — a round trip was made, the API answered 304, and the body
|
|
2770
|
+
* already held for that URL was reused. Cheap, but not free.
|
|
2697
2771
|
*
|
|
2698
|
-
* Counting
|
|
2699
|
-
* saw. Every caller reports, so counting all
|
|
2700
|
-
* the application made.
|
|
2772
|
+
* Counting `network` and `revalidated` gives the number of requests the
|
|
2773
|
+
* PokéAPI actually saw. Every caller reports, so counting all four gives the
|
|
2774
|
+
* number of calls the application made.
|
|
2701
2775
|
*/
|
|
2702
|
-
source: "network" | "cache" | "in-flight";
|
|
2776
|
+
source: "network" | "cache" | "in-flight" | "revalidated";
|
|
2703
2777
|
/** How long the client took to resolve the request, in milliseconds. */
|
|
2704
2778
|
durationMs: number;
|
|
2705
2779
|
}
|
|
2780
|
+
/**
|
|
2781
|
+
* ## Log Retry Payload
|
|
2782
|
+
* An attempt failed and another one is coming.
|
|
2783
|
+
*
|
|
2784
|
+
* Only emitted when `retry` is configured, and never for the attempt that gives
|
|
2785
|
+
* up — that one is a `response` or an `error` like any other. Counting these
|
|
2786
|
+
* gives the round trips the PokéAPI saw beyond the ones it answered.
|
|
2787
|
+
*/
|
|
2788
|
+
interface LogRetryPayload extends LogFields {
|
|
2789
|
+
event: "retry";
|
|
2790
|
+
/** Which attempt just failed, counting from one. */
|
|
2791
|
+
attempt: number;
|
|
2792
|
+
/** How long the client will wait before the next one, in milliseconds. */
|
|
2793
|
+
delayMs: number;
|
|
2794
|
+
/** The status that failed. Absent when the attempt never got a response. */
|
|
2795
|
+
status?: number;
|
|
2796
|
+
}
|
|
2797
|
+
/**
|
|
2798
|
+
* ## Log Cancelled Payload
|
|
2799
|
+
* A request was cancelled by the scope it was made through.
|
|
2800
|
+
*
|
|
2801
|
+
* A caller that hangs up asked for this, so it is not a failure and does not
|
|
2802
|
+
* reach `error`: a handler that scopes every request would otherwise report its
|
|
2803
|
+
* own timeouts as its error rate. Counting `response` and `cancelled` together
|
|
2804
|
+
* accounts for every `request` logged.
|
|
2805
|
+
*/
|
|
2806
|
+
interface LogCancelledPayload extends LogFields {
|
|
2807
|
+
event: "cancelled";
|
|
2808
|
+
/** `signal.reason`, or the `TimeoutError` a scoped timeout raised. */
|
|
2809
|
+
reason: unknown;
|
|
2810
|
+
/** How long the request had been running when it was cancelled, in milliseconds. */
|
|
2811
|
+
durationMs: number;
|
|
2812
|
+
}
|
|
2706
2813
|
/**
|
|
2707
2814
|
* ## Log Error Payload
|
|
2708
2815
|
* A request failed.
|
|
@@ -2730,11 +2837,12 @@ interface LogErrorPayload extends LogFields {
|
|
|
2730
2837
|
* new PokemonClient({ logger: winston.createLogger() });
|
|
2731
2838
|
* ```
|
|
2732
2839
|
*
|
|
2733
|
-
* Requests and
|
|
2734
|
-
* logged unless a logger is passed, and a client never picks a level
|
|
2840
|
+
* Requests, responses and cancellations go to `debug`; failures go to `error`.
|
|
2841
|
+
* Nothing is logged unless a logger is passed, and a client never picks a level
|
|
2842
|
+
* of its own.
|
|
2735
2843
|
*/
|
|
2736
2844
|
interface Logger {
|
|
2737
|
-
debug(payload: LogRequestPayload | LogResponsePayload): void;
|
|
2845
|
+
debug(payload: LogRequestPayload | LogResponsePayload | LogRetryPayload | LogCancelledPayload): void;
|
|
2738
2846
|
error(payload: LogErrorPayload): void;
|
|
2739
2847
|
}
|
|
2740
2848
|
/**
|
|
@@ -2746,13 +2854,6 @@ interface Logger {
|
|
|
2746
2854
|
*/
|
|
2747
2855
|
declare const consoleLogger: Logger;
|
|
2748
2856
|
//#endregion
|
|
2749
|
-
//#region src/constants/base.d.ts
|
|
2750
|
-
declare const BASE_URL: {
|
|
2751
|
-
readonly REST: "https://pokeapi.co/api/v2";
|
|
2752
|
-
/** Root of the sprite repository the API's own sprite URLs point at. */
|
|
2753
|
-
readonly SPRITES: "https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites";
|
|
2754
|
-
};
|
|
2755
|
-
//#endregion
|
|
2756
2857
|
//#region src/constants/berries.d.ts
|
|
2757
2858
|
/** Enum of Berries (NAME - ID) */
|
|
2758
2859
|
declare const BERRIES: {
|
|
@@ -3318,7 +3419,7 @@ declare const MOVE_TARGETS: {
|
|
|
3318
3419
|
readonly ALL_ALLIES: 15;
|
|
3319
3420
|
};
|
|
3320
3421
|
//#endregion
|
|
3321
|
-
//#region src/constants/
|
|
3422
|
+
//#region src/constants/pokemon.d.ts
|
|
3322
3423
|
declare const EGG_GROUPS: {
|
|
3323
3424
|
readonly MONSTER: 1;
|
|
3324
3425
|
readonly WATER1: 2;
|
|
@@ -3455,6 +3556,13 @@ declare const TYPES: {
|
|
|
3455
3556
|
readonly SHADOW: 10002;
|
|
3456
3557
|
};
|
|
3457
3558
|
//#endregion
|
|
3559
|
+
//#region src/constants/urls.d.ts
|
|
3560
|
+
declare const BASE_URL: {
|
|
3561
|
+
readonly REST: "https://pokeapi.co/api/v2";
|
|
3562
|
+
/** Root of the sprite repository the API's own sprite URLs point at. */
|
|
3563
|
+
readonly SPRITES: "https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites";
|
|
3564
|
+
};
|
|
3565
|
+
//#endregion
|
|
3458
3566
|
//#region src/constants/utilities.d.ts
|
|
3459
3567
|
declare const LANGUAGES: {
|
|
3460
3568
|
readonly JA_HRKT: 1;
|
|
@@ -3470,6 +3578,7 @@ declare const LANGUAGES: {
|
|
|
3470
3578
|
readonly JA: 11;
|
|
3471
3579
|
readonly ZH_HANS: 12;
|
|
3472
3580
|
readonly PT_BR: 13;
|
|
3581
|
+
readonly ES_419: 14;
|
|
3473
3582
|
};
|
|
3474
3583
|
declare namespace index_d_exports {
|
|
3475
3584
|
export { BASE_URL, BERRIES, BERRY_FIRMNESSES, BERRY_FLAVORS, CONTEST_TYPES, CURRENCIES, EGG_GROUPS, ENCOUNTER_CONDITIONS, ENCOUNTER_CONDITION_VALUES, ENCOUNTER_METHODS, ENDPOINTS, EVOLUTION_TRIGGERS, Endpoint, GENDERS, GENERATIONS, GROWTH_RATES, ITEM_ATTRIBUTES, ITEM_CATEGORIES, ITEM_FLING_EFFECTS, ITEM_POCKETS, LANGUAGES, MOVE_AILMENTS, MOVE_BATTLE_STYLES, MOVE_CATEGORIES, MOVE_DAMAGE_CLASSES, MOVE_LEARN_METHODS, MOVE_TARGETS, NATURES, PAL_PARK_AREAS, POKEATHLON_STATS, POKEDEXES, POKEMON_COLORS, POKEMON_HABITATS, POKEMON_SHAPES, REGIONS, STATS, TYPES, VERSIONS, VERSION_GROUPS };
|
|
@@ -3481,6 +3590,46 @@ declare namespace index_d_exports {
|
|
|
3481
3590
|
* A `fetch` implementation taking a string URL, as every client call does.
|
|
3482
3591
|
*/
|
|
3483
3592
|
type FetchLike = (input: string, init?: RequestInit) => Promise<Response>;
|
|
3593
|
+
/**
|
|
3594
|
+
* ## Resource Link
|
|
3595
|
+
* Something naming a single resource: a link taken from a response, or its URL
|
|
3596
|
+
* as a bare string.
|
|
3597
|
+
*
|
|
3598
|
+
* A link carries what it points at, so passing one infers `T`; a string does
|
|
3599
|
+
* not, and needs `T` named.
|
|
3600
|
+
*/
|
|
3601
|
+
type ResourceLink<T> = string | NamedAPIResource<T> | APIResource<T>;
|
|
3602
|
+
/**
|
|
3603
|
+
* ## Retry Options
|
|
3604
|
+
* When a failed request is worth attempting again.
|
|
3605
|
+
*
|
|
3606
|
+
* Retrying is off unless this is given — a client that quietly triples its own
|
|
3607
|
+
* traffic is not something to opt out of after the fact.
|
|
3608
|
+
*/
|
|
3609
|
+
interface RetryOptions {
|
|
3610
|
+
/** Attempts in total, the first one included. Defaults to 3. */
|
|
3611
|
+
attempts?: number;
|
|
3612
|
+
/** Statuses worth another attempt. Defaults to 429, 500, 502, 503 and 504. */
|
|
3613
|
+
statuses?: number[];
|
|
3614
|
+
/** The first wait, in milliseconds, doubling from there. Defaults to 300. */
|
|
3615
|
+
initialDelay?: number;
|
|
3616
|
+
/** The longest this client will ever wait between attempts. Defaults to 5000. */
|
|
3617
|
+
maxDelay?: number;
|
|
3618
|
+
}
|
|
3619
|
+
/**
|
|
3620
|
+
* ## Request Scope
|
|
3621
|
+
* Cancellation applied to every request a client makes.
|
|
3622
|
+
*
|
|
3623
|
+
* Passed to {@link ClientFacade.with}, not to the constructor: a signal belongs
|
|
3624
|
+
* to one unit of work, while a client outlives many, and a client holding a
|
|
3625
|
+
* signal for its whole life is dead the first time that signal aborts.
|
|
3626
|
+
*/
|
|
3627
|
+
interface RequestScope {
|
|
3628
|
+
/** Aborts the requests made through this scope. */
|
|
3629
|
+
signal?: AbortSignal;
|
|
3630
|
+
/** How long a request may take, in milliseconds, before it is aborted. */
|
|
3631
|
+
timeout?: number;
|
|
3632
|
+
}
|
|
3484
3633
|
/**
|
|
3485
3634
|
* ## Client Options
|
|
3486
3635
|
* Optional configuration accepted by every client.
|
|
@@ -3502,49 +3651,149 @@ interface ClientOptions {
|
|
|
3502
3651
|
* Custom `fetch` implementation, for proxies, retries, cancellation or
|
|
3503
3652
|
* instrumentation. Defaults to the global `fetch`.
|
|
3504
3653
|
*
|
|
3505
|
-
* Requests carry no timeout of their own:
|
|
3506
|
-
* want one.
|
|
3654
|
+
* Requests carry no timeout of their own: derive a scoped client with
|
|
3655
|
+
* {@link ClientFacade.with} if you want one.
|
|
3507
3656
|
*/
|
|
3508
3657
|
fetch?: FetchLike;
|
|
3658
|
+
/**
|
|
3659
|
+
* When to attempt a failed request again. Leave empty to attempt each request
|
|
3660
|
+
* exactly once.
|
|
3661
|
+
*/
|
|
3662
|
+
retry?: RetryOptions;
|
|
3663
|
+
/**
|
|
3664
|
+
* Ask the PokéAPI whether a response has changed, rather than downloading it
|
|
3665
|
+
* again, once the {@link CacheStore} entry for it has expired.
|
|
3666
|
+
*
|
|
3667
|
+
* Pass `true` for a default {@link EtagStore}, or one of your own to size it.
|
|
3668
|
+
* Leave empty and every expired entry is refetched in full.
|
|
3669
|
+
*/
|
|
3670
|
+
revalidate?: boolean | EtagStore;
|
|
3509
3671
|
}
|
|
3510
3672
|
/**
|
|
3511
|
-
* ##
|
|
3512
|
-
*
|
|
3513
|
-
*
|
|
3673
|
+
* ## List Page
|
|
3674
|
+
* The part of a resource list a walk needs: how much there is, and this page of
|
|
3675
|
+
* it. Both {@link NamedAPIResourceList} and {@link APIResourceList} qualify.
|
|
3514
3676
|
*/
|
|
3515
|
-
|
|
3677
|
+
interface ListPage<L> {
|
|
3678
|
+
count: number;
|
|
3679
|
+
results: L[];
|
|
3680
|
+
}
|
|
3681
|
+
/**
|
|
3682
|
+
* ## List Fn
|
|
3683
|
+
* A list method, called with the offset and the limit of the page to fetch.
|
|
3684
|
+
*/
|
|
3685
|
+
type ListFn<L> = (offset: number, limit: number) => Promise<ListPage<L>>;
|
|
3686
|
+
/**
|
|
3687
|
+
* ## List Method
|
|
3688
|
+
* The shape every `list*` method on a section client has.
|
|
3689
|
+
*/
|
|
3690
|
+
type ListMethod = (offset?: number, limit?: number) => Promise<ListPage<APIResource<unknown>>>;
|
|
3691
|
+
/**
|
|
3692
|
+
* ## List Method Name
|
|
3693
|
+
* The names of `C`'s own list methods, and nothing else — so naming one to
|
|
3694
|
+
* {@link BaseClient.paginate} is checked and completed by the compiler.
|
|
3695
|
+
*/
|
|
3696
|
+
type ListMethodName<C> = { [K in keyof C]: C[K] extends ListMethod ? K : never; }[keyof C];
|
|
3697
|
+
/** What a list method's page is made of. */
|
|
3698
|
+
type Listed<F> = F extends ((offset?: number, limit?: number) => Promise<ListPage<infer L>>) ? L : never;
|
|
3699
|
+
/** What a listed link resolves to. */
|
|
3700
|
+
type Resolves<L> = L extends APIResource<infer T> ? T : never;
|
|
3701
|
+
/**
|
|
3702
|
+
* ## Paginate Options
|
|
3703
|
+
* How {@link BaseClient.paginate} walks a list endpoint.
|
|
3704
|
+
*/
|
|
3705
|
+
interface PaginateOptions {
|
|
3706
|
+
/** Entries fetched per request. Defaults to 20. */
|
|
3707
|
+
pageSize?: number;
|
|
3708
|
+
/** Fetch each link and yield the resource instead. Defaults to `false`. */
|
|
3709
|
+
resolve?: boolean;
|
|
3710
|
+
/** Links resolved at a time, when `resolve` is set. Defaults to 4. */
|
|
3711
|
+
concurrency?: number;
|
|
3712
|
+
}
|
|
3713
|
+
/**
|
|
3714
|
+
* ## Resolve Options
|
|
3715
|
+
* How {@link ClientFacade.resolveAll} fetches the links it was given.
|
|
3716
|
+
*/
|
|
3717
|
+
interface ResolveOptions {
|
|
3718
|
+
/** Links fetched at a time. Defaults to 4. */
|
|
3719
|
+
concurrency?: number;
|
|
3720
|
+
}
|
|
3721
|
+
/**
|
|
3722
|
+
* ## Client Facade
|
|
3723
|
+
* What every client is, underneath: something that owns a transport and talks
|
|
3724
|
+
* to it. Holds the members {@link BaseClient} and {@link MainClient} would
|
|
3725
|
+
* otherwise each declare — the cache, the scope, and following a link.
|
|
3726
|
+
*
|
|
3727
|
+
* The transport is a `#private` field rather than a `protected` one so that
|
|
3728
|
+
* nothing about it reaches the published types: a `protected` member keeps its
|
|
3729
|
+
* type in the emitted `.d.ts`, which would put the whole internal transport
|
|
3730
|
+
* surface in front of consumers who cannot name it.
|
|
3731
|
+
*/
|
|
3732
|
+
declare abstract class ClientFacade {
|
|
3733
|
+
#private;
|
|
3734
|
+
constructor(options?: ClientOptions);
|
|
3516
3735
|
/** The store backing this client, or `undefined` when caching is disabled. */
|
|
3517
|
-
|
|
3518
|
-
|
|
3519
|
-
|
|
3520
|
-
|
|
3521
|
-
|
|
3522
|
-
|
|
3523
|
-
|
|
3736
|
+
get cache(): CacheStore | undefined;
|
|
3737
|
+
/**
|
|
3738
|
+
* Derives a client whose requests carry a signal, a timeout, or both.
|
|
3739
|
+
*
|
|
3740
|
+
* The clone shares this client's transport — its cache, its validators and the
|
|
3741
|
+
* requests already on the wire — so a scoped call still joins an identical
|
|
3742
|
+
* unscoped one instead of repeating it. Cloning is cheap, but not free: derive
|
|
3743
|
+
* one per unit of work — a request handler, a job — rather than one per call.
|
|
3744
|
+
*
|
|
3745
|
+
* ```ts
|
|
3746
|
+
* const scoped = api.with({ signal: request.signal, timeout: 2_000 });
|
|
3747
|
+
* ```
|
|
3748
|
+
*/
|
|
3749
|
+
with(scope: RequestScope): this;
|
|
3524
3750
|
/**
|
|
3525
|
-
* Drops every cached response
|
|
3526
|
-
*
|
|
3751
|
+
* Drops every cached response, and any `ETag` learned for one — otherwise the
|
|
3752
|
+
* next request revalidates and is answered with the body just dropped.
|
|
3753
|
+
*
|
|
3754
|
+
* A {@link CacheStore} that does not implement `clear` is left alone.
|
|
3755
|
+
*
|
|
3756
|
+
* The store is the transport's, so a client sharing one with others clears
|
|
3757
|
+
* theirs too.
|
|
3527
3758
|
*/
|
|
3528
3759
|
clearCache(): Promise<void>;
|
|
3529
3760
|
/**
|
|
3530
|
-
*
|
|
3531
|
-
*
|
|
3761
|
+
* Fetches what a link points at, through this client's cache and scope.
|
|
3762
|
+
*
|
|
3763
|
+
* A link carries what it points at, so the result is typed without saying so:
|
|
3532
3764
|
*
|
|
3533
|
-
*
|
|
3534
|
-
*
|
|
3765
|
+
* ```ts
|
|
3766
|
+
* const pokemon = await api.getPokemonByName('luxray');
|
|
3767
|
+
* const species = await api.resolve(pokemon.species);
|
|
3768
|
+
* // ^? PokemonSpecies
|
|
3769
|
+
* ```
|
|
3770
|
+
*
|
|
3771
|
+
* A link names a resource, not a section, so any client resolves any link.
|
|
3772
|
+
*
|
|
3773
|
+
* @throws {TypeError} If the URL is not valid, or names no PokéAPI endpoint.
|
|
3774
|
+
*/
|
|
3775
|
+
resolve<T>(resource: ResourceLink<T>): Promise<T>;
|
|
3776
|
+
/**
|
|
3777
|
+
* Fetches what several links point at, in the order they were given.
|
|
3778
|
+
*
|
|
3779
|
+
* At most `concurrency` requests run at a time — four by default, because the
|
|
3780
|
+
* PokéAPI's fair-use policy asks clients not to flood it. The first failure
|
|
3781
|
+
* rejects, and no further link is fetched.
|
|
3782
|
+
*
|
|
3783
|
+
* ```ts
|
|
3784
|
+
* const types = await api.resolveAll(pokemon.types.map((slot) => slot.type));
|
|
3785
|
+
* // ^? Type[]
|
|
3786
|
+
* ```
|
|
3535
3787
|
*/
|
|
3536
|
-
|
|
3537
|
-
/** Issues a request and remembers it, so a concurrent caller can share it. */
|
|
3538
|
-
private dispatch;
|
|
3539
|
-
private fetchResource;
|
|
3540
|
-
private logResponse;
|
|
3788
|
+
resolveAll<T>(resources: readonly ResourceLink<T>[], options?: ResolveOptions): Promise<T[]>;
|
|
3541
3789
|
/**
|
|
3542
3790
|
* Retrieves a single resource from the PokéAPI by its endpoint and identifier.
|
|
3543
3791
|
*
|
|
3544
|
-
* @param
|
|
3545
|
-
*
|
|
3792
|
+
* @param segments - The identifier of the resource, followed by any path below
|
|
3793
|
+
* it. Each is percent-encoded, so pass `id, 'encounters'` rather than
|
|
3794
|
+
* `` `${id}/encounters` ``. Omit them to address the endpoint itself.
|
|
3546
3795
|
*/
|
|
3547
|
-
protected getResource<T>(endpoint: Endpoint,
|
|
3796
|
+
protected getResource<T>(endpoint: Endpoint, ...segments: (string | number)[]): Promise<T>;
|
|
3548
3797
|
/**
|
|
3549
3798
|
* Retrieves a resource by its URL, or by a link taken from another response.
|
|
3550
3799
|
*
|
|
@@ -3553,7 +3802,7 @@ declare class BaseClient {
|
|
|
3553
3802
|
*
|
|
3554
3803
|
* @throws {TypeError} If the URL is not valid, or names no endpoint under `baseURL`.
|
|
3555
3804
|
*/
|
|
3556
|
-
protected getResourceByURL<T>(resource:
|
|
3805
|
+
protected getResourceByURL<T>(resource: ResourceLink<T>, baseURL?: string): Promise<T>;
|
|
3557
3806
|
/**
|
|
3558
3807
|
* Retrieves a list of resources from the PokéAPI with pagination support.
|
|
3559
3808
|
*
|
|
@@ -3566,6 +3815,65 @@ declare class BaseClient {
|
|
|
3566
3815
|
* @template T - What the listed links resolve to.
|
|
3567
3816
|
*/
|
|
3568
3817
|
protected getUnnamedListResource<T = unknown>(endpoint: Endpoint, offset?: number, limit?: number): Promise<APIResourceList<T>>;
|
|
3818
|
+
/**
|
|
3819
|
+
* Walks every page of a list, yielding one entry at a time. The bridge
|
|
3820
|
+
* {@link BaseClient.paginate} reaches the transport through, so that no
|
|
3821
|
+
* signature here has to name one.
|
|
3822
|
+
*/
|
|
3823
|
+
protected walk<T>(list: ListFn<APIResource<T>>, options?: PaginateOptions): AsyncGenerator<APIResource<T> | T>;
|
|
3824
|
+
}
|
|
3825
|
+
/**
|
|
3826
|
+
* ## Base Client
|
|
3827
|
+
* Base class for every section client. Names endpoints; the transport behind
|
|
3828
|
+
* {@link ClientFacade} does everything else — requests, caching, coalescing,
|
|
3829
|
+
* retries and logs.
|
|
3830
|
+
*
|
|
3831
|
+
* A {@link MainClient} builds one transport and hands it to all twelve of its
|
|
3832
|
+
* section clients, which is what makes them share a cache and a round trip.
|
|
3833
|
+
*/
|
|
3834
|
+
declare class BaseClient extends ClientFacade {
|
|
3835
|
+
/**
|
|
3836
|
+
* Walks every page of a list endpoint, yielding one entry at a time.
|
|
3837
|
+
*
|
|
3838
|
+
* Name the list method to walk; the offset and the limit are this method's to
|
|
3839
|
+
* manage.
|
|
3840
|
+
*
|
|
3841
|
+
* ```ts
|
|
3842
|
+
* for await (const berry of api.berry.paginate('listBerries')) {
|
|
3843
|
+
* console.log(berry.name);
|
|
3844
|
+
* }
|
|
3845
|
+
* ```
|
|
3846
|
+
*
|
|
3847
|
+
* With `resolve`, each link is fetched and the resource is yielded instead of
|
|
3848
|
+
* the link. Requests are capped at `concurrency` at a time — the default is
|
|
3849
|
+
* deliberately low, because walking a section is exactly the traffic the
|
|
3850
|
+
* PokéAPI's fair-use policy asks clients to keep gentle.
|
|
3851
|
+
*
|
|
3852
|
+
* ```ts
|
|
3853
|
+
* for await (const berry of api.berry.paginate('listBerries', { resolve: true })) {
|
|
3854
|
+
* console.log(berry.growth_time);
|
|
3855
|
+
* }
|
|
3856
|
+
* ```
|
|
3857
|
+
*
|
|
3858
|
+
* A function is accepted too, for a list this client does not carry — a page
|
|
3859
|
+
* of a foreign endpoint, or one narrowed before the walk sees it.
|
|
3860
|
+
*
|
|
3861
|
+
* ```ts
|
|
3862
|
+
* api.berry.paginate((offset, limit) => api.berry.listBerries(offset, limit));
|
|
3863
|
+
* ```
|
|
3864
|
+
*/
|
|
3865
|
+
paginate<K extends ListMethodName<this>>(list: K, options?: PaginateOptions & {
|
|
3866
|
+
resolve?: false;
|
|
3867
|
+
}): AsyncGenerator<Listed<this[K]>>;
|
|
3868
|
+
paginate<K extends ListMethodName<this>>(list: K, options: PaginateOptions & {
|
|
3869
|
+
resolve: true;
|
|
3870
|
+
}): AsyncGenerator<Resolves<Listed<this[K]>>>;
|
|
3871
|
+
paginate<L extends APIResource<unknown>>(list: ListFn<L>, options?: PaginateOptions & {
|
|
3872
|
+
resolve?: false;
|
|
3873
|
+
}): AsyncGenerator<L>;
|
|
3874
|
+
paginate<T>(list: ListFn<APIResource<T>>, options: PaginateOptions & {
|
|
3875
|
+
resolve: true;
|
|
3876
|
+
}): AsyncGenerator<T>;
|
|
3569
3877
|
}
|
|
3570
3878
|
//#endregion
|
|
3571
3879
|
//#region src/clients/berry.client.d.ts
|
|
@@ -3573,10 +3881,11 @@ declare class BaseClient {
|
|
|
3573
3881
|
* ### Berry Client
|
|
3574
3882
|
*
|
|
3575
3883
|
* Client used to access the Berry Endpoints:
|
|
3576
|
-
*
|
|
3577
|
-
*
|
|
3578
|
-
*
|
|
3579
|
-
*
|
|
3884
|
+
*
|
|
3885
|
+
* - [Berries](https://pokeapi.co/docs/v2#berries)
|
|
3886
|
+
* - [Berry Firmnesses](https://pokeapi.co/docs/v2#berry-firmnesses)
|
|
3887
|
+
* - [Berry Flavors](https://pokeapi.co/docs/v2#berry-flavors)
|
|
3888
|
+
*
|
|
3580
3889
|
* See [PokéAPI Documentation](https://pokeapi.co/docs/v2#berries-section)
|
|
3581
3890
|
*/
|
|
3582
3891
|
declare class BerryClient extends BaseClient {
|
|
@@ -3605,10 +3914,11 @@ declare class BerryClient extends BaseClient {
|
|
|
3605
3914
|
* ### Contest Client
|
|
3606
3915
|
*
|
|
3607
3916
|
* Client used to access the Contest Endpoints:
|
|
3608
|
-
*
|
|
3609
|
-
*
|
|
3610
|
-
*
|
|
3611
|
-
*
|
|
3917
|
+
*
|
|
3918
|
+
* - [Contest Types](https://pokeapi.co/docs/v2#contest-types)
|
|
3919
|
+
* - [Contest Effects](https://pokeapi.co/docs/v2#contest-effects)
|
|
3920
|
+
* - [Super Contest Effects](https://pokeapi.co/docs/v2#super-contest-effects)
|
|
3921
|
+
*
|
|
3612
3922
|
* See [PokéAPI Documentation](https://pokeapi.co/docs/v2#contests-section)
|
|
3613
3923
|
*/
|
|
3614
3924
|
declare class ContestClient extends BaseClient {
|
|
@@ -3633,8 +3943,9 @@ declare class ContestClient extends BaseClient {
|
|
|
3633
3943
|
* ### Currency Client
|
|
3634
3944
|
*
|
|
3635
3945
|
* Client used to access the Currency Endpoints:
|
|
3636
|
-
*
|
|
3637
|
-
*
|
|
3946
|
+
*
|
|
3947
|
+
* - [Currencies](https://pokeapi.co/docs/v2#currencies)
|
|
3948
|
+
*
|
|
3638
3949
|
* See [PokéAPI Documentation](https://pokeapi.co/docs/v2#currencies-section)
|
|
3639
3950
|
*/
|
|
3640
3951
|
declare class CurrencyClient extends BaseClient {
|
|
@@ -3651,10 +3962,11 @@ declare class CurrencyClient extends BaseClient {
|
|
|
3651
3962
|
* ### Encounter Client
|
|
3652
3963
|
*
|
|
3653
3964
|
* Client used to access the Encounter Endpoints:
|
|
3654
|
-
*
|
|
3655
|
-
*
|
|
3656
|
-
*
|
|
3657
|
-
*
|
|
3965
|
+
*
|
|
3966
|
+
* - [Encounter Methods](https://pokeapi.co/docs/v2#encounter-methods)
|
|
3967
|
+
* - [Encounter Conditions](https://pokeapi.co/docs/v2#encounter-conditions)
|
|
3968
|
+
* - [Encounter Condition Values](https://pokeapi.co/docs/v2#encounter-condition-values)
|
|
3969
|
+
*
|
|
3658
3970
|
* See [PokéAPI Documentation](https://pokeapi.co/docs/v2#encounters-section)
|
|
3659
3971
|
*/
|
|
3660
3972
|
declare class EncounterClient extends BaseClient {
|
|
@@ -3683,9 +3995,10 @@ declare class EncounterClient extends BaseClient {
|
|
|
3683
3995
|
* ### Evolution Client
|
|
3684
3996
|
*
|
|
3685
3997
|
* Client used to access the Evolution Endpoints:
|
|
3686
|
-
*
|
|
3687
|
-
*
|
|
3688
|
-
*
|
|
3998
|
+
*
|
|
3999
|
+
* - [Evolution Chains](https://pokeapi.co/docs/v2#evolution-chains)
|
|
4000
|
+
* - [Evolution Triggers](https://pokeapi.co/docs/v2#evolution-triggers)
|
|
4001
|
+
*
|
|
3689
4002
|
* See [PokéAPI Documentation](https://pokeapi.co/docs/v2#evolution-section)
|
|
3690
4003
|
*/
|
|
3691
4004
|
declare class EvolutionClient extends BaseClient {
|
|
@@ -3706,11 +4019,12 @@ declare class EvolutionClient extends BaseClient {
|
|
|
3706
4019
|
* ### Game Client
|
|
3707
4020
|
*
|
|
3708
4021
|
* Client used to access the Game Endpoints:
|
|
3709
|
-
*
|
|
3710
|
-
*
|
|
3711
|
-
*
|
|
3712
|
-
*
|
|
3713
|
-
*
|
|
4022
|
+
*
|
|
4023
|
+
* - [Generations](https://pokeapi.co/docs/v2#generations)
|
|
4024
|
+
* - [Pokédexes](https://pokeapi.co/docs/v2#pokedexes)
|
|
4025
|
+
* - [Versions](https://pokeapi.co/docs/v2#version)
|
|
4026
|
+
* - [Version Groups](https://pokeapi.co/docs/v2#version-groups)
|
|
4027
|
+
*
|
|
3714
4028
|
* See [PokéAPI Documentation](https://pokeapi.co/docs/v2#games-section)
|
|
3715
4029
|
*/
|
|
3716
4030
|
declare class GameClient extends BaseClient {
|
|
@@ -3745,12 +4059,13 @@ declare class GameClient extends BaseClient {
|
|
|
3745
4059
|
* ### Item Client
|
|
3746
4060
|
*
|
|
3747
4061
|
* Client used to access the Item Endpoints:
|
|
3748
|
-
*
|
|
3749
|
-
*
|
|
3750
|
-
*
|
|
3751
|
-
*
|
|
3752
|
-
*
|
|
3753
|
-
*
|
|
4062
|
+
*
|
|
4063
|
+
* - [Items](https://pokeapi.co/docs/v2#item)
|
|
4064
|
+
* - [Item Attributes](https://pokeapi.co/docs/v2#item-attributes)
|
|
4065
|
+
* - [Item Categories](https://pokeapi.co/docs/v2#item-categories)
|
|
4066
|
+
* - [Item Fling Effects](https://pokeapi.co/docs/v2#item-fling-effects)
|
|
4067
|
+
* - [Item Pockets](https://pokeapi.co/docs/v2#item-pockets)
|
|
4068
|
+
*
|
|
3754
4069
|
* See [PokéAPI Documentation](https://pokeapi.co/docs/v2#items-section)
|
|
3755
4070
|
*/
|
|
3756
4071
|
declare class ItemClient extends BaseClient {
|
|
@@ -3791,11 +4106,12 @@ declare class ItemClient extends BaseClient {
|
|
|
3791
4106
|
* ### Location Client
|
|
3792
4107
|
*
|
|
3793
4108
|
* Client used to access the Location Endpoints:
|
|
3794
|
-
*
|
|
3795
|
-
*
|
|
3796
|
-
*
|
|
3797
|
-
*
|
|
3798
|
-
*
|
|
4109
|
+
*
|
|
4110
|
+
* - [Locations](https://pokeapi.co/docs/v2#locations)
|
|
4111
|
+
* - [Location Areas](https://pokeapi.co/docs/v2#location-areas)
|
|
4112
|
+
* - [Pal Park Areas](https://pokeapi.co/docs/v2#pal-park-areas)
|
|
4113
|
+
* - [Regions](https://pokeapi.co/docs/v2#regions)
|
|
4114
|
+
*
|
|
3799
4115
|
* See [PokéAPI Documentation](https://pokeapi.co/docs/v2#locations-section)
|
|
3800
4116
|
*/
|
|
3801
4117
|
declare class LocationClient extends BaseClient {
|
|
@@ -3830,8 +4146,9 @@ declare class LocationClient extends BaseClient {
|
|
|
3830
4146
|
* ### Machine Client
|
|
3831
4147
|
*
|
|
3832
4148
|
* Client used to access the Machine Endpoints:
|
|
3833
|
-
*
|
|
3834
|
-
*
|
|
4149
|
+
*
|
|
4150
|
+
* - [Machines](https://pokeapi.co/docs/v2#machines)
|
|
4151
|
+
*
|
|
3835
4152
|
* See [PokéAPI Documentation](https://pokeapi.co/docs/v2#machines-section)
|
|
3836
4153
|
*/
|
|
3837
4154
|
declare class MachineClient extends BaseClient {
|
|
@@ -3846,14 +4163,15 @@ declare class MachineClient extends BaseClient {
|
|
|
3846
4163
|
* ### Move Client
|
|
3847
4164
|
*
|
|
3848
4165
|
* Client used to access the Move Endpoints:
|
|
3849
|
-
*
|
|
3850
|
-
*
|
|
3851
|
-
*
|
|
3852
|
-
*
|
|
3853
|
-
*
|
|
3854
|
-
*
|
|
3855
|
-
*
|
|
3856
|
-
*
|
|
4166
|
+
*
|
|
4167
|
+
* - [Moves](https://pokeapi.co/docs/v2#moves)
|
|
4168
|
+
* - [Move Ailments](https://pokeapi.co/docs/v2#move-ailments)
|
|
4169
|
+
* - [Move Battle Styles](https://pokeapi.co/docs/v2#move-battle-styles)
|
|
4170
|
+
* - [Move Categories](https://pokeapi.co/docs/v2#move-categories)
|
|
4171
|
+
* - [Move Damage Classes](https://pokeapi.co/docs/v2#move-damage-classes)
|
|
4172
|
+
* - [Move Learn Methods](https://pokeapi.co/docs/v2#move-learn-methods)
|
|
4173
|
+
* - [Move Targets](https://pokeapi.co/docs/v2#move-targets)
|
|
4174
|
+
*
|
|
3857
4175
|
* See [PokéAPI Documentation](https://pokeapi.co/docs/v2#moves-section)
|
|
3858
4176
|
*/
|
|
3859
4177
|
declare class MoveClient extends BaseClient {
|
|
@@ -3906,23 +4224,24 @@ declare class MoveClient extends BaseClient {
|
|
|
3906
4224
|
* ### Pokémon Client
|
|
3907
4225
|
*
|
|
3908
4226
|
* Client used to access the Pokémon Endpoints:
|
|
3909
|
-
*
|
|
3910
|
-
*
|
|
3911
|
-
*
|
|
3912
|
-
*
|
|
3913
|
-
*
|
|
3914
|
-
*
|
|
3915
|
-
*
|
|
3916
|
-
*
|
|
3917
|
-
*
|
|
3918
|
-
*
|
|
3919
|
-
*
|
|
3920
|
-
*
|
|
3921
|
-
*
|
|
3922
|
-
*
|
|
3923
|
-
*
|
|
3924
|
-
*
|
|
3925
|
-
*
|
|
4227
|
+
*
|
|
4228
|
+
* - [Abilities](https://pokeapi.co/docs/v2#abilities)
|
|
4229
|
+
* - [Characteristics](https://pokeapi.co/docs/v2#characteristics)
|
|
4230
|
+
* - [Egg Groups](https://pokeapi.co/docs/v2#egg-groups)
|
|
4231
|
+
* - [Genders](https://pokeapi.co/docs/v2#genders)
|
|
4232
|
+
* - [Growth Rates](https://pokeapi.co/docs/v2#growth-rates)
|
|
4233
|
+
* - [Natures](https://pokeapi.co/docs/v2#natures)
|
|
4234
|
+
* - [Pokéathlon Stats](https://pokeapi.co/docs/v2#pokeathlon-stats)
|
|
4235
|
+
* - [Pokémon](https://pokeapi.co/docs/v2#pokemon)
|
|
4236
|
+
* - [Pokémon Location Areas](https://pokeapi.co/docs/v2#pokemon-location-areas)
|
|
4237
|
+
* - [Pokémon Colors](https://pokeapi.co/docs/v2#pokemon-colors)
|
|
4238
|
+
* - [Pokémon Forms](https://pokeapi.co/docs/v2#pokemon-forms)
|
|
4239
|
+
* - [Pokémon Habitats](https://pokeapi.co/docs/v2#pokemon-habitats)
|
|
4240
|
+
* - [Pokémon Shapes](https://pokeapi.co/docs/v2#pokemon-shapes)
|
|
4241
|
+
* - [Pokémon Species](https://pokeapi.co/docs/v2#pokemon-species)
|
|
4242
|
+
* - [Stats](https://pokeapi.co/docs/v2#stats)
|
|
4243
|
+
* - [Types](https://pokeapi.co/docs/v2#types)
|
|
4244
|
+
*
|
|
3926
4245
|
* See [PokéAPI Documentation](https://pokeapi.co/docs/v2#pokemon-section)
|
|
3927
4246
|
*/
|
|
3928
4247
|
declare class PokemonClient extends BaseClient {
|
|
@@ -4026,9 +4345,10 @@ declare class PokemonClient extends BaseClient {
|
|
|
4026
4345
|
* ### Utility Client
|
|
4027
4346
|
*
|
|
4028
4347
|
* Client used to access the Utility Endpoints:
|
|
4029
|
-
*
|
|
4030
|
-
*
|
|
4031
|
-
*
|
|
4348
|
+
*
|
|
4349
|
+
* - [Languages](https://pokeapi.co/docs/v2#languages)
|
|
4350
|
+
* - [Resources](https://pokeapi.co/docs/v2#resource-listspagination-section)
|
|
4351
|
+
*
|
|
4032
4352
|
* See [PokéAPI Documentation](https://pokeapi.co/docs/v2#utility-section)
|
|
4033
4353
|
*/
|
|
4034
4354
|
declare class UtilityClient extends BaseClient {
|
|
@@ -4039,19 +4359,20 @@ declare class UtilityClient extends BaseClient {
|
|
|
4039
4359
|
/**
|
|
4040
4360
|
* Get any resource by its URL, or by a link taken from another response.
|
|
4041
4361
|
*
|
|
4042
|
-
* A link carries what it points at, so the result is typed without saying so:
|
|
4043
|
-
*
|
|
4044
4362
|
* ```ts
|
|
4045
4363
|
* const pokemon = await api.pokemon.getPokemonByName('luxray');
|
|
4046
4364
|
* const species = await api.utility.getResourceByUrl(pokemon.species);
|
|
4047
4365
|
* // ^? PokemonSpecies
|
|
4048
4366
|
* ```
|
|
4049
4367
|
*
|
|
4368
|
+
* Every client carries {@link BaseClient.resolve}, which does the same thing;
|
|
4369
|
+
* this is the name it went out under, and it stays.
|
|
4370
|
+
*
|
|
4050
4371
|
* @param resource The absolute URL of the resource, or a link to it.
|
|
4051
4372
|
* @returns The resource the URL points at.
|
|
4052
4373
|
* @throws {TypeError} If the URL is not valid, or names no PokéAPI endpoint.
|
|
4053
4374
|
*/
|
|
4054
|
-
getResourceByUrl<T>(resource:
|
|
4375
|
+
getResourceByUrl<T>(resource: ResourceLink<T>): Promise<T>;
|
|
4055
4376
|
/** List Languages. Page defaults to 20 entries from offset 0. */
|
|
4056
4377
|
listLanguages(offset?: number, limit?: number): Promise<NamedAPIResourceList<Language>>;
|
|
4057
4378
|
}
|
|
@@ -4061,26 +4382,31 @@ declare class UtilityClient extends BaseClient {
|
|
|
4061
4382
|
* ### Main Client
|
|
4062
4383
|
*
|
|
4063
4384
|
* The main client used to access all the PokéAPI Endpoints:
|
|
4064
|
-
*
|
|
4065
|
-
*
|
|
4066
|
-
*
|
|
4067
|
-
*
|
|
4068
|
-
*
|
|
4069
|
-
*
|
|
4070
|
-
*
|
|
4071
|
-
*
|
|
4072
|
-
*
|
|
4073
|
-
*
|
|
4074
|
-
*
|
|
4075
|
-
*
|
|
4076
|
-
*
|
|
4077
|
-
*
|
|
4078
|
-
*
|
|
4385
|
+
*
|
|
4386
|
+
* - [Berries](https://pokeapi.co/docs/v2#berries-section)
|
|
4387
|
+
* - [Contests](https://pokeapi.co/docs/v2#contests-section)
|
|
4388
|
+
* - [Currencies](https://pokeapi.co/docs/v2#currencies-section)
|
|
4389
|
+
* - [Encounters](https://pokeapi.co/docs/v2#encounters-section)
|
|
4390
|
+
* - [Evolution](https://pokeapi.co/docs/v2#evolution-section)
|
|
4391
|
+
* - [Games](https://pokeapi.co/docs/v2#games-section)
|
|
4392
|
+
* - [Items](https://pokeapi.co/docs/v2#items-section)
|
|
4393
|
+
* - [Locations](https://pokeapi.co/docs/v2#locations-section)
|
|
4394
|
+
* - [Machines](https://pokeapi.co/docs/v2#machines-section)
|
|
4395
|
+
* - [Moves](https://pokeapi.co/docs/v2#moves-section)
|
|
4396
|
+
* - [Pokémon](https://pokeapi.co/docs/v2#pokemon-section)
|
|
4397
|
+
* - [Utility](https://pokeapi.co/docs/v2#utility-section)
|
|
4398
|
+
*
|
|
4399
|
+
* All the clients below share a single transport, so a resource fetched through
|
|
4400
|
+
* one of them is served from cache by the rest — and two of them asking for the
|
|
4401
|
+
* same URL at once make one round trip, not two.
|
|
4402
|
+
*
|
|
4403
|
+
* Composes its sections rather than inheriting from them: it extends
|
|
4404
|
+
* {@link ClientFacade}, not {@link BaseClient}, so it carries no endpoint of its
|
|
4405
|
+
* own.
|
|
4079
4406
|
*
|
|
4080
4407
|
* See [PokéAPI Documentation](https://pokeapi.co/docs/v2)
|
|
4081
4408
|
*/
|
|
4082
|
-
declare class MainClient {
|
|
4083
|
-
readonly cache: CacheStore | undefined;
|
|
4409
|
+
declare class MainClient extends ClientFacade {
|
|
4084
4410
|
readonly berry: BerryClient;
|
|
4085
4411
|
readonly contest: ContestClient;
|
|
4086
4412
|
readonly currency: CurrencyClient;
|
|
@@ -4093,9 +4419,7 @@ declare class MainClient {
|
|
|
4093
4419
|
readonly move: MoveClient;
|
|
4094
4420
|
readonly pokemon: PokemonClient;
|
|
4095
4421
|
readonly utility: UtilityClient;
|
|
4096
|
-
constructor(
|
|
4097
|
-
/** Drops every cached response, for all the clients at once. */
|
|
4098
|
-
clearCache(): Promise<void>;
|
|
4422
|
+
constructor(options?: ClientOptions);
|
|
4099
4423
|
}
|
|
4100
4424
|
//#endregion
|
|
4101
4425
|
//#region src/config/errors.d.ts
|
|
@@ -4115,11 +4439,48 @@ declare class PokenodeError extends Error {
|
|
|
4115
4439
|
readonly url: string;
|
|
4116
4440
|
/** Parsed response body, when the error response carried JSON. */
|
|
4117
4441
|
readonly body: unknown;
|
|
4118
|
-
|
|
4442
|
+
/**
|
|
4443
|
+
* @param message Overrides the default text, for a status whose failure is not
|
|
4444
|
+
* self-explanatory.
|
|
4445
|
+
*/
|
|
4446
|
+
constructor(response: Response, body: unknown, message?: string);
|
|
4119
4447
|
/** Whether the error came from a pokenode-ts client. */
|
|
4120
4448
|
static isPokenodeError(error: unknown): error is PokenodeError;
|
|
4121
4449
|
}
|
|
4122
4450
|
//#endregion
|
|
4451
|
+
//#region src/utils/localize.d.ts
|
|
4452
|
+
/**
|
|
4453
|
+
* ## Localized
|
|
4454
|
+
* An entry the PokéAPI publishes once per language — a `Name`, `FlavorText`,
|
|
4455
|
+
* `Description`, `Effect`, `VerboseEffect`, and everything shaped like them.
|
|
4456
|
+
*/
|
|
4457
|
+
interface Localized {
|
|
4458
|
+
language: NamedAPIResource<Language>;
|
|
4459
|
+
}
|
|
4460
|
+
/**
|
|
4461
|
+
* Picks the entry written in `language`, by the name the PokéAPI gives that
|
|
4462
|
+
* language: `en`, `ja`, `ja-hrkt`, `zh-hans`, `es-419`, and so on.
|
|
4463
|
+
*
|
|
4464
|
+
* ```ts
|
|
4465
|
+
* const species = await api.pokemon.getPokemonSpeciesByName('eevee');
|
|
4466
|
+
*
|
|
4467
|
+
* localize(species.names)?.name; // 'Eevee'
|
|
4468
|
+
* localize(species.names, 'ja')?.name; // 'イーブイ'
|
|
4469
|
+
* ```
|
|
4470
|
+
*
|
|
4471
|
+
* Matched without regard to case: the PokéAPI writes these tags in lower case,
|
|
4472
|
+
* while BCP 47 capitalizes the script subtag — `ja-Hrkt` is the form anyone used
|
|
4473
|
+
* to language tags will reach for, and it should not silently match nothing.
|
|
4474
|
+
*
|
|
4475
|
+
* A section may list several entries for one language — flavor text, one per
|
|
4476
|
+
* version — and the first is the one returned. Filter first when you want a
|
|
4477
|
+
* particular version.
|
|
4478
|
+
*
|
|
4479
|
+
* @returns The entry, or `undefined` when that language is absent. Which
|
|
4480
|
+
* language to try instead is the caller's decision, so nothing is guessed here.
|
|
4481
|
+
*/
|
|
4482
|
+
declare const localize: <T extends Localized>(entries: readonly T[], language?: string) => T | undefined;
|
|
4483
|
+
//#endregion
|
|
4123
4484
|
//#region src/utils/sprites.d.ts
|
|
4124
4485
|
/**
|
|
4125
4486
|
* ## Sprite Variant
|
|
@@ -4180,5 +4541,5 @@ type PokemonSpriteOptions = {
|
|
|
4180
4541
|
*/
|
|
4181
4542
|
declare const getPokemonSpriteUrl: (id: number, options?: PokemonSpriteOptions) => string;
|
|
4182
4543
|
//#endregion
|
|
4183
|
-
export { APIResource, APIResourceList, Ability, AbilityEffectChange, AbilityFlavorText, AbilityPokemon, Animated, AwesomeName, BASE_URL, BERRIES, BERRY_FIRMNESSES, BERRY_FLAVORS, Berry, BerryClient, BerryFirmness, BerryFlavor, BerryFlavorMap, BlackWhite, BrilliantDiamondShiningPearl, index_d_exports as CONSTANTS, CONTEST_TYPES, CURRENCIES, type CacheStore, ChainLink, Characteristic, type ClientOptions, ContestClient, ContestComboDetail, ContestComboSets, ContestEffect, ContestFlavorText, ContestName, ContestType, Crystal, Currency, CurrencyClient, Description, DiamondPearl, DreamWorld, EGG_GROUPS, ENCOUNTER_CONDITIONS, ENCOUNTER_CONDITION_VALUES, ENCOUNTER_METHODS, ENDPOINTS, EVOLUTION_TRIGGERS, Effect, EggGroup, Emerald, Encounter, EncounterClient, EncounterCondition, EncounterConditionValue, EncounterMethod, EncounterMethodRate, EncounterPokemonDetail, EncounterVersionDetails, Endpoint, EvolutionChain, EvolutionClient, EvolutionDetail, EvolutionTrigger, type FetchLike, FireredLeafgreen, FlavorBerryMap, FlavorText, GENDERS, GENERATIONS, GROWTH_RATES, GameClient, Gender, Generation, GenerationGameIndex, GenerationIIISprites, GenerationIIITypeSprites, GenerationIISprites, GenerationISprites, GenerationIVSprites, GenerationIVTypeSprites, GenerationIXSprites, GenerationIXTypeSprites, GenerationVIIISprites, GenerationVIIITypeSprites, GenerationVIISprites, GenerationVIITypeSprites, GenerationVISprites, GenerationVITypeSprites, GenerationVSprites, GenerationVTypeSprites, GenerationViiIcons, GenerationViiiIcons, Genus, Gold, GrowthRate, GrowthRateExperienceLevel, HeartgoldSoulsilver, Home, ITEM_ATTRIBUTES, ITEM_CATEGORIES, ITEM_FLING_EFFECTS, ITEM_POCKETS, Item, ItemAttribute, ItemCategory, ItemClient, ItemFlingEffect, ItemHolderPokemon, ItemHolderPokemonVersionDetail, ItemPocket, ItemPrice, ItemSprites, LANGUAGES, Language, Location, LocationArea, LocationAreaEncounter, LocationClient, type LogErrorPayload, type LogRequestPayload, type LogResponsePayload, type Logger, MOVE_AILMENTS, MOVE_BATTLE_STYLES, MOVE_CATEGORIES, MOVE_DAMAGE_CLASSES, MOVE_LEARN_METHODS, MOVE_TARGETS, Machine, MachineClient, MachineVersionDetail, MainClient, MemoryCache, type MemoryCacheOptions, Move, MoveAilment, MoveBattleStyle, MoveBattleStylePreference, MoveCategory, MoveClient, MoveDamageClass, MoveFlavorText, MoveLearnMethod, MoveMetaData, MoveStatAffect, MoveStatAffectSets, MoveStatChange, MoveTarget, NATURES, Name, NamedAPIResource, NamedAPIResourceList, Nature, NaturePokeathlonStatAffect, NaturePokeathlonStatAffectSets, NatureStatAffectSets, NatureStatChange, OfficialArtwork, OmegarubyAlphasapphire, OtherPokemonSprites, PAL_PARK_AREAS, POKEATHLON_STATS, POKEDEXES, POKEMON_COLORS, POKEMON_HABITATS, POKEMON_SHAPES, PalParkArea, PalParkEncounterArea, PalParkEncounterSpecies, PastMoveStatValues, Platinum, PokeathlonStat, Pokedex, Pokemon, PokemonAbility, PokemonClient, PokemonColor, PokemonCries, PokemonEncounter, PokemonEntry, PokemonForm, PokemonFormCondition, PokemonFormGenerationVIIISprites, PokemonFormSprites, PokemonFormVersionSprites, PokemonHabitat, PokemonHeldItem, PokemonHeldItemVersion, PokemonMove, PokemonMoveVersion, PokemonPastAbility, PokemonPastAbilitySlot, PokemonPastStat, PokemonPastType, PokemonShape, PokemonSpecies, PokemonSpeciesDexEntry, PokemonSpeciesGender, PokemonSpeciesVariety, PokemonSpriteOptions, PokemonSprites, PokemonStat, PokemonType, PokenodeError, REGIONS, RedBlue, Region, RubySapphire, STATS, ScarletViolet, Showdown, Silver, SpriteVariant, Stat, SuperContestEffect, TYPES, Type, TypeGameSprites, TypePokemon, TypeRelations, TypeRelationsPast, TypeSprites, UltraSunUltraMoon, UtilityClient, VERSIONS, VERSION_GROUPS, VerboseEffect, Version, VersionEncounterDetail, VersionGameIndex, VersionGroup, VersionGroupFlavorText, VersionSprites, WebStorageCache, type WebStorageCacheOptions, type WebStorageLike, XY, Yellow, consoleLogger, getPokemonSpriteUrl };
|
|
4544
|
+
export { APIResource, APIResourceList, Ability, AbilityEffectChange, AbilityFlavorText, AbilityPokemon, Animated, AwesomeName, BASE_URL, BERRIES, BERRY_FIRMNESSES, BERRY_FLAVORS, Berry, BerryClient, BerryFirmness, BerryFlavor, BerryFlavorMap, BlackWhite, BrilliantDiamondShiningPearl, index_d_exports as CONSTANTS, CONTEST_TYPES, CURRENCIES, type CacheStore, ChainLink, Characteristic, type ClientOptions, ContestClient, ContestComboDetail, ContestComboSets, ContestEffect, ContestFlavorText, ContestName, ContestType, Crystal, Currency, CurrencyClient, Description, DiamondPearl, DreamWorld, EGG_GROUPS, ENCOUNTER_CONDITIONS, ENCOUNTER_CONDITION_VALUES, ENCOUNTER_METHODS, ENDPOINTS, EVOLUTION_TRIGGERS, Effect, EggGroup, Emerald, Encounter, EncounterClient, EncounterCondition, EncounterConditionValue, EncounterMethod, EncounterMethodRate, EncounterPokemonDetail, EncounterVersionDetails, Endpoint, type EtagEntry, EtagStore, type EtagStoreOptions, EvolutionChain, EvolutionClient, EvolutionDetail, EvolutionTrigger, type FetchLike, FireredLeafgreen, FlavorBerryMap, FlavorText, GENDERS, GENERATIONS, GROWTH_RATES, GameClient, Gender, Generation, GenerationGameIndex, GenerationIIISprites, GenerationIIITypeSprites, GenerationIISprites, GenerationISprites, GenerationIVSprites, GenerationIVTypeSprites, GenerationIXSprites, GenerationIXTypeSprites, GenerationVIIISprites, GenerationVIIITypeSprites, GenerationVIISprites, GenerationVIITypeSprites, GenerationVISprites, GenerationVITypeSprites, GenerationVSprites, GenerationVTypeSprites, GenerationViiIcons, GenerationViiiIcons, Genus, Gold, GrowthRate, GrowthRateExperienceLevel, HeartgoldSoulsilver, Home, ITEM_ATTRIBUTES, ITEM_CATEGORIES, ITEM_FLING_EFFECTS, ITEM_POCKETS, Item, ItemAttribute, ItemCategory, ItemClient, ItemFlingEffect, ItemHolderPokemon, ItemHolderPokemonVersionDetail, ItemPocket, ItemPrice, ItemSprites, LANGUAGES, Language, type ListFn, type ListMethodName, type ListPage, type Localized, Location, LocationArea, LocationAreaEncounter, LocationClient, type LogCancelledPayload, type LogErrorPayload, type LogRequestPayload, type LogResponsePayload, type LogRetryPayload, type Logger, MOVE_AILMENTS, MOVE_BATTLE_STYLES, MOVE_CATEGORIES, MOVE_DAMAGE_CLASSES, MOVE_LEARN_METHODS, MOVE_TARGETS, Machine, MachineClient, MachineVersionDetail, MainClient, MemoryCache, type MemoryCacheOptions, Move, MoveAilment, MoveBattleStyle, MoveBattleStylePreference, MoveCategory, MoveClient, MoveDamageClass, MoveFlavorText, MoveLearnMethod, MoveMetaData, MoveStatAffect, MoveStatAffectSets, MoveStatChange, MoveTarget, NATURES, Name, NamedAPIResource, NamedAPIResourceList, Nature, NaturePokeathlonStatAffect, NaturePokeathlonStatAffectSets, NatureStatAffectSets, NatureStatChange, OfficialArtwork, OmegarubyAlphasapphire, OtherPokemonSprites, PAL_PARK_AREAS, POKEATHLON_STATS, POKEDEXES, POKEMON_COLORS, POKEMON_HABITATS, POKEMON_SHAPES, type PaginateOptions, PalParkArea, PalParkEncounterArea, PalParkEncounterSpecies, PastMoveStatValues, Platinum, PokeathlonStat, Pokedex, Pokemon, PokemonAbility, PokemonClient, PokemonColor, PokemonCries, PokemonEncounter, PokemonEntry, PokemonForm, PokemonFormCondition, PokemonFormGenerationVIIISprites, PokemonFormSprites, PokemonFormVersionSprites, PokemonHabitat, PokemonHeldItem, PokemonHeldItemVersion, PokemonMove, PokemonMoveVersion, PokemonPastAbility, PokemonPastAbilitySlot, PokemonPastStat, PokemonPastType, PokemonShape, PokemonSpecies, PokemonSpeciesDexEntry, PokemonSpeciesGender, PokemonSpeciesVariety, type PokemonSpriteOptions, PokemonSprites, PokemonStat, PokemonType, PokenodeError, REGIONS, RedBlue, Region, type RequestScope, type ResolveOptions, type ResourceLink, type RetryOptions, RubySapphire, STATS, ScarletViolet, Showdown, Silver, type SpriteVariant, Stat, SuperContestEffect, TYPES, Type, TypeGameSprites, TypePokemon, TypeRelations, TypeRelationsPast, TypeSprites, UltraSunUltraMoon, UtilityClient, VERSIONS, VERSION_GROUPS, VerboseEffect, Version, VersionEncounterDetail, VersionGameIndex, VersionGroup, VersionGroupFlavorText, VersionSprites, WebStorageCache, type WebStorageCacheOptions, type WebStorageLike, XY, Yellow, consoleLogger, getPokemonSpriteUrl, localize };
|
|
4184
4545
|
//# sourceMappingURL=index.d.cts.map
|