eve-esi-types 2.1.2 → 2.2.1

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 (203) hide show
  1. package/README.md +1 -1
  2. package/minimal-rq.d.mts +26 -0
  3. package/minimal-rq.mjs +78 -0
  4. package/package.json +8 -3
  5. package/rq-util.d.mts +114 -0
  6. package/rq-util.mjs +262 -0
  7. package/tsconfig.json +3 -2
  8. package/v2/get_alliances_alliance_id_contacts_labels_ok.d.ts +1 -1
  9. package/v2/get_alliances_alliance_id_contacts_ok.d.ts +1 -1
  10. package/v2/get_alliances_alliance_id_corporations_ok.d.ts +1 -1
  11. package/v2/get_alliances_alliance_id_icons_ok.d.ts +1 -1
  12. package/v2/get_alliances_alliance_id_ok.d.ts +1 -1
  13. package/v2/get_alliances_ok.d.ts +1 -1
  14. package/v2/get_characters_character_id_agents_research_ok.d.ts +1 -1
  15. package/v2/get_characters_character_id_assets_ok.d.ts +1 -1
  16. package/v2/get_characters_character_id_attributes_ok.d.ts +1 -1
  17. package/v2/get_characters_character_id_blueprints_ok.d.ts +1 -1
  18. package/v2/get_characters_character_id_bookmarks_folders_ok.d.ts +1 -1
  19. package/v2/get_characters_character_id_bookmarks_ok.d.ts +1 -1
  20. package/v2/get_characters_character_id_calendar_event_id_attendees_ok.d.ts +1 -1
  21. package/v2/get_characters_character_id_calendar_event_id_ok.d.ts +1 -1
  22. package/v2/get_characters_character_id_calendar_ok.d.ts +1 -1
  23. package/v2/get_characters_character_id_clones_ok.d.ts +1 -1
  24. package/v2/get_characters_character_id_contacts_labels_ok.d.ts +1 -1
  25. package/v2/get_characters_character_id_contacts_ok.d.ts +1 -1
  26. package/v2/get_characters_character_id_contracts_contract_id_bids_ok.d.ts +1 -1
  27. package/v2/get_characters_character_id_contracts_contract_id_items_ok.d.ts +1 -1
  28. package/v2/get_characters_character_id_contracts_ok.d.ts +1 -1
  29. package/v2/get_characters_character_id_corporationhistory_ok.d.ts +1 -1
  30. package/v2/get_characters_character_id_fatigue_ok.d.ts +1 -1
  31. package/v2/get_characters_character_id_fittings_ok.d.ts +1 -1
  32. package/v2/get_characters_character_id_fleet_ok.d.ts +1 -1
  33. package/v2/get_characters_character_id_fw_stats_ok.d.ts +1 -1
  34. package/v2/get_characters_character_id_implants_ok.d.ts +1 -1
  35. package/v2/get_characters_character_id_industry_jobs_ok.d.ts +1 -1
  36. package/v2/get_characters_character_id_killmails_recent_ok.d.ts +1 -1
  37. package/v2/get_characters_character_id_location_ok.d.ts +1 -1
  38. package/v2/get_characters_character_id_loyalty_points_ok.d.ts +1 -1
  39. package/v2/get_characters_character_id_mail_labels_ok.d.ts +1 -1
  40. package/v2/get_characters_character_id_mail_lists_ok.d.ts +1 -1
  41. package/v2/get_characters_character_id_mail_mail_id_ok.d.ts +1 -1
  42. package/v2/get_characters_character_id_mail_ok.d.ts +1 -1
  43. package/v2/get_characters_character_id_medals_ok.d.ts +1 -1
  44. package/v2/get_characters_character_id_mining_ok.d.ts +1 -1
  45. package/v2/get_characters_character_id_notifications_contacts_ok.d.ts +1 -1
  46. package/v2/get_characters_character_id_notifications_ok.d.ts +1 -1
  47. package/v2/get_characters_character_id_ok.d.ts +1 -1
  48. package/v2/get_characters_character_id_online_ok.d.ts +1 -1
  49. package/v2/get_characters_character_id_opportunities_ok.d.ts +1 -1
  50. package/v2/get_characters_character_id_orders_history_ok.d.ts +1 -1
  51. package/v2/get_characters_character_id_orders_ok.d.ts +1 -1
  52. package/v2/get_characters_character_id_planets_ok.d.ts +1 -1
  53. package/v2/get_characters_character_id_planets_planet_id_ok.d.ts +1 -1
  54. package/v2/get_characters_character_id_portrait_ok.d.ts +1 -1
  55. package/v2/get_characters_character_id_roles_ok.d.ts +1 -1
  56. package/v2/get_characters_character_id_search_ok.d.ts +1 -1
  57. package/v2/get_characters_character_id_ship_ok.d.ts +1 -1
  58. package/v2/get_characters_character_id_skillqueue_ok.d.ts +1 -1
  59. package/v2/get_characters_character_id_skills_ok.d.ts +1 -1
  60. package/v2/get_characters_character_id_standings_ok.d.ts +1 -1
  61. package/v2/get_characters_character_id_titles_ok.d.ts +1 -1
  62. package/v2/get_characters_character_id_wallet_journal_ok.d.ts +1 -1
  63. package/v2/get_characters_character_id_wallet_ok.d.ts +1 -1
  64. package/v2/get_characters_character_id_wallet_transactions_ok.d.ts +1 -1
  65. package/v2/get_contracts_public_bids_contract_id_ok.d.ts +1 -1
  66. package/v2/get_contracts_public_items_contract_id_ok.d.ts +1 -1
  67. package/v2/get_contracts_public_region_id_ok.d.ts +1 -1
  68. package/v2/get_corporation_corporation_id_mining_extractions_ok.d.ts +1 -1
  69. package/v2/get_corporation_corporation_id_mining_observers_observer_id_ok.d.ts +1 -1
  70. package/v2/get_corporation_corporation_id_mining_observers_ok.d.ts +1 -1
  71. package/v2/get_corporations_corporation_id_alliancehistory_ok.d.ts +1 -1
  72. package/v2/get_corporations_corporation_id_assets_ok.d.ts +1 -1
  73. package/v2/get_corporations_corporation_id_blueprints_ok.d.ts +1 -1
  74. package/v2/get_corporations_corporation_id_bookmarks_folders_ok.d.ts +1 -1
  75. package/v2/get_corporations_corporation_id_bookmarks_ok.d.ts +1 -1
  76. package/v2/get_corporations_corporation_id_contacts_labels_ok.d.ts +1 -1
  77. package/v2/get_corporations_corporation_id_contacts_ok.d.ts +1 -1
  78. package/v2/get_corporations_corporation_id_containers_logs_ok.d.ts +1 -1
  79. package/v2/get_corporations_corporation_id_contracts_contract_id_bids_ok.d.ts +1 -1
  80. package/v2/get_corporations_corporation_id_contracts_contract_id_items_ok.d.ts +1 -1
  81. package/v2/get_corporations_corporation_id_contracts_ok.d.ts +1 -1
  82. package/v2/get_corporations_corporation_id_customs_offices_ok.d.ts +1 -1
  83. package/v2/get_corporations_corporation_id_divisions_ok.d.ts +1 -1
  84. package/v2/get_corporations_corporation_id_facilities_ok.d.ts +1 -1
  85. package/v2/get_corporations_corporation_id_fw_stats_ok.d.ts +1 -1
  86. package/v2/get_corporations_corporation_id_icons_ok.d.ts +1 -1
  87. package/v2/get_corporations_corporation_id_industry_jobs_ok.d.ts +1 -1
  88. package/v2/get_corporations_corporation_id_killmails_recent_ok.d.ts +1 -1
  89. package/v2/get_corporations_corporation_id_medals_issued_ok.d.ts +1 -1
  90. package/v2/get_corporations_corporation_id_medals_ok.d.ts +1 -1
  91. package/v2/get_corporations_corporation_id_members_limit_ok.d.ts +1 -1
  92. package/v2/get_corporations_corporation_id_members_ok.d.ts +1 -1
  93. package/v2/get_corporations_corporation_id_members_titles_ok.d.ts +1 -1
  94. package/v2/get_corporations_corporation_id_membertracking_ok.d.ts +1 -1
  95. package/v2/get_corporations_corporation_id_ok.d.ts +1 -1
  96. package/v2/get_corporations_corporation_id_orders_history_ok.d.ts +1 -1
  97. package/v2/get_corporations_corporation_id_orders_ok.d.ts +1 -1
  98. package/v2/get_corporations_corporation_id_roles_history_ok.d.ts +1 -1
  99. package/v2/get_corporations_corporation_id_roles_ok.d.ts +1 -1
  100. package/v2/get_corporations_corporation_id_shareholders_ok.d.ts +1 -1
  101. package/v2/get_corporations_corporation_id_standings_ok.d.ts +1 -1
  102. package/v2/get_corporations_corporation_id_starbases_ok.d.ts +1 -1
  103. package/v2/get_corporations_corporation_id_starbases_starbase_id_ok.d.ts +1 -1
  104. package/v2/get_corporations_corporation_id_structures_ok.d.ts +1 -1
  105. package/v2/get_corporations_corporation_id_titles_ok.d.ts +1 -1
  106. package/v2/get_corporations_corporation_id_wallets_division_journal_ok.d.ts +1 -1
  107. package/v2/get_corporations_corporation_id_wallets_division_transactions_ok.d.ts +1 -1
  108. package/v2/get_corporations_corporation_id_wallets_ok.d.ts +1 -1
  109. package/v2/get_corporations_npccorps_ok.d.ts +1 -1
  110. package/v2/get_dogma_attributes_attribute_id_ok.d.ts +1 -1
  111. package/v2/get_dogma_attributes_ok.d.ts +1 -1
  112. package/v2/get_dogma_dynamic_items_type_id_item_id_ok.d.ts +1 -1
  113. package/v2/get_dogma_effects_effect_id_ok.d.ts +1 -1
  114. package/v2/get_dogma_effects_ok.d.ts +1 -1
  115. package/v2/get_fleets_fleet_id_members_ok.d.ts +1 -1
  116. package/v2/get_fleets_fleet_id_ok.d.ts +1 -1
  117. package/v2/get_fleets_fleet_id_wings_ok.d.ts +1 -1
  118. package/v2/get_fw_leaderboards_characters_ok.d.ts +1 -1
  119. package/v2/get_fw_leaderboards_corporations_ok.d.ts +1 -1
  120. package/v2/get_fw_leaderboards_ok.d.ts +1 -1
  121. package/v2/get_fw_stats_ok.d.ts +1 -1
  122. package/v2/get_fw_systems_ok.d.ts +1 -1
  123. package/v2/get_fw_wars_ok.d.ts +1 -1
  124. package/v2/get_incursions_ok.d.ts +1 -1
  125. package/v2/get_industry_facilities_ok.d.ts +1 -1
  126. package/v2/get_industry_systems_ok.d.ts +1 -1
  127. package/v2/get_insurance_prices_ok.d.ts +1 -1
  128. package/v2/get_killmails_killmail_id_killmail_hash_ok.d.ts +1 -1
  129. package/v2/get_loyalty_stores_corporation_id_offers_ok.d.ts +1 -1
  130. package/v2/get_markets_groups_market_group_id_ok.d.ts +1 -1
  131. package/v2/get_markets_groups_ok.d.ts +1 -1
  132. package/v2/get_markets_prices_ok.d.ts +1 -1
  133. package/v2/get_markets_region_id_history_ok.d.ts +1 -1
  134. package/v2/get_markets_region_id_orders_ok.d.ts +1 -1
  135. package/v2/get_markets_region_id_types_ok.d.ts +1 -1
  136. package/v2/get_markets_structures_structure_id_ok.d.ts +1 -1
  137. package/v2/get_opportunities_groups_group_id_ok.d.ts +1 -1
  138. package/v2/get_opportunities_groups_ok.d.ts +1 -1
  139. package/v2/get_opportunities_tasks_ok.d.ts +1 -1
  140. package/v2/get_opportunities_tasks_task_id_ok.d.ts +1 -1
  141. package/v2/get_route_origin_destination_ok.d.ts +1 -1
  142. package/v2/get_sovereignty_campaigns_ok.d.ts +1 -1
  143. package/v2/get_sovereignty_map_ok.d.ts +1 -1
  144. package/v2/get_sovereignty_structures_ok.d.ts +1 -1
  145. package/v2/get_status_ok.d.ts +1 -1
  146. package/v2/get_universe_ancestries_ok.d.ts +1 -1
  147. package/v2/get_universe_asteroid_belts_asteroid_belt_id_ok.d.ts +1 -1
  148. package/v2/get_universe_bloodlines_ok.d.ts +1 -1
  149. package/v2/get_universe_categories_category_id_ok.d.ts +1 -1
  150. package/v2/get_universe_categories_ok.d.ts +1 -1
  151. package/v2/get_universe_constellations_constellation_id_ok.d.ts +1 -1
  152. package/v2/get_universe_constellations_ok.d.ts +1 -1
  153. package/v2/get_universe_factions_ok.d.ts +1 -1
  154. package/v2/get_universe_graphics_graphic_id_ok.d.ts +1 -1
  155. package/v2/get_universe_graphics_ok.d.ts +1 -1
  156. package/v2/get_universe_groups_group_id_ok.d.ts +1 -1
  157. package/v2/get_universe_groups_ok.d.ts +1 -1
  158. package/v2/get_universe_moons_moon_id_ok.d.ts +1 -1
  159. package/v2/get_universe_planets_planet_id_ok.d.ts +1 -1
  160. package/v2/get_universe_races_ok.d.ts +1 -1
  161. package/v2/get_universe_regions_ok.d.ts +1 -1
  162. package/v2/get_universe_regions_region_id_ok.d.ts +1 -1
  163. package/v2/get_universe_schematics_schematic_id_ok.d.ts +1 -1
  164. package/v2/get_universe_stargates_stargate_id_ok.d.ts +1 -1
  165. package/v2/get_universe_stars_star_id_ok.d.ts +1 -1
  166. package/v2/get_universe_stations_station_id_ok.d.ts +1 -1
  167. package/v2/get_universe_structures_ok.d.ts +1 -1
  168. package/v2/get_universe_structures_structure_id_ok.d.ts +1 -1
  169. package/v2/get_universe_system_jumps_ok.d.ts +1 -1
  170. package/v2/get_universe_system_kills_ok.d.ts +1 -1
  171. package/v2/get_universe_systems_ok.d.ts +1 -1
  172. package/v2/get_universe_systems_system_id_ok.d.ts +1 -1
  173. package/v2/get_universe_types_ok.d.ts +1 -1
  174. package/v2/get_universe_types_type_id_ok.d.ts +1 -1
  175. package/v2/get_wars_ok.d.ts +1 -1
  176. package/v2/get_wars_war_id_killmails_ok.d.ts +1 -1
  177. package/v2/get_wars_war_id_ok.d.ts +1 -1
  178. package/v2/index.d.ts +190 -36
  179. package/v2/post_characters_affiliation_ok.d.ts +1 -1
  180. package/v2/post_characters_character_id_assets_locations_ok.d.ts +1 -1
  181. package/v2/post_characters_character_id_assets_names_ok.d.ts +1 -1
  182. package/v2/post_characters_character_id_contacts_created.d.ts +1 -1
  183. package/v2/post_characters_character_id_cspa_created.d.ts +1 -1
  184. package/v2/post_characters_character_id_fittings_created.d.ts +1 -1
  185. package/v2/post_characters_character_id_mail_created.d.ts +1 -1
  186. package/v2/post_characters_character_id_mail_labels_created.d.ts +1 -1
  187. package/v2/post_corporations_corporation_id_assets_locations_ok.d.ts +1 -1
  188. package/v2/post_corporations_corporation_id_assets_names_ok.d.ts +1 -1
  189. package/v2/post_fleets_fleet_id_wings_created.d.ts +1 -1
  190. package/v2/post_fleets_fleet_id_wings_wing_id_squads_created.d.ts +1 -1
  191. package/v2/post_universe_ids_ok.d.ts +1 -1
  192. package/v2/post_universe_names_ok.d.ts +1 -1
  193. package/v2.d.mts +1 -27
  194. package/v2.mjs +28 -174
  195. package/v2/post_fleets_fleet_id_members_invitation.d.ts +0 -27
  196. package/v2/post_ui_openwindow_newmail_new_mail.d.ts +0 -40
  197. package/v2/put_characters_character_id_calendar_event_id_response.d.ts +0 -15
  198. package/v2/put_characters_character_id_contacts_contact_ids.d.ts +0 -16
  199. package/v2/put_characters_character_id_mail_mail_id_contents.d.ts +0 -20
  200. package/v2/put_fleets_fleet_id_members_member_id_movement.d.ts +0 -27
  201. package/v2/put_fleets_fleet_id_new_settings.d.ts +0 -18
  202. package/v2/put_fleets_fleet_id_squads_squad_id_naming.d.ts +0 -14
  203. package/v2/put_fleets_fleet_id_wings_wing_id_naming.d.ts +0 -14
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * ESI endpoint: /characters/affiliation/
2
+ * ESI endpoint: post:/characters/affiliation/
3
3
  */
4
4
  /**
5
5
  * 200 ok array
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * ESI endpoint: /characters/{character_id}/assets/locations/
2
+ * ESI endpoint: post:/characters/{character_id}/assets/locations/
3
3
  */
4
4
  /**
5
5
  * 200 ok array
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * ESI endpoint: /characters/{character_id}/assets/names/
2
+ * ESI endpoint: post:/characters/{character_id}/assets/names/
3
3
  */
4
4
  /**
5
5
  * 200 ok array
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * ESI endpoint: /characters/{character_id}/contacts/
2
+ * ESI endpoint: post:/characters/{character_id}/contacts/
3
3
  */
4
4
  /**
5
5
  * 201 created array
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * ESI endpoint: /characters/{character_id}/cspa/
2
+ * ESI endpoint: post:/characters/{character_id}/cspa/
3
3
  */
4
4
  /**
5
5
  * 201 created number
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * ESI endpoint: /characters/{character_id}/fittings/
2
+ * ESI endpoint: post:/characters/{character_id}/fittings/
3
3
  */
4
4
 
5
5
  /**
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * ESI endpoint: /characters/{character_id}/mail/
2
+ * ESI endpoint: post:/characters/{character_id}/mail/
3
3
  */
4
4
  /**
5
5
  * Mail ID
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * ESI endpoint: /characters/{character_id}/mail/labels/
2
+ * ESI endpoint: post:/characters/{character_id}/mail/labels/
3
3
  */
4
4
  /**
5
5
  * Label ID
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * ESI endpoint: /corporations/{corporation_id}/assets/locations/
2
+ * ESI endpoint: post:/corporations/{corporation_id}/assets/locations/
3
3
  */
4
4
  /**
5
5
  * 200 ok array
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * ESI endpoint: /corporations/{corporation_id}/assets/names/
2
+ * ESI endpoint: post:/corporations/{corporation_id}/assets/names/
3
3
  */
4
4
  /**
5
5
  * 200 ok array
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * ESI endpoint: /fleets/{fleet_id}/wings/
2
+ * ESI endpoint: post:/fleets/{fleet_id}/wings/
3
3
  */
4
4
 
5
5
  /**
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * ESI endpoint: /fleets/{fleet_id}/wings/{wing_id}/squads/
2
+ * ESI endpoint: post:/fleets/{fleet_id}/wings/{wing_id}/squads/
3
3
  */
4
4
 
5
5
  /**
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * ESI endpoint: /universe/ids/
2
+ * ESI endpoint: post:/universe/ids/
3
3
  */
4
4
 
5
5
  /**
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * ESI endpoint: /universe/names/
2
+ * ESI endpoint: post:/universe/names/
3
3
  */
4
4
  /**
5
5
  * category string
package/v2.d.mts CHANGED
@@ -6,33 +6,7 @@
6
6
  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
7
7
  */
8
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
- };
9
+ import { type ESIRequestOptions } from "./rq-util.mjs";
36
10
  /**
37
11
  * fire ESI request
38
12
  * @template {TESIEntryMethod} M
package/v2.mjs CHANGED
@@ -1,4 +1,5 @@
1
1
  // import type { TESIResponseOKMap } from "eve-esi-types";
2
+ import { curl, fetchP, replaceCbt, getSDEVersion, ESIRequesError, initOptions, isDebug, ESIErrorLimitReachedError, fireRequestsDoesNotRequireAuth } from "./rq-util.mjs";
2
3
  // - - - - - - - - - - - - - - - - - - - -
3
4
  // constants, types
4
5
  // - - - - - - - - - - - - - - - - - - - -
@@ -8,23 +9,10 @@ const isArray = Array.isArray;
8
9
  /**
9
10
  * enable/disable console.log
10
11
  */
11
- let LOG = false;
12
- /**
13
- * this always `https://esi.evetech.net`
14
- */
15
- const BASE = "https://esi.evetech.net";
12
+ let LOG = isDebug();
16
13
  /**
17
14
  * @typedef {import("./v2").TESIResponseOKMap} TESIResponseOKMap
18
- */
19
- /**
20
- * @typedef {`${string}.${string}.${string}`} TAcccessToken __{Header}.{Payload}.{Signature}__
21
- * @typedef ESIRequestOptions
22
- * @prop {Record<string, any>} [query] query params for ESI request.
23
- * @prop {any} [body] will need it for `POST` request etc.
24
- * @prop {true=} [auth] Can be an empty object if no authentication is required.description
25
- * @prop {string} [token] Can be an empty object if no authentication is required.description
26
- * @prop {boolean} [ignoreError] if want response data with ignore error then can be set to `true`.
27
- * @prop {AbortController} [cancelable] cancel request immediately
15
+ * @typedef {import("./rq-util.mjs").ESIRequestOptions} ESIRequestOptions
28
16
  */
29
17
  // - - - - - - - - - - - - - - - - - - - -
30
18
  // module vars, functions
@@ -33,124 +21,10 @@ const BASE = "https://esi.evetech.net";
33
21
  * Get the number of currently executing ESI requests
34
22
  */
35
23
  let ax = 0;
36
- /**
37
- * simple named error class.
38
- */
39
- class ESIRequesError extends Error {
40
- }
41
- /**
42
- * throws when x-esi-error-limit-remain header value is "0". (http status: 420)
43
- */
44
- class ESIErrorLimitReachedError extends Error {
45
- constructor() {
46
- super("Cannot continue ESI request because 'x-esi-error-limit-remain' is zero!");
47
- }
48
- valueOf() {
49
- return 420;
50
- }
51
- }
52
- /**
53
- * fetch the extra pages
54
- *
55
- * + if the `x-pages` header property ware more than 1
56
- *
57
- * @param {string} endpointUrl
58
- * @param {RequestInit} rqopt request options
59
- * @param {Record<string, any>} qs queries
60
- * @param {number} pc pageCount
61
- */
62
- const fetchP = async (endpointUrl, rqopt, qs, pc) => {
63
- const rqs = [];
64
- const rqp = new URLSearchParams(qs);
65
- for (let i = 2; i <= pc;) {
66
- rqp.set("page", (i++) + "");
67
- ax++;
68
- rqs.push(fetch(`${endpointUrl}?${rqp + ""}`, rqopt).then(res => res.json()).catch(reason => {
69
- console.warn(reason);
70
- return [];
71
- }).finally(() => {
72
- ax--;
73
- }));
74
- }
75
- return Promise.all(rqs).then(jsons => {
76
- // DEVNOTE: let check the page 2, type is array?
77
- if (isArray(jsons[0])) {
78
- let combined = [];
79
- for (let i = 0, end = jsons.length; i < end;) {
80
- combined = combined.concat(jsons[i++]);
81
- }
82
- return combined;
83
- }
84
- LOG && log("> > > pages result are object < < < --", jsons);
85
- return null;
86
- });
87
- };
88
- /** ### replace (C)urly (B)races (T)oken
89
- *
90
- * @example
91
- * "/characters/{character_id}/skills"
92
- * // ->
93
- * "/characters/<char.character_id>/skills"
94
- *
95
- * @param {string} endpoint e.g - "/characters/{character_id}/"
96
- * @param {number[]} ids
97
- * @returns fragment of qualified endpoint uri or null.
98
- */
99
- const replaceCbt = (endpoint, ids) => {
100
- const re = /{([\w]+)}/g;
101
- /** @type {RegExpExecArray?} */
102
- let m;
103
- let idx = 0;
104
- while (m = re.exec(endpoint)) {
105
- endpoint = endpoint.replace(m[0], ids[idx++] + "");
106
- }
107
- return endpoint;
108
- };
109
- /**
110
- *
111
- * @param {string} endp this means endpoint url fragment like `/characters/{character_id}/` or `/characters/{character_id}/agents_research/`
112
- * + The version parameter can be omitted by using `<version>/<endpoint>`
113
- */
114
- const curl = (endp) => {
115
- endp = endp.replace(/^\/+|\/+$/g, "");
116
- return `${BASE}/latest/${endp}/`;
117
- };
24
+ const incrementAx = (minus) => minus ? ax-- : ax++;
118
25
  // - - - - - - - - - - - - - - - - - - - -
119
26
  // main functions
120
27
  // - - - - - - - - - - - - - - - - - - - -
121
- // It should complete correctly.
122
- async function getEVEStatus() {
123
- try {
124
- const ok = await fire("get", "/characters/{character_id}/ship/", 994562, { auth: true });
125
- // query patameter `filter` is optional
126
- await fire("get", "/universe/structures/", {
127
- query: {
128
- // filter: "market"
129
- }
130
- });
131
- // in this case, "categories" and "search" is required
132
- await fire("get", "/characters/{character_id}/search/", 994562, {
133
- query: {
134
- categories: ["agent"],
135
- search: "ok"
136
- },
137
- auth: true
138
- });
139
- // in this case, "order_type" is required
140
- await fire("get", "/markets/{region_id}/orders/", 994562, {
141
- query: {
142
- order_type: "all"
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/");
147
- console.log(ok);
148
- }
149
- catch (error) {
150
- console.error("Failed to get character ship -", error);
151
- }
152
- return fire("get", "/status/");
153
- }
154
28
  /**
155
29
  * fire ESI request
156
30
  * @template {TESIEntryMethod} M
@@ -179,63 +53,32 @@ export async function fire(mthd, endp, pathParams, opt) {
179
53
  // When only options are provided
180
54
  /** @type {Opt} */
181
55
  // @ts-ignore
182
- const actualOpt = pathParams || opt || {};
183
- /** @type {RequestInit} */
184
- const rqopt = {
185
- method: mthd,
186
- mode: "cors",
187
- cache: "no-cache",
188
- // @ts-ignore
189
- signal: actualOpt.cancelable?.signal,
190
- headers: {}
191
- };
192
- const qss = {
193
- language: "en",
194
- };
195
- if (actualOpt.query) {
196
- // Object.assign(queries, options.queries); Object.assign is too slow
197
- const oqs = actualOpt.query;
198
- for (const k of Object.keys(oqs)) {
199
- qss[k] = oqs[k];
200
- }
201
- }
202
- // DEVNOTE: when datasource is not empty string. (e.g - "singularity"
203
- // in this case must specify datasource.
204
- // disabled since `REMOVING DATASOURCE SINGULARITY`
205
- // if (actualOpt.datasource === "singularity") {
206
- // actualOpt.datasource = "tranquility";
207
- // }
208
- if (actualOpt.auth) {
209
- // @ts-ignore The header is indeed an object
210
- rqopt.headers.authorization = `Bearer ${actualOpt.token}`;
211
- }
212
- if (actualOpt.body) { // means "POST" method etc
213
- // @ts-ignore The header is indeed an object
214
- rqopt.headers["content-type"] = "application/json";
215
- rqopt.body = JSON.stringify(actualOpt.body);
216
- }
56
+ const actualOpt = opt || pathParams || {};
57
+ const { rqopt, qss } = initOptions(mthd, actualOpt);
217
58
  // @ts-ignore actualy endp is string
218
59
  const endpointUrl = curl(endp);
60
+ const url = `${endpointUrl}?${new URLSearchParams(qss) + ""}`;
61
+ LOG && log(url);
219
62
  ax++;
220
63
  try {
221
64
  // @ts-ignore A silly type error will appear, but ignore it.
222
- const res = await fetch(`${endpointUrl}?${new URLSearchParams(qss) + ""}`, rqopt).finally(() => ax--);
223
- const stat = res.status;
65
+ const res = await fetch(url, rqopt).finally(() => ax--);
66
+ const { status } = res;
224
67
  if (!res.ok && !actualOpt.ignoreError) {
225
- if (stat === 420) {
68
+ if (status === 420) {
226
69
  actualOpt.cancelable && actualOpt.cancelable.abort();
227
70
  throw new ESIErrorLimitReachedError();
228
71
  }
229
72
  else {
230
73
  // console.log(res);
231
- throw new ESIRequesError(`${res.statusText} (status=${stat})`);
74
+ throw new ESIRequesError(`${res.statusText} (status=${status})`);
232
75
  }
233
76
  }
234
77
  else {
235
78
  // DEVNOTE: - 204 No Content
236
- if (stat === 204) {
79
+ if (status === 204) {
237
80
  // this result is empty, decided to return status code.
238
- return /** @type {R} */ ({ status: stat });
81
+ return /** @type {R} */ ({ status });
239
82
  }
240
83
  /** @type {R} */
241
84
  const data = await res.json();
@@ -250,7 +93,7 @@ export async function fire(mthd, endp, pathParams, opt) {
250
93
  // has remaining pages? NaN > 1 === false !isNaN(pageCount)
251
94
  if (pc > 1) {
252
95
  LOG && log('found "x-pages" header, pages: %d', pc);
253
- const remData = await fetchP(endpointUrl, rqopt, qss, pc);
96
+ const remData = await fetchP(endpointUrl, rqopt, qss, pc, incrementAx);
254
97
  // finally, decide product data.
255
98
  if (isArray(data) && isArray(remData)) {
256
99
  // DEVNOTE: 2019/7/23 15:01:48 - types
@@ -269,10 +112,21 @@ export async function fire(mthd, endp, pathParams, opt) {
269
112
  throw new ESIRequesError(`message: ${e.message}, endpoint=${endp}`);
270
113
  }
271
114
  }
115
+ // It should complete correctly.
116
+ /**
117
+ * @param {TESIRequestFunctionSignature<ESIRequestOptions>} fn
118
+ */
119
+ async function getEVEStatus(fn) {
120
+ const sdeVersion = await getSDEVersion();
121
+ log(`sdeVersion: ${sdeVersion}`.blue);
122
+ await fireRequestsDoesNotRequireAuth(fn);
123
+ return fn("get", "/status/");
124
+ }
272
125
  // type following and run
126
+ // bun scripts/v2.mts
273
127
  // node v2.mjs
274
- // or yarn test:v2
275
- getEVEStatus().then(eveStatus => console.log(eveStatus));
128
+ // or yarn test
129
+ getEVEStatus(fire).then(eveStatus => console.log(eveStatus));
276
130
  // {
277
131
  // "players": 16503,
278
132
  // "server_version": "2794925",
@@ -1,27 +0,0 @@
1
- /*!
2
- * ESI endpoint: /fleets/{fleet_id}/members/
3
- */
4
- /**
5
- * If a character is invited with the `fleet_commander` role, neither `wing_id` or `squad_id` should be specified. If a character is invited with the `wing_commander` role, only `wing_id` should be specified. If a character is invited with the `squad_commander` role, both `wing_id` and `squad_id` should be specified. If a character is invited with the `squad_member` role, `wing_id` and `squad_id` should either both be specified or not specified at all. If they aren’t specified, the invited character will join any squad with available positions.
6
- */
7
- type PostFleetsFleetIdMembersRole = "fleet_commander" | "wing_commander" | "squad_commander" | "squad_member";
8
-
9
- /**
10
- * invitation object
11
- */
12
- interface PostFleetsFleetIdMembersInvitation {
13
- /**
14
- * The character you want to invite
15
- */
16
- character_id: number;
17
- role: PostFleetsFleetIdMembersRole;
18
- /**
19
- * squad_id integer
20
- */
21
- squad_id?: number;
22
- /**
23
- * wing_id integer
24
- */
25
- wing_id?: number;
26
- [k: string]: unknown | undefined;
27
- }
@@ -1,40 +0,0 @@
1
- /*!
2
- * ESI endpoint: /ui/openwindow/newmail/
3
- */
4
- /**
5
- * recipients array
6
- *
7
- * @minItems 1
8
- * @maxItems 50
9
- */
10
- type PostUiOpenwindowNewmailRecipients = [
11
- /**
12
- * recipient integer
13
- */
14
- number,
15
- ...number[]
16
- ];
17
-
18
- /**
19
- * new_mail object
20
- */
21
- interface PostUiOpenwindowNewmailNewMail {
22
- /**
23
- * body string
24
- */
25
- body: string;
26
- recipients: PostUiOpenwindowNewmailRecipients;
27
- /**
28
- * subject string
29
- */
30
- subject: string;
31
- /**
32
- * to_corp_or_alliance_id integer
33
- */
34
- to_corp_or_alliance_id?: number;
35
- /**
36
- * Corporations, alliances and mailing lists are all types of mailing groups. You may only send to one mailing group, at a time, so you may fill out either this field or the to_corp_or_alliance_ids field
37
- */
38
- to_mailing_list_id?: number;
39
- [k: string]: unknown | undefined;
40
- }
@@ -1,15 +0,0 @@
1
- /*!
2
- * ESI endpoint: /characters/{character_id}/calendar/{event_id}/
3
- */
4
- /**
5
- * response string
6
- */
7
- type PutCharactersCharacterIdCalendarEventIdResponseResponse = "accepted" | "declined" | "tentative";
8
-
9
- /**
10
- * response object
11
- */
12
- interface PutCharactersCharacterIdCalendarEventIdResponse {
13
- response: PutCharactersCharacterIdCalendarEventIdResponseResponse;
14
- [k: string]: unknown | undefined;
15
- }
@@ -1,16 +0,0 @@
1
- /*!
2
- * ESI endpoint: /characters/{character_id}/contacts/
3
- */
4
- /**
5
- * contact_ids array
6
- *
7
- * @minItems 1
8
- * @maxItems 100
9
- */
10
- type PutCharactersCharacterIdContactsContactIds = [
11
- /**
12
- * ID of the contact to edit
13
- */
14
- number,
15
- ...number[]
16
- ];
@@ -1,20 +0,0 @@
1
- /*!
2
- * ESI endpoint: /characters/{character_id}/mail/{mail_id}/
3
- */
4
-
5
- /**
6
- * contents object
7
- */
8
- interface PutCharactersCharacterIdMailMailIdContents {
9
- /**
10
- * Labels to assign to the mail. Pre-existing labels are unassigned.
11
- *
12
- * @maxItems 25
13
- */
14
- labels?: number[];
15
- /**
16
- * Whether the mail is flagged as read
17
- */
18
- read?: boolean;
19
- [k: string]: unknown | undefined;
20
- }
@@ -1,27 +0,0 @@
1
- /*!
2
- * ESI endpoint: /fleets/{fleet_id}/members/{member_id}/
3
- */
4
- /**
5
- * If a character is moved to the `fleet_commander` role, neither `wing_id` or `squad_id` should be specified. If a character is moved to the `wing_commander` role, only `wing_id` should be specified. If a character is moved to the `squad_commander` role, both `wing_id` and `squad_id` should be specified. If a character is moved to the `squad_member` role, both `wing_id` and `squad_id` should be specified.
6
- */
7
- type PutFleetsFleetIdMembersMemberIdRole =
8
- | "fleet_commander"
9
- | "wing_commander"
10
- | "squad_commander"
11
- | "squad_member";
12
-
13
- /**
14
- * movement object
15
- */
16
- interface PutFleetsFleetIdMembersMemberIdMovement {
17
- role: PutFleetsFleetIdMembersMemberIdRole;
18
- /**
19
- * squad_id integer
20
- */
21
- squad_id?: number;
22
- /**
23
- * wing_id integer
24
- */
25
- wing_id?: number;
26
- [k: string]: unknown | undefined;
27
- }
@@ -1,18 +0,0 @@
1
- /*!
2
- * ESI endpoint: /fleets/{fleet_id}/
3
- */
4
-
5
- /**
6
- * new_settings object
7
- */
8
- interface PutFleetsFleetIdNewSettings {
9
- /**
10
- * Should free-move be enabled in the fleet
11
- */
12
- is_free_move?: boolean;
13
- /**
14
- * New fleet MOTD in CCP flavoured HTML
15
- */
16
- motd?: string;
17
- [k: string]: unknown | undefined;
18
- }
@@ -1,14 +0,0 @@
1
- /*!
2
- * ESI endpoint: /fleets/{fleet_id}/squads/{squad_id}/
3
- */
4
-
5
- /**
6
- * naming object
7
- */
8
- interface PutFleetsFleetIdSquadsSquadIdNaming {
9
- /**
10
- * name string
11
- */
12
- name: string;
13
- [k: string]: unknown | undefined;
14
- }
@@ -1,14 +0,0 @@
1
- /*!
2
- * ESI endpoint: /fleets/{fleet_id}/wings/{wing_id}/
3
- */
4
-
5
- /**
6
- * naming object
7
- */
8
- interface PutFleetsFleetIdWingsWingIdNaming {
9
- /**
10
- * name string
11
- */
12
- name: string;
13
- [k: string]: unknown | undefined;
14
- }