eve-esi-types 2.1.0 → 2.1.2

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.
Files changed (208) hide show
  1. package/README.md +28 -2
  2. package/esi-types-util.md +108 -0
  3. package/package.json +7 -9
  4. package/tsconfig.json +1 -0
  5. package/v2/extra-types.d.ts +28 -1091
  6. package/v2/index.d.ts +11 -10
  7. package/v2.d.mts +58 -0
  8. package/v2.mjs +6 -5
  9. package/esi-request.mjs +0 -247
  10. package/src/get_alliances_alliance_id_contacts_labels_ok.d.ts +0 -27
  11. package/src/get_alliances_alliance_id_contacts_ok.d.ts +0 -43
  12. package/src/get_alliances_alliance_id_corporations_ok.d.ts +0 -14
  13. package/src/get_alliances_alliance_id_icons_ok.d.ts +0 -21
  14. package/src/get_alliances_alliance_id_ok.d.ts +0 -46
  15. package/src/get_alliances_ok.d.ts +0 -14
  16. package/src/get_characters_character_id_agents_research_ok.d.ts +0 -42
  17. package/src/get_characters_character_id_assets_ok.d.ts +0 -144
  18. package/src/get_characters_character_id_attributes_ok.d.ts +0 -51
  19. package/src/get_characters_character_id_blueprints_ok.d.ts +0 -133
  20. package/src/get_characters_character_id_bookmarks_folders_ok.d.ts +0 -27
  21. package/src/get_characters_character_id_bookmarks_ok.d.ts +0 -91
  22. package/src/get_characters_character_id_calendar_event_id_attendees_ok.d.ts +0 -32
  23. package/src/get_characters_character_id_calendar_event_id_ok.d.ts +0 -66
  24. package/src/get_characters_character_id_calendar_ok.d.ts +0 -42
  25. package/src/get_characters_character_id_clones_ok.d.ts +0 -82
  26. package/src/get_characters_character_id_contacts_labels_ok.d.ts +0 -27
  27. package/src/get_characters_character_id_contacts_ok.d.ts +0 -53
  28. package/src/get_characters_character_id_contracts_contract_id_bids_ok.d.ts +0 -37
  29. package/src/get_characters_character_id_contracts_contract_id_items_ok.d.ts +0 -48
  30. package/src/get_characters_character_id_contracts_ok.d.ts +0 -137
  31. package/src/get_characters_character_id_corporationhistory_ok.d.ts +0 -37
  32. package/src/get_characters_character_id_fatigue_ok.d.ts +0 -26
  33. package/src/get_characters_character_id_fittings_ok.d.ts +0 -108
  34. package/src/get_characters_character_id_fleet_ok.d.ts +0 -35
  35. package/src/get_characters_character_id_fw_stats_ok.d.ts +0 -75
  36. package/src/get_characters_character_id_implants_ok.d.ts +0 -14
  37. package/src/get_characters_character_id_industry_jobs_ok.d.ts +0 -133
  38. package/src/get_characters_character_id_killmails_recent_ok.d.ts +0 -27
  39. package/src/get_characters_character_id_location_ok.d.ts +0 -26
  40. package/src/get_characters_character_id_loyalty_points_ok.d.ts +0 -27
  41. package/src/get_characters_character_id_mail_labels_ok.d.ts +0 -67
  42. package/src/get_characters_character_id_mail_lists_ok.d.ts +0 -27
  43. package/src/get_characters_character_id_mail_mail_id_ok.d.ts +0 -71
  44. package/src/get_characters_character_id_mail_ok.d.ts +0 -77
  45. package/src/get_characters_character_id_medals_ok.d.ts +0 -147
  46. package/src/get_characters_character_id_mining_ok.d.ts +0 -37
  47. package/src/get_characters_character_id_notifications_contacts_ok.d.ts +0 -42
  48. package/src/get_characters_character_id_notifications_ok.d.ts +0 -297
  49. package/src/get_characters_character_id_ok.d.ts +0 -66
  50. package/src/get_characters_character_id_online_ok.d.ts +0 -31
  51. package/src/get_characters_character_id_opportunities_ok.d.ts +0 -27
  52. package/src/get_characters_character_id_orders_history_ok.d.ts +0 -104
  53. package/src/get_characters_character_id_orders_ok.d.ts +0 -99
  54. package/src/get_characters_character_id_planets_ok.d.ts +0 -131
  55. package/src/get_characters_character_id_planets_planet_id_ok.d.ts +0 -323
  56. package/src/get_characters_character_id_portrait_ok.d.ts +0 -31
  57. package/src/get_characters_character_id_roles_ok.d.ts +0 -271
  58. package/src/get_characters_character_id_search_ok.d.ts +0 -132
  59. package/src/get_characters_character_id_ship_ok.d.ts +0 -26
  60. package/src/get_characters_character_id_skillqueue_ok.d.ts +0 -57
  61. package/src/get_characters_character_id_skills_ok.d.ts +0 -54
  62. package/src/get_characters_character_id_standings_ok.d.ts +0 -32
  63. package/src/get_characters_character_id_titles_ok.d.ts +0 -187
  64. package/src/get_characters_character_id_wallet_journal_ok.d.ts +0 -240
  65. package/src/get_characters_character_id_wallet_ok.d.ts +0 -8
  66. package/src/get_characters_character_id_wallet_transactions_ok.d.ts +0 -67
  67. package/src/get_contracts_public_bids_contract_id_ok.d.ts +0 -32
  68. package/src/get_contracts_public_items_contract_id_ok.d.ts +0 -62
  69. package/src/get_contracts_public_region_id_ok.d.ts +0 -97
  70. package/src/get_corporation_corporation_id_mining_extractions_ok.d.ts +0 -45
  71. package/src/get_corporation_corporation_id_mining_observers_observer_id_ok.d.ts +0 -45
  72. package/src/get_corporation_corporation_id_mining_observers_ok.d.ts +0 -33
  73. package/src/get_corporations_corporation_id_alliancehistory_ok.d.ts +0 -37
  74. package/src/get_corporations_corporation_id_assets_ok.d.ts +0 -180
  75. package/src/get_corporations_corporation_id_blueprints_ok.d.ts +0 -174
  76. package/src/get_corporations_corporation_id_bookmarks_folders_ok.d.ts +0 -32
  77. package/src/get_corporations_corporation_id_bookmarks_ok.d.ts +0 -91
  78. package/src/get_corporations_corporation_id_contacts_labels_ok.d.ts +0 -27
  79. package/src/get_corporations_corporation_id_contacts_ok.d.ts +0 -48
  80. package/src/get_corporations_corporation_id_containers_logs_ok.d.ts +0 -204
  81. package/src/get_corporations_corporation_id_contracts_contract_id_bids_ok.d.ts +0 -38
  82. package/src/get_corporations_corporation_id_contracts_contract_id_items_ok.d.ts +0 -48
  83. package/src/get_corporations_corporation_id_contracts_ok.d.ts +0 -137
  84. package/src/get_corporations_corporation_id_customs_offices_ok.d.ts +0 -92
  85. package/src/get_corporations_corporation_id_divisions_ok.d.ts +0 -133
  86. package/src/get_corporations_corporation_id_facilities_ok.d.ts +0 -32
  87. package/src/get_corporations_corporation_id_fw_stats_ok.d.ts +0 -70
  88. package/src/get_corporations_corporation_id_icons_ok.d.ts +0 -26
  89. package/src/get_corporations_corporation_id_industry_jobs_ok.d.ts +0 -133
  90. package/src/get_corporations_corporation_id_killmails_recent_ok.d.ts +0 -27
  91. package/src/get_corporations_corporation_id_medals_issued_ok.d.ts +0 -47
  92. package/src/get_corporations_corporation_id_medals_ok.d.ts +0 -42
  93. package/src/get_corporations_corporation_id_members_limit_ok.d.ts +0 -8
  94. package/src/get_corporations_corporation_id_members_ok.d.ts +0 -14
  95. package/src/get_corporations_corporation_id_members_titles_ok.d.ts +0 -197
  96. package/src/get_corporations_corporation_id_membertracking_ok.d.ts +0 -52
  97. package/src/get_corporations_corporation_id_ok.d.ts +0 -81
  98. package/src/get_corporations_corporation_id_orders_history_ok.d.ts +0 -109
  99. package/src/get_corporations_corporation_id_orders_ok.d.ts +0 -104
  100. package/src/get_corporations_corporation_id_roles_history_ok.d.ts +0 -175
  101. package/src/get_corporations_corporation_id_roles_ok.d.ts +0 -545
  102. package/src/get_corporations_corporation_id_shareholders_ok.d.ts +0 -32
  103. package/src/get_corporations_corporation_id_standings_ok.d.ts +0 -32
  104. package/src/get_corporations_corporation_id_starbases_ok.d.ts +0 -62
  105. package/src/get_corporations_corporation_id_starbases_starbase_id_ok.d.ts +0 -369
  106. package/src/get_corporations_corporation_id_structures_ok.d.ts +0 -194
  107. package/src/get_corporations_corporation_id_titles_ok.d.ts +0 -715
  108. package/src/get_corporations_corporation_id_wallets_division_journal_ok.d.ts +0 -241
  109. package/src/get_corporations_corporation_id_wallets_division_transactions_ok.d.ts +0 -63
  110. package/src/get_corporations_corporation_id_wallets_ok.d.ts +0 -65
  111. package/src/get_corporations_npccorps_ok.d.ts +0 -14
  112. package/src/get_dogma_attributes_attribute_id_ok.d.ts +0 -61
  113. package/src/get_dogma_attributes_ok.d.ts +0 -14
  114. package/src/get_dogma_dynamic_items_type_id_item_id_ok.d.ts +0 -72
  115. package/src/get_dogma_effects_effect_id_ok.d.ts +0 -154
  116. package/src/get_dogma_effects_ok.d.ts +0 -14
  117. package/src/get_fleets_fleet_id_members_ok.d.ts +0 -67
  118. package/src/get_fleets_fleet_id_ok.d.ts +0 -31
  119. package/src/get_fleets_fleet_id_wings_ok.d.ts +0 -50
  120. package/src/get_fw_leaderboards_characters_ok.d.ts +0 -163
  121. package/src/get_fw_leaderboards_corporations_ok.d.ts +0 -589
  122. package/src/get_fw_leaderboards_ok.d.ts +0 -235
  123. package/src/get_fw_stats_ok.d.ts +0 -76
  124. package/src/get_fw_systems_ok.d.ts +0 -47
  125. package/src/get_fw_wars_ok.d.ts +0 -27
  126. package/src/get_incursions_ok.d.ts +0 -63
  127. package/src/get_industry_facilities_ok.d.ts +0 -47
  128. package/src/get_industry_systems_ok.d.ts +0 -122
  129. package/src/get_insurance_prices_ok.d.ts +0 -70
  130. package/src/get_killmails_killmail_id_killmail_hash_ok.d.ts +0 -242
  131. package/src/get_loyalty_stores_corporation_id_offers_ok.d.ts +0 -70
  132. package/src/get_markets_groups_market_group_id_ok.d.ts +0 -42
  133. package/src/get_markets_groups_ok.d.ts +0 -14
  134. package/src/get_markets_prices_ok.d.ts +0 -32
  135. package/src/get_markets_region_id_history_ok.d.ts +0 -47
  136. package/src/get_markets_region_id_orders_ok.d.ts +0 -89
  137. package/src/get_markets_region_id_types_ok.d.ts +0 -14
  138. package/src/get_markets_structures_structure_id_ok.d.ts +0 -84
  139. package/src/get_opportunities_groups_group_id_ok.d.ts +0 -53
  140. package/src/get_opportunities_groups_ok.d.ts +0 -14
  141. package/src/get_opportunities_tasks_ok.d.ts +0 -14
  142. package/src/get_opportunities_tasks_task_id_ok.d.ts +0 -31
  143. package/src/get_route_origin_destination_ok.d.ts +0 -14
  144. package/src/get_sovereignty_campaigns_ok.d.ts +0 -94
  145. package/src/get_sovereignty_map_ok.d.ts +0 -37
  146. package/src/get_sovereignty_structures_ok.d.ts +0 -58
  147. package/src/get_status_ok.d.ts +0 -31
  148. package/src/get_universe_ancestries_ok.d.ts +0 -47
  149. package/src/get_universe_asteroid_belts_asteroid_belt_id_ok.d.ts +0 -43
  150. package/src/get_universe_bloodlines_ok.d.ts +0 -72
  151. package/src/get_universe_categories_category_id_ok.d.ts +0 -37
  152. package/src/get_universe_categories_ok.d.ts +0 -14
  153. package/src/get_universe_constellations_constellation_id_ok.d.ts +0 -59
  154. package/src/get_universe_constellations_ok.d.ts +0 -14
  155. package/src/get_universe_factions_ok.d.ts +0 -67
  156. package/src/get_universe_graphics_graphic_id_ok.d.ts +0 -51
  157. package/src/get_universe_graphics_ok.d.ts +0 -14
  158. package/src/get_universe_groups_group_id_ok.d.ts +0 -42
  159. package/src/get_universe_groups_ok.d.ts +0 -14
  160. package/src/get_universe_moons_moon_id_ok.d.ts +0 -48
  161. package/src/get_universe_planets_planet_id_ok.d.ts +0 -53
  162. package/src/get_universe_races_ok.d.ts +0 -57
  163. package/src/get_universe_regions_ok.d.ts +0 -14
  164. package/src/get_universe_regions_region_id_ok.d.ts +0 -37
  165. package/src/get_universe_schematics_schematic_id_ok.d.ts +0 -21
  166. package/src/get_universe_stargates_stargate_id_ok.d.ts +0 -70
  167. package/src/get_universe_stars_star_id_ok.d.ts +0 -140
  168. package/src/get_universe_stations_station_id_ok.d.ts +0 -121
  169. package/src/get_universe_structures_ok.d.ts +0 -14
  170. package/src/get_universe_structures_structure_id_ok.d.ts +0 -54
  171. package/src/get_universe_system_jumps_ok.d.ts +0 -27
  172. package/src/get_universe_system_kills_ok.d.ts +0 -37
  173. package/src/get_universe_systems_ok.d.ts +0 -14
  174. package/src/get_universe_systems_system_id_ok.d.ts +0 -125
  175. package/src/get_universe_types_ok.d.ts +0 -14
  176. package/src/get_universe_types_type_id_ok.d.ts +0 -127
  177. package/src/get_wars_ok.d.ts +0 -14
  178. package/src/get_wars_war_id_killmails_ok.d.ts +0 -27
  179. package/src/get_wars_war_id_ok.d.ts +0 -123
  180. package/src/index.d.ts +0 -404
  181. package/src/post_characters_affiliation_ok.d.ts +0 -37
  182. package/src/post_characters_character_id_assets_locations_ok.d.ts +0 -44
  183. package/src/post_characters_character_id_assets_names_ok.d.ts +0 -27
  184. package/src/post_characters_character_id_contacts_contact_ids.d.ts +0 -18
  185. package/src/post_characters_character_id_contacts_created.d.ts +0 -14
  186. package/src/post_characters_character_id_cspa_characters.d.ts +0 -18
  187. package/src/post_characters_character_id_cspa_created.d.ts +0 -8
  188. package/src/post_characters_character_id_fittings_created.d.ts +0 -16
  189. package/src/post_characters_character_id_fittings_fitting.d.ts +0 -101
  190. package/src/post_characters_character_id_mail_created.d.ts +0 -8
  191. package/src/post_characters_character_id_mail_labels_created.d.ts +0 -8
  192. package/src/post_characters_character_id_mail_labels_label.d.ts +0 -39
  193. package/src/post_characters_character_id_mail_mail.d.ts +0 -53
  194. package/src/post_corporations_corporation_id_assets_locations_ok.d.ts +0 -44
  195. package/src/post_corporations_corporation_id_assets_names_ok.d.ts +0 -27
  196. package/src/post_fleets_fleet_id_members_invitation.d.ts +0 -31
  197. package/src/post_fleets_fleet_id_wings_created.d.ts +0 -16
  198. package/src/post_fleets_fleet_id_wings_wing_id_squads_created.d.ts +0 -16
  199. package/src/post_ui_openwindow_newmail_new_mail.d.ts +0 -46
  200. package/src/post_universe_ids_ok.d.ts +0 -241
  201. package/src/post_universe_names_ok.d.ts +0 -41
  202. package/src/put_characters_character_id_calendar_event_id_response.d.ts +0 -16
  203. package/src/put_characters_character_id_contacts_contact_ids.d.ts +0 -18
  204. package/src/put_characters_character_id_mail_mail_id_contents.d.ts +0 -27
  205. package/src/put_fleets_fleet_id_members_member_id_movement.d.ts +0 -30
  206. package/src/put_fleets_fleet_id_new_settings.d.ts +0 -21
  207. package/src/put_fleets_fleet_id_squads_squad_id_naming.d.ts +0 -16
  208. package/src/put_fleets_fleet_id_wings_wing_id_naming.d.ts +0 -16
package/v2/index.d.ts CHANGED
@@ -1,5 +1,15 @@
1
+ /*!
2
+ // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
3
+ // Copyright (C) 2025 jeffy-g <hirotom1107@gmail.com>
4
+ // Released under the MIT license
5
+ // https://opensource.org/licenses/mit-license.php
6
+ // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
7
+ */
1
8
  /**
2
- * this tsd is auto generated, DO NOT EDIT
9
+ * THIS TSD IS AUTO GENERATED, DO NOT EDIT
10
+ *
11
+ * @file eve-esi-types/v2/index.d.ts
12
+ * @summary This file is auto-generated and defines version 2.1.2 of the EVE Online ESI response types.
3
13
  */
4
14
  import "./get_alliances_ok.d.ts";
5
15
  import "./get_alliances_alliance_id_ok.d.ts";
@@ -197,15 +207,6 @@ import "./get_wars_war_id_killmails_ok.d.ts";
197
207
  import "./extra-types.d.ts";
198
208
 
199
209
 
200
- /**
201
- * mark a specific property as `required`
202
- */
203
- type RequireThese<T, K extends keyof T> = T & Required<Pick<T, K>>;
204
-
205
- // type EndPointEntryMap = TESIResponseOKMap[TESIEntryMethod];
206
- // type AllEndPoints = keyof TESIResponseOKMap[TESIEntryMethod];
207
- // type BasicEntries = EndPointEntryMap[AllEndPoints];
208
-
209
210
  declare global {
210
211
 
211
212
  /**
package/v2.d.mts ADDED
@@ -0,0 +1,58 @@
1
+ /*!
2
+ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
3
+ Copyright (C) 2025 jeffy-g <hirotom1107@gmail.com>
4
+ Released under the MIT license
5
+ https://opensource.org/licenses/mit-license.php
6
+ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
7
+ */
8
+ import type { TESIResponseOKMap } from "./v2";
9
+ /**
10
+ * __{Header}.{Payload}.{Signature}__
11
+ */
12
+ type TAcccessToken = `${string}.${string}.${string}`;
13
+ type ESIRequestOptions = {
14
+ /**
15
+ * query params for ESI request.
16
+ */
17
+ query?: Record<string, any>;
18
+ /**
19
+ * will need it for `POST` request etc.
20
+ */
21
+ body?: any;
22
+ /**
23
+ * if want response data with ignore error then can be set to `true`.
24
+ */
25
+ ignoreError?: boolean;
26
+ /**
27
+ * cancel request immediately
28
+ */
29
+ cancelable?: AbortController;
30
+ /**
31
+ * Can be an empty object if no authentication is required.description
32
+ */
33
+ token?: TAcccessToken;
34
+ auth?: true;
35
+ };
36
+ /**
37
+ * fire ESI request
38
+ * @template {TESIEntryMethod} M
39
+ * @template {keyof TESIResponseOKMap[M]} EP
40
+ * @template {IsParameterizedPath<EP, number | number[], Opt>} P2
41
+ * @template {IdentifyParameters<TESIResponseOKMap[M][EP], ESIRequestOptions>} Opt
42
+ * @template {InferESIResponseResult<M, EP>} R
43
+ *
44
+ * @param {M} mthd
45
+ * @param {EP} endp - The endpoint to request.
46
+ * @param {Opt} [opt] - default is empty object {}. `body` is json string
47
+ * @param {P2} [pathParams] - Optional path parameters.
48
+ * @returns {Promise<R>} - The response from the endpoint.
49
+ * @throws
50
+ * @async
51
+ */
52
+ export declare function fire<
53
+ M extends TESIEntryMethod,
54
+ EP extends keyof TESIResponseOKMap[M],
55
+ Opt extends IdentifyParameters<TESIResponseOKMap[M][EP], ESIRequestOptions>,
56
+ P2 extends IsParameterizedPath<EP, number | number[], Opt>,
57
+ R extends InferESIResponseResult<M, EP>
58
+ >(mthd: M, endp: EP, pathParams?: P2, opt?: Opt): Promise<R>;
package/v2.mjs CHANGED
@@ -17,6 +17,7 @@ const BASE = "https://esi.evetech.net";
17
17
  * @typedef {import("./v2").TESIResponseOKMap} TESIResponseOKMap
18
18
  */
19
19
  /**
20
+ * @typedef {`${string}.${string}.${string}`} TAcccessToken __{Header}.{Payload}.{Signature}__
20
21
  * @typedef ESIRequestOptions
21
22
  * @prop {Record<string, any>} [query] query params for ESI request.
22
23
  * @prop {any} [body] will need it for `POST` request etc.
@@ -141,6 +142,8 @@ async function getEVEStatus() {
141
142
  order_type: "all"
142
143
  },
143
144
  });
145
+ // TODO: want TypeScript semantics to throw an error because there is a required query parameter, but it's not possible
146
+ await fire("get", "/characters/{character_id}/search/");
144
147
  console.log(ok);
145
148
  }
146
149
  catch (error) {
@@ -158,8 +161,8 @@ async function getEVEStatus() {
158
161
  *
159
162
  * @param {M} mthd
160
163
  * @param {EP} endp - The endpoint to request.
161
- * @param {P2} [pathParams] - Optional path parameters.
162
164
  * @param {Opt} [opt] - default is empty object {}. `body` is json string
165
+ * @param {P2} [pathParams] - Optional path parameters.
163
166
  * @returns {Promise<R>} - The response from the endpoint.
164
167
  * @throws
165
168
  * @async
@@ -167,7 +170,7 @@ async function getEVEStatus() {
167
170
  export async function fire(mthd, endp, pathParams, opt) {
168
171
  if (typeof pathParams === "number") {
169
172
  // @ts-ignore
170
- pathParams = [pathParams];
173
+ pathParams = [pathParams]; // as unknown as P2;
171
174
  }
172
175
  if (isArray(pathParams)) {
173
176
  // @ts-ignore actualy endp is string
@@ -216,9 +219,7 @@ export async function fire(mthd, endp, pathParams, opt) {
216
219
  ax++;
217
220
  try {
218
221
  // @ts-ignore A silly type error will appear, but ignore it.
219
- const res = await fetch(`${endpointUrl}?${new URLSearchParams(qss) + ""}`, rqopt).finally(() => {
220
- ax--;
221
- });
222
+ const res = await fetch(`${endpointUrl}?${new URLSearchParams(qss) + ""}`, rqopt).finally(() => ax--);
222
223
  const stat = res.status;
223
224
  if (!res.ok && !actualOpt.ignoreError) {
224
225
  if (stat === 420) {
package/esi-request.mjs DELETED
@@ -1,247 +0,0 @@
1
- // import type { TESIResponseOKMap } from "eve-esi-types";
2
- // - - - - - - - - - - - - - - - - - - - -
3
- // constants, types
4
- // - - - - - - - - - - - - - - - - - - - -
5
- // shorthands
6
- const log = console.log;
7
- const isArray = Array.isArray;
8
- /**
9
- * enable/disable console.log
10
- */
11
- let LOG = false;
12
- /**
13
- * this always `https://esi.evetech.net`
14
- */
15
- const BASE = "https://esi.evetech.net";
16
- /**
17
- * @typedef {import("./src").TESIResponseOKMap} TESIResponseOKMap
18
- */
19
- /**
20
- * @typedef ESIRequestOptions
21
- * @prop {Record<string, any>} [queries] query params for ESI request.
22
- * @prop {any} [body] will need it for `POST` request etc.
23
- * @prop {boolean} [ignoreError] if want response data with ignore error then can be set to `true`.
24
- * @prop {AbortController} [cancelable] cancel request immediately
25
- * @prop {string} [token] Can be an empty object if no authentication is required.description
26
- */
27
- // - - - - - - - - - - - - - - - - - - - -
28
- // module vars, functions
29
- // - - - - - - - - - - - - - - - - - - - -
30
- /**
31
- * Get the number of currently executing ESI requests
32
- */
33
- let ax = 0;
34
- /**
35
- * simple named error class.
36
- */
37
- class ESIRequesError extends Error {
38
- }
39
- /**
40
- * throws when x-esi-error-limit-remain header value is "0". (http status: 420)
41
- */
42
- class ESIErrorLimitReachedError extends Error {
43
- constructor() {
44
- super("Cannot continue ESI request because 'x-esi-error-limit-remain' is zero!");
45
- }
46
- valueOf() {
47
- return 420;
48
- }
49
- }
50
- /**
51
- * fetch the extra pages
52
- *
53
- * + if the `x-pages` header property ware more than 1
54
- *
55
- * @param {string} endpointUrl
56
- * @param {RequestInit} rqopt request options
57
- * @param {Record<string, any>} qs queries
58
- * @param {number} pc pageCount
59
- */
60
- const fetchP = async (endpointUrl, rqopt, qs, pc) => {
61
- const rqs = [];
62
- const rqp = new URLSearchParams(qs);
63
- for (let i = 2; i <= pc;) {
64
- rqp.set("page", (i++) + "");
65
- ax++;
66
- rqs.push(fetch(`${endpointUrl}?${rqp + ""}`, rqopt).then(res => res.json()).catch(reason => {
67
- console.warn(reason);
68
- return [];
69
- }).finally(() => {
70
- ax--;
71
- }));
72
- }
73
- return Promise.all(rqs).then(jsons => {
74
- // DEVNOTE: let check the page 2, type is array?
75
- if (isArray(jsons[0])) {
76
- let combined = [];
77
- for (let i = 0, end = jsons.length; i < end;) {
78
- combined = combined.concat(jsons[i++]);
79
- }
80
- return combined;
81
- }
82
- LOG && log("> > > pages result are object < < < --", jsons);
83
- return null;
84
- });
85
- };
86
- /** ### replace (C)urly (B)races (T)oken
87
- *
88
- * @example
89
- * "/characters/{character_id}/skills"
90
- * // ->
91
- * "/characters/<char.character_id>/skills"
92
- *
93
- * @param {string} endpoint e.g - "/characters/{character_id}/"
94
- * @param {number[]} ids
95
- * @returns fragment of qualified endpoint uri or null.
96
- */
97
- const replaceCbt = (endpoint, ids) => {
98
- const re = /{([\w]+)}/g;
99
- /** @type {RegExpExecArray?} */
100
- let m;
101
- let idx = 0;
102
- while (m = re.exec(endpoint)) {
103
- endpoint = endpoint.replace(m[0], ids[idx++] + "");
104
- }
105
- return endpoint;
106
- };
107
- /**
108
- *
109
- * @param {string} endp this means endpoint url fragment like `/characters/{character_id}/` or `/characters/{character_id}/agents_research/`
110
- * + The version parameter can be omitted by using `<version>/<endpoint>`
111
- */
112
- const curl = (endp) => {
113
- endp = endp.replace(/^\/+|\/+$/g, "");
114
- return `${BASE}/latest/${endp}/`;
115
- };
116
- // - - - - - - - - - - - - - - - - - - - -
117
- // main functions
118
- // - - - - - - - - - - - - - - - - - - - -
119
- /**
120
- * fire ESI request
121
- * @template {"get" | "post" | "put" | "delete"} M
122
- * @template {keyof TESIResponseOKMap[M]} EP
123
- * @template {TESIResponseOKMap[M][EP]} R
124
- *
125
- * @param {M} mthd
126
- * @param {EP} endp - The endpoint to request.
127
- * @param {number | number[] | ESIRequestOptions} [pathParams] - Optional path parameters.
128
- * @param {ESIRequestOptions} [opt] - default is empty object {}. `body` is json string
129
- * @returns {Promise<R>} - The response from the endpoint.
130
- * @throws
131
- * @async
132
- */
133
- export async function fire(mthd, endp, pathParams, opt = {}) {
134
- if (typeof pathParams === "number") {
135
- pathParams = /** @type {number[]} */ ([pathParams]);
136
- }
137
- if (isArray(pathParams)) {
138
- // @ts-ignore actualy endp is string
139
- endp = replaceCbt(endp, pathParams);
140
- }
141
- else {
142
- // When only options are provided
143
- opt = /** @type {ESIRequestOptions} */ (pathParams) || opt;
144
- }
145
- /** @type {RequestInit} */
146
- const rqopt = {
147
- method: mthd,
148
- mode: "cors",
149
- cache: "no-cache",
150
- signal: opt.cancelable?.signal,
151
- headers: {}
152
- };
153
- const qss = {
154
- // language: "en",
155
- };
156
- if (opt.queries) {
157
- // Object.assign(queries, options.queries); Object.assign is too slow
158
- const oqs = opt.queries;
159
- for (const k of Object.keys(oqs)) {
160
- qss[k] = oqs[k];
161
- }
162
- }
163
- // DEVNOTE: when datasource is not empty string. (e.g - "singularity"
164
- // in this case must specify datasource.
165
- // disabled since `REMOVING DATASOURCE SINGULARITY`
166
- // if (opt.datasource === "singularity") {
167
- // opt.datasource = "tranquility";
168
- // }
169
- if (opt.token) {
170
- // @ts-ignore The header is indeed an object
171
- rqopt.headers.authorization = `Bearer ${opt.token}`;
172
- }
173
- if (opt.body) { // means "POST" method etc
174
- // @ts-ignore The header is indeed an object
175
- rqopt.headers["content-type"] = "application/json";
176
- rqopt.body = JSON.stringify(opt.body);
177
- }
178
- // @ts-ignore actualy endp is string
179
- const endpointUrl = curl(endp);
180
- ax++;
181
- try {
182
- // @ts-ignore A silly type error will appear, but ignore it.
183
- const res = await fetch(`${endpointUrl}?${new URLSearchParams(qss) + ""}`, rqopt).finally(() => {
184
- ax--;
185
- });
186
- const stat = res.status;
187
- if (!res.ok && !opt.ignoreError) {
188
- if (stat === 420) {
189
- opt.cancelable && opt.cancelable.abort();
190
- throw new ESIErrorLimitReachedError();
191
- }
192
- else {
193
- // @ts-ignore actualy endp is string
194
- throw new ESIRequesError(`maybe network disconneted or otherwise request data are invalid. (endpoint=${endp}, http status=${stat})`);
195
- }
196
- }
197
- else {
198
- // DEVNOTE: - 204 No Content
199
- if (stat === 204) {
200
- // this result is empty, decided to return status code.
201
- return /** @type {R} */ ({ status: stat });
202
- }
203
- /** @type {R} */
204
- const data = await res.json();
205
- if (opt.ignoreError) {
206
- // meaning `forceJson`?
207
- return data;
208
- }
209
- // - - - - x-pages response.
210
- // +undefined is NaN
211
- // @ts-ignore becouse +null is 0
212
- const pc = +res.headers.get("x-pages");
213
- // has remaining pages? NaN > 1 === false !isNaN(pageCount)
214
- if (pc > 1) {
215
- LOG && log('found "x-pages" header, pages: %d', pc);
216
- const remData = await fetchP(endpointUrl, rqopt, qss, pc);
217
- // finally, decide product data.
218
- if (isArray(data) && isArray(remData)) {
219
- // DEVNOTE: 2019/7/23 15:01:48 - types
220
- return /** @type {R} */ (data.concat(remData));
221
- }
222
- else {
223
- // @ts-ignore TODO: fix type
224
- remData && Object.assign(data, remData);
225
- }
226
- }
227
- return data;
228
- }
229
- }
230
- catch (e) {
231
- // @ts-ignore actualy endp is string
232
- throw new ESIRequesError(`unknown error occurred, message: ${e.message}, endpoint=${endp}`);
233
- }
234
- }
235
- // It should complete correctly.
236
- async function getEVEStatus() {
237
- return fire("get", "/status/");
238
- }
239
- // type following and run
240
- // node esi-request.mjs
241
- // or yarn test
242
- getEVEStatus().then(eveStatus => console.log(eveStatus));
243
- // {
244
- // "players": 16503,
245
- // "server_version": "2794925",
246
- // "start_time": "2025-01-21T11:02:34Z"
247
- // }
@@ -1,27 +0,0 @@
1
- /**
2
- * ESI endpoint: /alliances/{alliance_id}/contacts/labels/
3
- */
4
-
5
- /**
6
- * label_id integer
7
- */
8
- type GetAlliancesAllianceIdContactsLabelsLabelId = number;
9
- /**
10
- * label_name string
11
- */
12
- type GetAlliancesAllianceIdContactsLabelsLabelName = string;
13
- /**
14
- * 200 ok array
15
- *
16
- * @maxItems 64
17
- */
18
- type GetAlliancesAllianceIdContactsLabelsOk = GetAlliancesAllianceIdContactsLabels_200Ok[];
19
-
20
- /**
21
- * 200 ok object
22
- */
23
- interface GetAlliancesAllianceIdContactsLabels_200Ok {
24
- label_id: GetAlliancesAllianceIdContactsLabelsLabelId;
25
- label_name: GetAlliancesAllianceIdContactsLabelsLabelName;
26
- [k: string]: unknown | undefined;
27
- }
@@ -1,43 +0,0 @@
1
- /**
2
- * ESI endpoint: /alliances/{alliance_id}/contacts/
3
- */
4
-
5
- /**
6
- * contact_id integer
7
- */
8
- type GetAlliancesAllianceIdContactsContactId = number;
9
- /**
10
- * contact_type string
11
- */
12
- type GetAlliancesAllianceIdContactsContactType = "character" | "corporation" | "alliance" | "faction";
13
- /**
14
- * Label IDs applied to the contact
15
- */
16
- type GetAlliancesAllianceIdContactsLabelId = number;
17
- /**
18
- * label_ids array
19
- *
20
- * @maxItems 63
21
- */
22
- type GetAlliancesAllianceIdContactsLabelIds = GetAlliancesAllianceIdContactsLabelId[];
23
- /**
24
- * Standing of the contact
25
- */
26
- type GetAlliancesAllianceIdContactsStanding = number;
27
- /**
28
- * 200 ok array
29
- *
30
- * @maxItems 1000
31
- */
32
- type GetAlliancesAllianceIdContactsOk = GetAlliancesAllianceIdContacts_200Ok[];
33
-
34
- /**
35
- * 200 ok object
36
- */
37
- interface GetAlliancesAllianceIdContacts_200Ok {
38
- contact_id: GetAlliancesAllianceIdContactsContactId;
39
- contact_type: GetAlliancesAllianceIdContactsContactType;
40
- label_ids?: GetAlliancesAllianceIdContactsLabelIds;
41
- standing: GetAlliancesAllianceIdContactsStanding;
42
- [k: string]: unknown | undefined;
43
- }
@@ -1,14 +0,0 @@
1
- /**
2
- * ESI endpoint: /alliances/{alliance_id}/corporations/
3
- */
4
-
5
- /**
6
- * 200 ok integer
7
- */
8
- type GetAlliancesAllianceIdCorporations_200Ok = number;
9
- /**
10
- * 200 ok array
11
- *
12
- * @maxItems 1000
13
- */
14
- type GetAlliancesAllianceIdCorporationsOk = GetAlliancesAllianceIdCorporations_200Ok[];
@@ -1,21 +0,0 @@
1
- /**
2
- * ESI endpoint: /alliances/{alliance_id}/icons/
3
- */
4
-
5
- /**
6
- * px128x128 string
7
- */
8
- type GetAlliancesAllianceIdIconsPx128X128 = string;
9
- /**
10
- * px64x64 string
11
- */
12
- type GetAlliancesAllianceIdIconsPx64X64 = string;
13
-
14
- /**
15
- * 200 ok object
16
- */
17
- interface GetAlliancesAllianceIdIconsOk {
18
- px128x128?: GetAlliancesAllianceIdIconsPx128X128;
19
- px64x64?: GetAlliancesAllianceIdIconsPx64X64;
20
- [k: string]: unknown | undefined;
21
- }
@@ -1,46 +0,0 @@
1
- /**
2
- * ESI endpoint: /alliances/{alliance_id}/
3
- */
4
-
5
- /**
6
- * ID of the corporation that created the alliance
7
- */
8
- type GetAlliancesAllianceIdCreatorCorporationId = number;
9
- /**
10
- * ID of the character that created the alliance
11
- */
12
- type GetAlliancesAllianceIdCreatorId = number;
13
- /**
14
- * date_founded string
15
- */
16
- type GetAlliancesAllianceIdDateFounded = string;
17
- /**
18
- * the executor corporation ID, if this alliance is not closed
19
- */
20
- type GetAlliancesAllianceIdExecutorCorporationId = number;
21
- /**
22
- * Faction ID this alliance is fighting for, if this alliance is enlisted in factional warfare
23
- */
24
- type GetAlliancesAllianceIdFactionId = number;
25
- /**
26
- * the full name of the alliance
27
- */
28
- type GetAlliancesAllianceIdName = string;
29
- /**
30
- * the short name of the alliance
31
- */
32
- type GetAlliancesAllianceIdTicker = string;
33
-
34
- /**
35
- * 200 ok object
36
- */
37
- interface GetAlliancesAllianceIdOk {
38
- creator_corporation_id: GetAlliancesAllianceIdCreatorCorporationId;
39
- creator_id: GetAlliancesAllianceIdCreatorId;
40
- date_founded: GetAlliancesAllianceIdDateFounded;
41
- executor_corporation_id?: GetAlliancesAllianceIdExecutorCorporationId;
42
- faction_id?: GetAlliancesAllianceIdFactionId;
43
- name: GetAlliancesAllianceIdName;
44
- ticker: GetAlliancesAllianceIdTicker;
45
- [k: string]: unknown | undefined;
46
- }
@@ -1,14 +0,0 @@
1
- /**
2
- * ESI endpoint: /alliances/
3
- */
4
-
5
- /**
6
- * 200 ok integer
7
- */
8
- type GetAlliances_200Ok = number;
9
- /**
10
- * 200 ok array
11
- *
12
- * @maxItems 5000
13
- */
14
- type GetAlliancesOk = GetAlliances_200Ok[];
@@ -1,42 +0,0 @@
1
- /**
2
- * ESI endpoint: /characters/{character_id}/agents_research/
3
- */
4
-
5
- /**
6
- * agent_id integer
7
- */
8
- type GetCharactersCharacterIdAgentsResearchAgentId = number;
9
- /**
10
- * points_per_day number
11
- */
12
- type GetCharactersCharacterIdAgentsResearchPointsPerDay = number;
13
- /**
14
- * remainder_points number
15
- */
16
- type GetCharactersCharacterIdAgentsResearchRemainderPoints = number;
17
- /**
18
- * skill_type_id integer
19
- */
20
- type GetCharactersCharacterIdAgentsResearchSkillTypeId = number;
21
- /**
22
- * started_at string
23
- */
24
- type GetCharactersCharacterIdAgentsResearchStartedAt = string;
25
- /**
26
- * 200 ok array
27
- *
28
- * @maxItems 1000
29
- */
30
- type GetCharactersCharacterIdAgentsResearchOk = GetCharactersCharacterIdAgentsResearch_200Ok[];
31
-
32
- /**
33
- * 200 ok object
34
- */
35
- interface GetCharactersCharacterIdAgentsResearch_200Ok {
36
- agent_id: GetCharactersCharacterIdAgentsResearchAgentId;
37
- points_per_day: GetCharactersCharacterIdAgentsResearchPointsPerDay;
38
- remainder_points: GetCharactersCharacterIdAgentsResearchRemainderPoints;
39
- skill_type_id: GetCharactersCharacterIdAgentsResearchSkillTypeId;
40
- started_at: GetCharactersCharacterIdAgentsResearchStartedAt;
41
- [k: string]: unknown | undefined;
42
- }