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