eve-esi-types 3.1.6 → 3.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/CHANGELOG.md +182 -0
- package/jsconfig.json +28 -0
- package/lib/rq-util.mjs +1 -1
- package/lib/tagged-request-api.mjs +5 -6
- package/package.json +14 -8
- package/v2/esi-tagged-types.d.ts +9 -5
- package/v2/{get_alliances_alliance_id_ok.d.ts → globals/alliance.d.ts} +44 -0
- package/v2/globals/assets.d.ts +443 -0
- package/v2/globals/calendar.d.ts +130 -0
- package/v2/globals/character.d.ts +1084 -0
- package/v2/{get_characters_character_id_clones_ok.d.ts → globals/clones.d.ts} +15 -0
- package/v2/globals/contacts.d.ts +212 -0
- package/v2/globals/contracts.d.ts +546 -0
- package/v2/globals/corporation.d.ts +2329 -0
- package/v2/globals/dogma.d.ts +262 -0
- package/v2/globals/factionwarfare.d.ts +668 -0
- package/v2/{get_characters_character_id_fittings_ok.d.ts → globals/fittings.d.ts} +23 -0
- package/v2/globals/fleets.d.ts +201 -0
- package/v2/{get_incursions_ok.d.ts → globals/incursions.d.ts} +5 -0
- package/v2/globals/industry.d.ts +445 -0
- package/v2/globals/insurance.d.ts +47 -0
- package/v2/{get_killmails_killmail_id_killmail_hash_ok.d.ts → globals/killmails.d.ts} +55 -0
- package/v2/globals/location.d.ts +74 -0
- package/v2/{get_loyalty_stores_corporation_id_offers_ok.d.ts → globals/loyalty.d.ts} +30 -0
- package/v2/globals/mail.d.ts +237 -0
- package/v2/globals/market.d.ts +615 -0
- package/v2/globals/planetaryinteraction.d.ts +344 -0
- package/v2/globals/routes.d.ts +14 -0
- package/v2/{get_characters_character_id_search_ok.d.ts → globals/search.d.ts} +5 -0
- package/v2/globals/skills.d.ts +144 -0
- package/v2/globals/sovereignty.d.ts +168 -0
- package/v2/{get_status_ok.d.ts → globals/status.d.ts} +5 -0
- package/v2/globals/universe.d.ts +1297 -0
- package/v2/globals/wallet.d.ts +601 -0
- package/v2/{get_wars_war_id_ok.d.ts → globals/wars.d.ts} +40 -0
- package/v2/index.d.ts +38 -163
- package/v2/response-map.d.ts +22 -45
- package/v2/types-index.d.ts +31 -182
- package/v2/types-util.d.ts +335 -0
- package/v2/util.d.ts +4 -2
- package/web/index.html +1 -1
- package/docs/esi-tagged-types.md +0 -120
- package/docs/v2/identify-parameters.md +0 -74
- package/docs/v2/if-parameterized-path.md +0 -70
- package/docs/v2/infer-esi-response-result.md +0 -44
- package/docs/v2/require-these.md +0 -57
- package/docs/v3/esi-enhanced-function-signature.md +0 -67
- package/docs/v3/esi-types-util3.md +0 -319
- package/docs/v3/has-require-params.md +0 -50
- package/docs/v3/infer-endpoint-origin.md +0 -57
- package/docs/v3/infer-path-params.md +0 -41
- package/docs/v3/pick-require-params.md +0 -56
- package/docs/v3/replace-path-params.md +0 -60
- package/docs/v3/resolved-endpoint.md +0 -44
- package/tsconfig.json +0 -28
- package/v2/get_alliances_alliance_id_contacts_labels_ok.d.ts +0 -24
- package/v2/get_alliances_alliance_id_contacts_ok.d.ts +0 -35
- package/v2/get_alliances_alliance_id_corporations_ok.d.ts +0 -9
- package/v2/get_alliances_alliance_id_icons_ok.d.ts +0 -18
- package/v2/get_alliances_ok.d.ts +0 -9
- package/v2/get_characters_character_id_agents_research_ok.d.ts +0 -33
- package/v2/get_characters_character_id_assets_ok.d.ts +0 -134
- package/v2/get_characters_character_id_attributes_ok.d.ts +0 -42
- package/v2/get_characters_character_id_blueprints_ok.d.ts +0 -122
- package/v2/get_characters_character_id_calendar_event_id_attendees_ok.d.ts +0 -30
- package/v2/get_characters_character_id_calendar_event_id_ok.d.ts +0 -56
- package/v2/get_characters_character_id_calendar_ok.d.ts +0 -37
- package/v2/get_characters_character_id_contacts_labels_ok.d.ts +0 -24
- package/v2/get_characters_character_id_contacts_ok.d.ts +0 -43
- package/v2/get_characters_character_id_contracts_contract_id_bids_ok.d.ts +0 -32
- package/v2/get_characters_character_id_contracts_contract_id_items_ok.d.ts +0 -38
- package/v2/get_characters_character_id_contracts_ok.d.ts +0 -117
- package/v2/get_characters_character_id_corporationhistory_ok.d.ts +0 -32
- package/v2/get_characters_character_id_fatigue_ok.d.ts +0 -22
- package/v2/get_characters_character_id_fleet_ok.d.ts +0 -31
- package/v2/get_characters_character_id_fw_stats_ok.d.ts +0 -64
- package/v2/get_characters_character_id_implants_ok.d.ts +0 -9
- package/v2/get_characters_character_id_industry_jobs_ok.d.ts +0 -105
- package/v2/get_characters_character_id_killmails_recent_ok.d.ts +0 -24
- package/v2/get_characters_character_id_location_ok.d.ts +0 -22
- package/v2/get_characters_character_id_loyalty_points_ok.d.ts +0 -24
- package/v2/get_characters_character_id_mail_labels_ok.d.ts +0 -62
- package/v2/get_characters_character_id_mail_lists_ok.d.ts +0 -24
- package/v2/get_characters_character_id_mail_mail_id_ok.d.ts +0 -59
- package/v2/get_characters_character_id_mail_ok.d.ts +0 -65
- package/v2/get_characters_character_id_medals_ok.d.ts +0 -135
- package/v2/get_characters_character_id_mining_ok.d.ts +0 -29
- package/v2/get_characters_character_id_notifications_contacts_ok.d.ts +0 -36
- package/v2/get_characters_character_id_notifications_ok.d.ts +0 -291
- package/v2/get_characters_character_id_ok.d.ts +0 -55
- package/v2/get_characters_character_id_online_ok.d.ts +0 -26
- package/v2/get_characters_character_id_opportunities_ok.d.ts +0 -24
- package/v2/get_characters_character_id_orders_history_ok.d.ts +0 -87
- package/v2/get_characters_character_id_orders_ok.d.ts +0 -82
- package/v2/get_characters_character_id_planets_ok.d.ts +0 -124
- package/v2/get_characters_character_id_planets_planet_id_ok.d.ts +0 -283
- package/v2/get_characters_character_id_portrait_ok.d.ts +0 -26
- package/v2/get_characters_character_id_roles_ok.d.ts +0 -270
- package/v2/get_characters_character_id_ship_ok.d.ts +0 -19
- package/v2/get_characters_character_id_skillqueue_ok.d.ts +0 -48
- package/v2/get_characters_character_id_skills_ok.d.ts +0 -47
- package/v2/get_characters_character_id_standings_ok.d.ts +0 -29
- package/v2/get_characters_character_id_titles_ok.d.ts +0 -184
- package/v2/get_characters_character_id_wallet_journal_ok.d.ts +0 -228
- package/v2/get_characters_character_id_wallet_ok.d.ts +0 -7
- package/v2/get_characters_character_id_wallet_transactions_ok.d.ts +0 -53
- package/v2/get_contracts_public_bids_contract_id_ok.d.ts +0 -28
- package/v2/get_contracts_public_items_contract_id_ok.d.ts +0 -49
- package/v2/get_contracts_public_region_id_ok.d.ts +0 -81
- package/v2/get_corporation_corporation_id_mining_extractions_ok.d.ts +0 -39
- package/v2/get_corporation_corporation_id_mining_observers_observer_id_ok.d.ts +0 -36
- package/v2/get_corporation_corporation_id_mining_observers_ok.d.ts +0 -30
- package/v2/get_corporations_corporation_id_alliancehistory_ok.d.ts +0 -32
- package/v2/get_corporations_corporation_id_assets_ok.d.ts +0 -170
- package/v2/get_corporations_corporation_id_blueprints_ok.d.ts +0 -163
- package/v2/get_corporations_corporation_id_contacts_labels_ok.d.ts +0 -24
- package/v2/get_corporations_corporation_id_contacts_ok.d.ts +0 -39
- package/v2/get_corporations_corporation_id_containers_logs_ok.d.ts +0 -188
- package/v2/get_corporations_corporation_id_contracts_contract_id_bids_ok.d.ts +0 -33
- package/v2/get_corporations_corporation_id_contracts_contract_id_items_ok.d.ts +0 -38
- package/v2/get_corporations_corporation_id_contracts_ok.d.ts +0 -117
- package/v2/get_corporations_corporation_id_customs_offices_ok.d.ts +0 -78
- package/v2/get_corporations_corporation_id_divisions_ok.d.ts +0 -128
- package/v2/get_corporations_corporation_id_facilities_ok.d.ts +0 -25
- package/v2/get_corporations_corporation_id_fw_stats_ok.d.ts +0 -60
- package/v2/get_corporations_corporation_id_icons_ok.d.ts +0 -22
- package/v2/get_corporations_corporation_id_industry_jobs_ok.d.ts +0 -105
- package/v2/get_corporations_corporation_id_killmails_recent_ok.d.ts +0 -24
- package/v2/get_corporations_corporation_id_medals_issued_ok.d.ts +0 -41
- package/v2/get_corporations_corporation_id_medals_ok.d.ts +0 -36
- package/v2/get_corporations_corporation_id_members_limit_ok.d.ts +0 -7
- package/v2/get_corporations_corporation_id_members_ok.d.ts +0 -9
- package/v2/get_corporations_corporation_id_members_titles_ok.d.ts +0 -194
- package/v2/get_corporations_corporation_id_membertracking_ok.d.ts +0 -41
- package/v2/get_corporations_corporation_id_ok.d.ts +0 -66
- package/v2/get_corporations_corporation_id_orders_history_ok.d.ts +0 -91
- package/v2/get_corporations_corporation_id_orders_ok.d.ts +0 -86
- package/v2/get_corporations_corporation_id_roles_history_ok.d.ts +0 -171
- package/v2/get_corporations_corporation_id_roles_ok.d.ts +0 -543
- package/v2/get_corporations_corporation_id_shareholders_ok.d.ts +0 -29
- package/v2/get_corporations_corporation_id_standings_ok.d.ts +0 -29
- package/v2/get_corporations_corporation_id_starbases_ok.d.ts +0 -51
- package/v2/get_corporations_corporation_id_starbases_starbase_id_ok.d.ts +0 -110
- package/v2/get_corporations_corporation_id_structures_ok.d.ts +0 -176
- package/v2/get_corporations_corporation_id_titles_ok.d.ts +0 -548
- package/v2/get_corporations_corporation_id_wallets_division_journal_ok.d.ts +0 -229
- package/v2/get_corporations_corporation_id_wallets_division_transactions_ok.d.ts +0 -50
- package/v2/get_corporations_corporation_id_wallets_ok.d.ts +0 -62
- package/v2/get_corporations_npccorps_ok.d.ts +0 -9
- package/v2/get_dogma_attributes_attribute_id_ok.d.ts +0 -50
- package/v2/get_dogma_attributes_ok.d.ts +0 -9
- package/v2/get_dogma_dynamic_items_type_id_item_id_ok.d.ts +0 -58
- package/v2/get_dogma_effects_effect_id_ok.d.ts +0 -127
- package/v2/get_dogma_effects_ok.d.ts +0 -9
- package/v2/get_fleets_fleet_id_members_ok.d.ts +0 -54
- package/v2/get_fleets_fleet_id_ok.d.ts +0 -26
- package/v2/get_fleets_fleet_id_wings_ok.d.ts +0 -45
- package/v2/get_fw_leaderboards_characters_ok.d.ts +0 -110
- package/v2/get_fw_leaderboards_corporations_ok.d.ts +0 -109
- package/v2/get_fw_leaderboards_ok.d.ts +0 -182
- package/v2/get_fw_stats_ok.d.ts +0 -66
- package/v2/get_fw_systems_ok.d.ts +0 -41
- package/v2/get_fw_wars_ok.d.ts +0 -24
- package/v2/get_industry_facilities_ok.d.ts +0 -37
- package/v2/get_industry_systems_ok.d.ts +0 -119
- package/v2/get_insurance_prices_ok.d.ts +0 -62
- package/v2/get_markets_groups_market_group_id_ok.d.ts +0 -27
- package/v2/get_markets_groups_ok.d.ts +0 -9
- package/v2/get_markets_prices_ok.d.ts +0 -25
- package/v2/get_markets_region_id_history_ok.d.ts +0 -40
- package/v2/get_markets_region_id_orders_ok.d.ts +0 -74
- package/v2/get_markets_region_id_types_ok.d.ts +0 -9
- package/v2/get_markets_structures_structure_id_ok.d.ts +0 -70
- package/v2/get_opportunities_groups_group_id_ok.d.ts +0 -38
- package/v2/get_opportunities_groups_ok.d.ts +0 -9
- package/v2/get_opportunities_tasks_ok.d.ts +0 -9
- package/v2/get_opportunities_tasks_task_id_ok.d.ts +0 -26
- package/v2/get_route_origin_destination_ok.d.ts +0 -9
- package/v2/get_sovereignty_campaigns_ok.d.ts +0 -83
- package/v2/get_sovereignty_map_ok.d.ts +0 -32
- package/v2/get_sovereignty_structures_ok.d.ts +0 -46
- package/v2/get_universe_ancestries_ok.d.ts +0 -40
- package/v2/get_universe_asteroid_belts_asteroid_belt_id_ok.d.ts +0 -37
- package/v2/get_universe_bloodlines_ok.d.ts +0 -57
- package/v2/get_universe_categories_category_id_ok.d.ts +0 -28
- package/v2/get_universe_categories_ok.d.ts +0 -9
- package/v2/get_universe_constellations_constellation_id_ok.d.ts +0 -47
- package/v2/get_universe_constellations_ok.d.ts +0 -9
- package/v2/get_universe_factions_ok.d.ts +0 -56
- package/v2/get_universe_graphics_graphic_id_ok.d.ts +0 -42
- package/v2/get_universe_graphics_ok.d.ts +0 -9
- package/v2/get_universe_groups_group_id_ok.d.ts +0 -27
- package/v2/get_universe_groups_ok.d.ts +0 -9
- package/v2/get_universe_moons_moon_id_ok.d.ts +0 -41
- package/v2/get_universe_planets_planet_id_ok.d.ts +0 -42
- package/v2/get_universe_races_ok.d.ts +0 -52
- package/v2/get_universe_regions_ok.d.ts +0 -9
- package/v2/get_universe_regions_region_id_ok.d.ts +0 -28
- package/v2/get_universe_schematics_schematic_id_ok.d.ts +0 -18
- package/v2/get_universe_stargates_stargate_id_ok.d.ts +0 -57
- package/v2/get_universe_stars_star_id_ok.d.ts +0 -129
- package/v2/get_universe_stations_station_id_ok.d.ts +0 -104
- package/v2/get_universe_structures_ok.d.ts +0 -9
- package/v2/get_universe_structures_structure_id_ok.d.ts +0 -43
- package/v2/get_universe_system_jumps_ok.d.ts +0 -24
- package/v2/get_universe_system_kills_ok.d.ts +0 -32
- package/v2/get_universe_systems_ok.d.ts +0 -9
- package/v2/get_universe_systems_system_id_ok.d.ts +0 -94
- package/v2/get_universe_types_ok.d.ts +0 -9
- package/v2/get_universe_types_type_id_ok.d.ts +0 -105
- package/v2/get_wars_ok.d.ts +0 -9
- package/v2/get_wars_war_id_killmails_ok.d.ts +0 -24
- package/v2/post_characters_affiliation_ok.d.ts +0 -32
- package/v2/post_characters_character_id_assets_locations_ok.d.ts +0 -39
- package/v2/post_characters_character_id_assets_names_ok.d.ts +0 -24
- package/v2/post_characters_character_id_contacts_created.d.ts +0 -9
- package/v2/post_characters_character_id_cspa_created.d.ts +0 -7
- package/v2/post_characters_character_id_fittings_created.d.ts +0 -14
- package/v2/post_characters_character_id_mail_created.d.ts +0 -7
- package/v2/post_characters_character_id_mail_labels_created.d.ts +0 -7
- package/v2/post_corporations_corporation_id_assets_locations_ok.d.ts +0 -39
- package/v2/post_corporations_corporation_id_assets_names_ok.d.ts +0 -24
- package/v2/post_fleets_fleet_id_wings_created.d.ts +0 -14
- package/v2/post_fleets_fleet_id_wings_wing_id_squads_created.d.ts +0 -14
- package/v2/post_universe_ids_ok.d.ts +0 -86
- package/v2/post_universe_names_ok.d.ts +0 -38
- /package/v2/{extra-types.d.ts → globals/extra-types.d.ts} +0 -0
package/docs/esi-tagged-types.md
DELETED
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
# ESI Tagged Types
|
|
2
|
-
|
|
3
|
-
This document provides an overview of the types defined in the `eve-esi-types/v2/esi-tagged-types.d.ts` file. These types are used to handle EVE Online ESI responses.
|
|
4
|
-
|
|
5
|
-
## LCamelCase
|
|
6
|
-
|
|
7
|
-
Converts a string to lower camel case.
|
|
8
|
-
|
|
9
|
-
```typescript
|
|
10
|
-
type LCamelCase<S extends string> = S extends `${infer P1} ${infer P2}`
|
|
11
|
-
? `${Lowercase<P1>}${Capitalize<P2>}` : Lowercase<S>;
|
|
12
|
-
```
|
|
13
|
-
|
|
14
|
-
### Example
|
|
15
|
-
|
|
16
|
-
```typescript
|
|
17
|
-
// returns "assets"
|
|
18
|
-
LCamelCase<"Assets">
|
|
19
|
-
|
|
20
|
-
// returns "factionWarfare"
|
|
21
|
-
LCamelCase<"Faction Warfare">
|
|
22
|
-
```
|
|
23
|
-
|
|
24
|
-
## InferSomethingBy
|
|
25
|
-
|
|
26
|
-
Infers something by a brand.
|
|
27
|
-
|
|
28
|
-
```typescript
|
|
29
|
-
type InferSomethingByBrand<N = number> = N & { __enum: "InferSomethingBy" };
|
|
30
|
-
type InferSomethingByMethod = InferSomethingByBrand<0>;
|
|
31
|
-
type InferSomethingByTags = InferSomethingByBrand<1>;
|
|
32
|
-
type InferSomethingBy<Tag, AsType extends InferSomethingByBrand = InferSomethingByMethod> = {
|
|
33
|
-
[M in TESIEntryMethod]: TESIResponseOKMap[M] extends Record<`/${string}/`, { tag: infer ActualTag }>
|
|
34
|
-
? AsType extends InferSomethingByTags
|
|
35
|
-
? ActualTag : ActualTag extends Tag
|
|
36
|
-
? M
|
|
37
|
-
: never
|
|
38
|
-
: never;
|
|
39
|
-
}[TESIEntryMethod];
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
## ESITags
|
|
43
|
-
|
|
44
|
-
Maps HTTP methods to their corresponding tags.
|
|
45
|
-
|
|
46
|
-
```typescript
|
|
47
|
-
type ESITags = InferSomethingBy<never, InferSomethingByTags>;
|
|
48
|
-
```
|
|
49
|
-
|
|
50
|
-
## InferMethod
|
|
51
|
-
|
|
52
|
-
Infers the HTTP method based on the provided tag.
|
|
53
|
-
|
|
54
|
-
```typescript
|
|
55
|
-
type InferMethod<Tag> = InferSomethingBy<Tag>;
|
|
56
|
-
```
|
|
57
|
-
|
|
58
|
-
## TaggedEndpointRequestFunction2
|
|
59
|
-
|
|
60
|
-
Creates a function type for making requests to tagged endpoints.
|
|
61
|
-
|
|
62
|
-
```typescript
|
|
63
|
-
type TaggedEndpointRequestFunction2<
|
|
64
|
-
M extends TESIEntryMethod, Tag extends ESITags,
|
|
65
|
-
ActualOpt extends Record<string, unknown> = {},
|
|
66
|
-
EndPoints extends SelectEndpointByTag<Tag, M> = SelectEndpointByTag<Tag, M>,
|
|
67
|
-
> = <
|
|
68
|
-
REP extends ReplacePathParams<EndPoints> | EndPoints,
|
|
69
|
-
EPX extends _InferEndpointOrigin<REP, EndPoints> extends never ? REP: _InferEndpointOrigin<REP, EndPoints>,
|
|
70
|
-
PPM extends InferPathParams<REP, EPX>,
|
|
71
|
-
Opt extends IdentifyParameters<M, EPX, ActualOpt & PPM>,
|
|
72
|
-
Ret extends InferESIResponseResult<M, EPX>,
|
|
73
|
-
HasOpt = HasRequireParams<M, EPX, PPM>,
|
|
74
|
-
>(endpoint: REP, ...options: HasOpt extends 1 ? [Opt] : [Opt?]) => Promise<Ret>;
|
|
75
|
-
```
|
|
76
|
-
|
|
77
|
-
## ESITaggedEndpointRequest2
|
|
78
|
-
|
|
79
|
-
Maps tags to their corresponding endpoint request functions.
|
|
80
|
-
|
|
81
|
-
```typescript
|
|
82
|
-
type ESITaggedEndpointRequest2<Tag extends ESITags, ActualOpt extends Record<string, unknown> = {}> = {
|
|
83
|
-
[tag in Tag]: {
|
|
84
|
-
[method in InferMethod<Tag>]: TaggedEndpointRequestFunction2<method, tag, ActualOpt>;
|
|
85
|
-
};
|
|
86
|
-
}[Tag];
|
|
87
|
-
```
|
|
88
|
-
|
|
89
|
-
## SelectEndpointByTag
|
|
90
|
-
|
|
91
|
-
Selects an endpoint by tag and method.
|
|
92
|
-
|
|
93
|
-
```typescript
|
|
94
|
-
type SelectEndpointByTag<
|
|
95
|
-
Tag extends ESITags, M extends TESIEntryMethod
|
|
96
|
-
> = {
|
|
97
|
-
[EP in keyof TESIResponseOKMap[M]]: TESIResponseOKMap[M][EP] extends { tag: infer ActualTag }
|
|
98
|
-
? ActualTag extends Tag
|
|
99
|
-
? EP : never
|
|
100
|
-
: never;
|
|
101
|
-
}[keyof TESIResponseOKMap[M]];
|
|
102
|
-
```
|
|
103
|
-
|
|
104
|
-
## TaggedESIRequestMap2
|
|
105
|
-
|
|
106
|
-
Maps lower camel case tags to their corresponding endpoint request functions.
|
|
107
|
-
|
|
108
|
-
```typescript
|
|
109
|
-
type TaggedESIRequestMap2<ActualOpt extends Record<string, unknown> = {}> = {
|
|
110
|
-
[tag in ESITags as LCamelCase<tag>]: ESITaggedEndpointRequest2<tag, ActualOpt>;
|
|
111
|
-
};
|
|
112
|
-
```
|
|
113
|
-
|
|
114
|
-
## TaggedESIRequestMapPartial2
|
|
115
|
-
|
|
116
|
-
Creates a partial map of lower camel case tags to their corresponding endpoint request functions.
|
|
117
|
-
|
|
118
|
-
```typescript
|
|
119
|
-
type TaggedESIRequestMapPartial2<Props extends LCamelCase<ESITags>> = RequireThese<Partial<TaggedESIRequestMap2>, Props>;
|
|
120
|
-
```
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
# Explanation of the `IdentifyParameters` Type
|
|
2
|
-
|
|
3
|
-
`IdentifyParameters` is an advanced TypeScript utility type designed to pinpoint the required parameters for an API endpoint by combining the key properties from the entry type and any additional options. This type ensures that all required parameters are explicitly marked as required, facilitating strong type-checking for API operations.
|
|
4
|
-
|
|
5
|
-
## Type Definition
|
|
6
|
-
|
|
7
|
-
```typescript
|
|
8
|
-
type IdentifyParameters<
|
|
9
|
-
M extends TESIEntryMethod,
|
|
10
|
-
EPx extends ESIEndpointOf<M> | string,
|
|
11
|
-
Opt extends Record<string, unknown>,
|
|
12
|
-
AdditionalParams,
|
|
13
|
-
Entry = _ESIResponseType<M, EPx> & AdditionalParams,
|
|
14
|
-
RequireKeys = Exclude<keyof (Entry & AdditionalParams), "result" | "tag" | "cachedSeconds">
|
|
15
|
-
// @ts-expect-error
|
|
16
|
-
> = RestrictKeys<Opt, RequireKeys> & Pick<Entry, RequireKeys> & AdditionalParams;
|
|
17
|
-
```
|
|
18
|
-
|
|
19
|
-
## Template Parameters
|
|
20
|
-
|
|
21
|
-
- **`M extends TESIEntryMethod`**
|
|
22
|
-
Specifies the HTTP method (e.g., `"get"`, `"post"`, `"delete"`, etc.) used for the API request. This allows the type system to select the appropriate endpoint and response types.
|
|
23
|
-
|
|
24
|
-
- **`EPx extends ESIEndpointOf<M> | string`**
|
|
25
|
-
Denotes the endpoint path. It can be a specific parameterized endpoint corresponding to the method or a generic endpoint represented as a string.
|
|
26
|
-
|
|
27
|
-
- **`Opt extends Record<string, unknown>`**
|
|
28
|
-
Represents the additional options provided by the user. These options are expected to be an object whose keys are strings.
|
|
29
|
-
|
|
30
|
-
- **`AdditionalParams`**
|
|
31
|
-
These are extra parameters that, when merged with the entry type, give a more comprehensive view of the API parameters.
|
|
32
|
-
|
|
33
|
-
- **`Entry = _ESIResponseType<M, EPx> & AdditionalParams`**
|
|
34
|
-
This type combines the inferred response type for the given HTTP method and endpoint with the additional parameters. It serves as the base type from which the required keys are extracted.
|
|
35
|
-
|
|
36
|
-
- **`RequireKeys = Exclude<keyof (Entry & AdditionalParams), "result" | "tag" | "cachedSeconds">`**
|
|
37
|
-
This calculates the keys that are considered required by excluding common metadata keys (`"result"`, `"tag"`, and `"cachedSeconds"`) from the combined type.
|
|
38
|
-
|
|
39
|
-
## How It Works
|
|
40
|
-
|
|
41
|
-
1. **Merging Types**
|
|
42
|
-
The type first merges the API response type (`_ESIResponseType<M, EPx>`) with any additional parameters passed as `AdditionalParams` to form the composite type `Entry`.
|
|
43
|
-
|
|
44
|
-
2. **Identifying Required Keys**
|
|
45
|
-
It then computes `RequireKeys` by taking the keys of the merged type and excluding the metadata keys (`"result"`, `"tag"`, `"cachedSeconds"`). These remaining keys are treated as required parameters.
|
|
46
|
-
|
|
47
|
-
3. **Restricting Additional Options**
|
|
48
|
-
The helper type `RestrictKeys<Opt, RequireKeys>` ensures that the additional options in `Opt` are limited only to the keys identified as required. This adds an extra layer of type-safety.
|
|
49
|
-
|
|
50
|
-
4. **Final Combination**
|
|
51
|
-
Finally, the type returns the intersection:
|
|
52
|
-
- `RestrictKeys<Opt, RequireKeys>` restricts `Opt` to only the required keys.
|
|
53
|
-
- `Pick<Entry, RequireKeys>` extracts the corresponding values from the merged entry type.
|
|
54
|
-
- `AdditionalParams` is intersected in the end, ensuring that any extra provided parameters are also included.
|
|
55
|
-
|
|
56
|
-
This results in a final type that accurately represents only the required parameters for an API endpoint.
|
|
57
|
-
|
|
58
|
-
## Practical Example
|
|
59
|
-
|
|
60
|
-
```typescript
|
|
61
|
-
type ExampleEntry = { result: string, tag: string, cachedSeconds: number, auth: string };
|
|
62
|
-
type ExampleOpt = { auth: string };
|
|
63
|
-
type IdentifiedParams = IdentifyParameters<"get", "/example/endpoint", ExampleOpt, ExampleEntry>;
|
|
64
|
-
// Result: { auth: string } & { auth: string }
|
|
65
|
-
```
|
|
66
|
-
|
|
67
|
-
In this example:
|
|
68
|
-
- `ExampleEntry` includes metadata keys along with the essential key `auth`.
|
|
69
|
-
- `ExampleOpt` specifies that `auth` is required.
|
|
70
|
-
- `IdentifyParameters` processes these inputs and produces a type that enforces the `auth` parameter as required, ensuring accurate and reliable type-checking.
|
|
71
|
-
|
|
72
|
-
---
|
|
73
|
-
|
|
74
|
-
`IdentifyParameters` thus plays a crucial role in extracting and enforcing the required parameters from API definitions, merging inherent parameters with additional options into a concise, strongly-typed structure.
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
# Explanation of the `IfParameterizedPath` Type
|
|
2
|
-
|
|
3
|
-
`IfParameterizedPath` is a conditional TypeScript utility type that checks whether a given endpoint path (`EP`) is parameterized—i.e., contains a parameterized segment enclosed in `{}`—and, if so, determines the required type for its numeric replacements. Depending on the number of parameters detected, it returns different types:
|
|
4
|
-
- Returns `number` if exactly one parameter is detected.
|
|
5
|
-
- Returns `[number, number]` if two parameters are detected.
|
|
6
|
-
- Otherwise, it returns the fallback type `Opt` (which defaults to `never`).
|
|
7
|
-
|
|
8
|
-
## Type Definition
|
|
9
|
-
|
|
10
|
-
```typescript
|
|
11
|
-
type IfParameterizedPath<EP extends unknown, Opt = never> = EP extends `${string}/{${string}}${string}`
|
|
12
|
-
? PickPathParameters<EP> extends never
|
|
13
|
-
? Opt : InferKeysLen<PickPathParameters<EP>> extends 1
|
|
14
|
-
? number : [number, number]
|
|
15
|
-
: Opt;
|
|
16
|
-
```
|
|
17
|
-
|
|
18
|
-
## Template Parameters
|
|
19
|
-
|
|
20
|
-
- **`EP extends unknown`**
|
|
21
|
-
The endpoint path as a string literal. This path may contain dynamic segments (e.g., `"/users/{user_id}/posts/{post_id}"`) that need to be replaced with numerical values.
|
|
22
|
-
|
|
23
|
-
- **`Opt`**
|
|
24
|
-
The fallback type to return if `EP` is not parameterized. By default, this is set to `never`.
|
|
25
|
-
|
|
26
|
-
## How It Works
|
|
27
|
-
|
|
28
|
-
1. **Pattern Matching**
|
|
29
|
-
The type checks if `EP` matches the pattern:
|
|
30
|
-
```typescript
|
|
31
|
-
EP extends `${string}/{${string}}${string}`
|
|
32
|
-
```
|
|
33
|
-
This verifies that `EP` includes at least one parameter wrapped in curly braces.
|
|
34
|
-
|
|
35
|
-
2. **Extracting Parameters**
|
|
36
|
-
If `EP` is parameterized, `PickPathParameters<EP>` is used to extract the dynamic segments:
|
|
37
|
-
- If `PickPathParameters<EP>` evaluates to `never` (indicating no valid parameters were found), the type returns `Opt`.
|
|
38
|
-
- Otherwise, it proceeds to the next step.
|
|
39
|
-
|
|
40
|
-
3. **Determining the Number of Parameters**
|
|
41
|
-
The type uses `InferKeysLen<PickPathParameters<EP>>` to count the number of extracted parameters:
|
|
42
|
-
- If exactly one parameter is found, it returns `number`—indicating a single numeric replacement.
|
|
43
|
-
- Otherwise (implicitly for two parameters as per the provided description), it returns `[number, number]`.
|
|
44
|
-
|
|
45
|
-
4. **Fallback for Non-Parameterized Paths**
|
|
46
|
-
If `EP` does not match the parameterized pattern, the type simply returns `Opt`.
|
|
47
|
-
|
|
48
|
-
## Practical Example
|
|
49
|
-
|
|
50
|
-
For an endpoint with one parameter:
|
|
51
|
-
```typescript
|
|
52
|
-
type SingleParam = IfParameterizedPath<"/users/{user_id}/profile">;
|
|
53
|
-
// Evaluates to: number
|
|
54
|
-
```
|
|
55
|
-
|
|
56
|
-
For an endpoint with two parameters:
|
|
57
|
-
```typescript
|
|
58
|
-
type TwoParams = IfParameterizedPath<"/users/{user_id}/posts/{post_id}">;
|
|
59
|
-
// Evaluates to: [number, number]
|
|
60
|
-
```
|
|
61
|
-
|
|
62
|
-
And for a non-parameterized endpoint:
|
|
63
|
-
```typescript
|
|
64
|
-
type NotParam = IfParameterizedPath<"/about">;
|
|
65
|
-
// Evaluates to: never (using the default for Opt)
|
|
66
|
-
```
|
|
67
|
-
|
|
68
|
-
---
|
|
69
|
-
|
|
70
|
-
`IfParameterizedPath` provides a precise mechanism for type-level validation of endpoint structures by determining the necessary numerical replacements for dynamic segments, ensuring robust type-checking for API endpoint definitions.
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
# Explanation of the `InferESIResponseResult` Type
|
|
2
|
-
|
|
3
|
-
`InferESIResponseResult` is a utility TypeScript type designed to extract the type of the `result` property from an ESI response based on a given HTTP method and endpoint. It relies on the underlying `_ESIResponseType`, which represents the full response type for the specified method and endpoint. If this inferred response type includes a `result` key, the type captures and returns its type; otherwise, it defaults to `never`.
|
|
4
|
-
|
|
5
|
-
## Type Definition
|
|
6
|
-
|
|
7
|
-
```typescript
|
|
8
|
-
type InferESIResponseResult<
|
|
9
|
-
M extends TESIEntryMethod,
|
|
10
|
-
EPx extends ESIEndpointOf<M> | string
|
|
11
|
-
> = _ESIResponseType<M, EPx> extends { result: infer U } ? U : never;
|
|
12
|
-
```
|
|
13
|
-
|
|
14
|
-
## Template Parameters
|
|
15
|
-
|
|
16
|
-
- **`M extends TESIEntryMethod`**
|
|
17
|
-
The HTTP method (e.g., `"get"`, `"post"`, `"delete"`, etc.) used for the request. This helps determine the proper response type from the API endpoints.
|
|
18
|
-
|
|
19
|
-
- **`EPx extends ESIEndpointOf<M> | string`**
|
|
20
|
-
The endpoint path, which can either be one of the predefined parameterized endpoints associated with the HTTP method `M` or a generic string representing an endpoint.
|
|
21
|
-
|
|
22
|
-
## How It Works
|
|
23
|
-
|
|
24
|
-
1. **Inferring the Response Type:**
|
|
25
|
-
The type first evaluates `_ESIResponseType<M, EPx>`, which returns the anticipated response type for the given HTTP method and endpoint.
|
|
26
|
-
|
|
27
|
-
2. **Extracting the `result` Property:**
|
|
28
|
-
It then uses a conditional type with the `infer` keyword:
|
|
29
|
-
```typescript
|
|
30
|
-
_ESIResponseType<M, EPx> extends { result: infer U } ? U : never;
|
|
31
|
-
```
|
|
32
|
-
- If the response type has a `result` property, `U` is inferred as the type of that property.
|
|
33
|
-
- If there is no `result` property, the type evaluates to `never`.
|
|
34
|
-
|
|
35
|
-
## Practical Example
|
|
36
|
-
|
|
37
|
-
```typescript
|
|
38
|
-
type Result = InferESIResponseResult<"get", "/characters/{character_id}/">;
|
|
39
|
-
// The type 'Result' represents the type of the 'result' field in the response for the GET request to the specified endpoint.
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
---
|
|
43
|
-
|
|
44
|
-
`InferESIResponseResult` enhances type safety by allowing developers to directly access the portion of the API response that contains the primary data of interest. This makes it easier to work with and validate the structure of responses in a strongly-typed manner.
|
package/docs/v2/require-these.md
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
# Explanation of the `RequireThese` Type
|
|
2
|
-
|
|
3
|
-
The `RequireThese` type is a utility type that takes an existing type `T` and a subset of its keys `K`, and marks those keys as **required**. The rest of the properties in `T` remain unchanged. This is especially useful when you want to enforce that certain properties are provided while leaving other properties optional or in their original state.
|
|
4
|
-
|
|
5
|
-
## Type Definition
|
|
6
|
-
|
|
7
|
-
```typescript
|
|
8
|
-
type RequireThese<T, K extends keyof T> = {
|
|
9
|
-
[P in keyof T as P extends K ? P : never]-?: T[P];
|
|
10
|
-
} & {
|
|
11
|
-
[P in keyof T as P extends K ? never : P]: T[P];
|
|
12
|
-
};
|
|
13
|
-
```
|
|
14
|
-
|
|
15
|
-
## How It Works
|
|
16
|
-
|
|
17
|
-
1. **Selecting Required Keys**
|
|
18
|
-
The first mapped type:
|
|
19
|
-
```typescript
|
|
20
|
-
{
|
|
21
|
-
[P in keyof T as P extends K ? P : never]-?: T[P];
|
|
22
|
-
}
|
|
23
|
-
```
|
|
24
|
-
- Iterates over each property key `P` in `T`.
|
|
25
|
-
- Uses a conditional type `P extends K ? P : never` to filter in only the keys that are specified in `K`.
|
|
26
|
-
- The `-?` operator removes the optional modifier, ensuring that these properties are marked as required.
|
|
27
|
-
|
|
28
|
-
2. **Preserving Other Keys**
|
|
29
|
-
The second mapped type:
|
|
30
|
-
```typescript
|
|
31
|
-
{
|
|
32
|
-
[P in keyof T as P extends K ? never : P]: T[P];
|
|
33
|
-
}
|
|
34
|
-
```
|
|
35
|
-
- Iterates over each property key `P` in `T`.
|
|
36
|
-
- Uses a conditional type to exclude the keys in `K` (by returning `never` for them), effectively preserving only the properties not in `K` in their original form.
|
|
37
|
-
|
|
38
|
-
3. **Combining the Results**
|
|
39
|
-
The intersection (`&`) of the two mapped types results in a new type that:
|
|
40
|
-
- Contains all keys in `K` as required.
|
|
41
|
-
- Contains all keys not in `K` with their original modifiers (optional or required).
|
|
42
|
-
|
|
43
|
-
## Practical Example
|
|
44
|
-
|
|
45
|
-
```typescript
|
|
46
|
-
type Original = { a?: number; b?: string; c: boolean };
|
|
47
|
-
type RequiredA = RequireThese<Original, 'a'>;
|
|
48
|
-
// Evaluates to: { a: number; b?: string; c: boolean }
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
In this example:
|
|
52
|
-
- The property `a` is transformed from an optional property to a required property.
|
|
53
|
-
- The properties `b` and `c` retain their original statuses, with `b` remaining optional and `c` remaining required.
|
|
54
|
-
|
|
55
|
-
---
|
|
56
|
-
|
|
57
|
-
`RequireThese` provides a concise way to enforce the presence of selected properties within a type, making it an effective tool for enhancing type safety in TypeScript.
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
# Explanation of the `TESIEnhancedRequestFunctionSignature` Type
|
|
2
|
-
|
|
3
|
-
`TESIEnhancedRequestFunctionSignature` is a highly generic function signature type for performing enhanced ESI requests.
|
|
4
|
-
It extends a base request function signature by injecting a prepended parameter at the beginning of the function call,
|
|
5
|
-
thereby providing extra context or enabling pre-processing prior to executing the request.
|
|
6
|
-
|
|
7
|
-
This signature adapts to the specifics of the chosen HTTP method, endpoint configuration, inferred path parameters,
|
|
8
|
-
and additional request options—making it ideal for advanced API interactions where both flexibility and strict type-safety are required.
|
|
9
|
-
|
|
10
|
-
## Generic Parameters
|
|
11
|
-
|
|
12
|
-
- **`PrependParam`**: The type of the additional parameter that is injected at the beginning of the function call.
|
|
13
|
-
- **`ActualOpt`**: An object representing the default options (typically extending `ESIRequestOptions`) used for the request.
|
|
14
|
-
|
|
15
|
-
## Function Generic Parameters
|
|
16
|
-
|
|
17
|
-
- **`Mtd`**: The ESI request method type (e.g., GET, POST, DELETE) as defined in `TESIEntryMethod`.
|
|
18
|
-
- **`REP`**: The endpoint type, which can be either a version with replaced path parameters (via `ReplacePathParams`) or the raw endpoint type from `ESIEndpointOf<Mtd>`.
|
|
19
|
-
- **`EPX`**: The resolved endpoint type, derived from `REP` and `Mtd`.
|
|
20
|
-
- **`PPM`**: The type representing the inferred path parameters extracted from `REP` and `EPX`.
|
|
21
|
-
- **`Opt`**: The type for additional request options, as deduced from the HTTP method (`Mtd`), endpoint (`EPX`), the default options (`ActualOpt`), and the inferred path parameters (`PPM`).
|
|
22
|
-
- **`Ret`**: The type of the response result from the ESI request, as inferred from the method and the endpoint.
|
|
23
|
-
- **`HasOpt`**: An internal flag, computed via `HasRequireParams<Mtd, EPX, PPM>`, used to determine whether the request options (`Opt`) are required (evaluating to `1`) or optional (evaluating to `0`).
|
|
24
|
-
|
|
25
|
-
## Parameters
|
|
26
|
-
|
|
27
|
-
- **`prependParam: PrependParam`**
|
|
28
|
-
A prepended parameter that supplies additional context or configuration necessary for the request.
|
|
29
|
-
|
|
30
|
-
- **`method: Mtd`**
|
|
31
|
-
The HTTP method for the request.
|
|
32
|
-
|
|
33
|
-
- **`endpoint: REP`**
|
|
34
|
-
The API endpoint, which may include path parameter replacements (as provided by `ReplacePathParams`).
|
|
35
|
-
|
|
36
|
-
- **`...options: HasOpt extends 1 ? [Opt] : [Opt?]`**
|
|
37
|
-
A rest parameter representing additional options for the request. This is required if `HasOpt` is `1` (indicating that some options are mandatory), otherwise it is optional.
|
|
38
|
-
|
|
39
|
-
## Return Value
|
|
40
|
-
|
|
41
|
-
- Returns a `Promise<Ret>` that resolves with the response from the ESI endpoint, where `Ret` reflects the inferred result type.
|
|
42
|
-
|
|
43
|
-
## Type Definition
|
|
44
|
-
|
|
45
|
-
```typescript
|
|
46
|
-
type TESIEnhancedRequestFunctionSignature<
|
|
47
|
-
PrependParam extends unknown, ActualOpt extends Record<string, unknown>
|
|
48
|
-
> = <
|
|
49
|
-
Mtd extends TESIEntryMethod,
|
|
50
|
-
REP extends ReplacePathParams<ESIEndpointOf<Mtd>> | ESIEndpointOf<Mtd>,
|
|
51
|
-
EPX extends ResolvedEndpoint<REP, Mtd>,
|
|
52
|
-
PPM extends InferPathParams<REP, EPX>,
|
|
53
|
-
Opt extends IdentifyParameters<Mtd, EPX, ActualOpt, PPM>,
|
|
54
|
-
Ret extends InferESIResponseResult<Mtd, EPX>,
|
|
55
|
-
HasOpt = HasRequireParams<Mtd, EPX, PPM>
|
|
56
|
-
>(
|
|
57
|
-
prependParam: PrependParam,
|
|
58
|
-
method: Mtd,
|
|
59
|
-
endpoint: REP,
|
|
60
|
-
...options: HasOpt extends 1 ? [Opt] : [Opt?]
|
|
61
|
-
) => Promise<Ret>;
|
|
62
|
-
```
|
|
63
|
-
|
|
64
|
-
---
|
|
65
|
-
|
|
66
|
-
`TESIEnhancedRequestFunctionSignature` combines dynamic type inference with advanced parameter and return type handling to support complex API interactions in a type-safe manner.
|
|
67
|
-
It ensures that extra configuration is accounted for at the start of the function call, aligning the signature with the specific needs of the API endpoint and HTTP method being used.
|