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
package/README.md CHANGED
@@ -6,7 +6,7 @@ Extracted the main type of ESI. Used for ESI request response types.
6
6
  > This package is configured to use version 2 only.
7
7
 
8
8
  + If you need to use version 1, please refer to the following link:
9
- [eve-esi-types v1](https://github.com/jeffy-g/eve-esi-types/tree/v1.1.0)
9
+ [eve-esi-types v1](https://github.com/jeffy-g/eve-esi-types/tree/version-1.x)
10
10
 
11
11
 
12
12
  > Sample code is provided -> [`v2.mjs`](./v2.mjs)
@@ -0,0 +1,26 @@
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 * as util from "./rq-util.mjs";
9
+ /**
10
+ * @typedef {import("./v2").TESIResponseOKMap} TESIResponseOKMap
11
+ * @typedef {import("./rq-util.mjs").ESIRequestOptions} ESIRequestOptions
12
+ */
13
+ /** #### Sample of `TESIRequestFunctionSignature`
14
+ *
15
+ * + This is a minimal implementation using `TESIRequestFunctionSignature`.
16
+ * If the response contains "page", only the first page can be retrieved.
17
+ *
18
+ * @type {TESIRequestFunctionSignature<ESIRequestOptions>}
19
+ * @param method - The HTTP method to use for the request
20
+ * @param endpoint - The Path of the ESI endpoint to send the request to
21
+ * @param pathParams - An object of parameters to include in the request
22
+ * @param options - An object of options to include in the request
23
+ * @returns A Promise object containing the response data
24
+ * @throws {ESIRequesError}
25
+ */
26
+ export declare const request: TESIRequestFunctionSignature<util.ESIRequestOptions>;
package/minimal-rq.mjs ADDED
@@ -0,0 +1,78 @@
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
+ /// <reference types="./v2"/>
9
+ // - - - - - - - - - - - - - - - - - - - -
10
+ // imports
11
+ // - - - - - - - - - - - - - - - - - - - -
12
+ import * as util from "./rq-util.mjs";
13
+ // - - - - - - - - - - - - - - - - - - - -
14
+ // constants, types
15
+ // - - - - - - - - - - - - - - - - - - - -
16
+ // shorthands
17
+ const log = console.log;
18
+ const DEBUG = util.isDebug();
19
+ /**
20
+ * @typedef {import("./v2").TESIResponseOKMap} TESIResponseOKMap
21
+ * @typedef {import("./rq-util.mjs").ESIRequestOptions} ESIRequestOptions
22
+ */
23
+ // - - - - - - - - - - - - - - - - - - - -
24
+ // main functions
25
+ // - - - - - - - - - - - - - - - - - - - -
26
+ // node scripts/minimal-rq.mjs
27
+ /** #### Sample of `TESIRequestFunctionSignature`
28
+ *
29
+ * + This is a minimal implementation using `TESIRequestFunctionSignature`.
30
+ * If the response contains "page", only the first page can be retrieved.
31
+ *
32
+ * @type {TESIRequestFunctionSignature<ESIRequestOptions>}
33
+ * @param method - The HTTP method to use for the request
34
+ * @param endpoint - The Path of the ESI endpoint to send the request to
35
+ * @param pathParams - An object of parameters to include in the request
36
+ * @param options - An object of options to include in the request
37
+ * @returns A Promise object containing the response data
38
+ * @throws {ESIRequesError}
39
+ */
40
+ export const request = (method, endpoint, pathParams, opt) => {
41
+ if (typeof pathParams === "number") {
42
+ // @ts-ignore
43
+ pathParams = [pathParams];
44
+ }
45
+ if (Array.isArray(pathParams)) {
46
+ // @ts-ignore actualy endp is string
47
+ endpoint = util.replaceCbt(endpoint, pathParams);
48
+ }
49
+ // When only options are provided
50
+ // @ts-ignore
51
+ const actualOpt = /** @type {ESIRequestOptions} */ (opt || pathParams || {});
52
+ const { rqopt, qss } = util.initOptions(method, actualOpt);
53
+ // @ts-ignore actualy endp is string
54
+ const endpointUrl = util.curl(endpoint);
55
+ const url = `${endpointUrl}?${new URLSearchParams(qss) + ""}`;
56
+ DEBUG && log(url);
57
+ return fetch(url, rqopt).then(res => res.json()).catch(reason => {
58
+ throw new util.ESIRequesError(reason.message ? reason.message : reason);
59
+ });
60
+ };
61
+ // It should complete correctly.
62
+ /**
63
+ * @param {TESIRequestFunctionSignature<ESIRequestOptions>} fn
64
+ */
65
+ async function getEVEStatus(fn) {
66
+ const sdeVersion = await util.getSDEVersion();
67
+ log(`sdeVersion: ${sdeVersion}`.blue);
68
+ await util.fireRequestsDoesNotRequireAuth(fn);
69
+ return fn("get", "/status/");
70
+ }
71
+ // type following and run
72
+ // node minimal-rq.mjs
73
+ getEVEStatus(request).then(eveStatus => log(eveStatus));
74
+ // {
75
+ // "players": 16503,
76
+ // "server_version": "2794925",
77
+ // "start_time": "2025-01-21T11:02:34Z"
78
+ // }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eve-esi-types",
3
- "version": "2.1.2",
3
+ "version": "2.2.1",
4
4
  "description": "Extracted the main type of ESI. use for ESI request response types (version 2 only)",
5
5
  "main": "v2/index.d.ts",
6
6
  "scripts": {
@@ -12,8 +12,10 @@
12
12
  },
13
13
  "files": [
14
14
  "v2",
15
+ "*.d.mts",
15
16
  "v2.mjs",
16
- "v2.d.mts",
17
+ "rq-util.mjs",
18
+ "minimal-rq.mjs",
17
19
  "LICENSE",
18
20
  "*.md",
19
21
  "package.json",
@@ -33,5 +35,8 @@
33
35
  "bugs": {
34
36
  "url": "https://github.com/jeffy-g/eve-esi-types/issues"
35
37
  },
36
- "homepage": "https://github.com/jeffy-g/eve-esi-types#readme"
38
+ "homepage": "https://github.com/jeffy-g/eve-esi-types#readme",
39
+ "devDependencies": {
40
+ "colors": "^1.4.0"
41
+ }
37
42
  }
package/rq-util.d.mts ADDED
@@ -0,0 +1,114 @@
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 "colors";
9
+ /**
10
+ * this always `https://esi.evetech.net`
11
+ */
12
+ export declare const BASE = "https://esi.evetech.net";
13
+ export type Truthy = string | number | boolean;
14
+ /**
15
+ * __{Header}.{Payload}.{Signature}__
16
+ */
17
+ export type TAcccessToken = `${string}.${string}.${string}`;
18
+ export type ESIRequestOptions = {
19
+ /**
20
+ * query params for ESI request.
21
+ */
22
+ query?: Record<string, any>;
23
+ /**
24
+ * will need it for `POST` request etc.
25
+ */
26
+ body?: any;
27
+ /**
28
+ * if want response data with ignore error then can be set to `true`.
29
+ */
30
+ ignoreError?: boolean;
31
+ /**
32
+ * cancel request immediately
33
+ */
34
+ cancelable?: AbortController;
35
+ /**
36
+ * Can be an empty object if no authentication is required.description
37
+ */
38
+ token?: TAcccessToken;
39
+ /**
40
+ * whether an authorization header is required
41
+ *
42
+ * + When using the `Web Fetch API`, avoid extra `OPTIONS` requests and reduce extra http requests
43
+ *
44
+ * @date 2020/1/23
45
+ */
46
+ auth?: true;
47
+ };
48
+ /**
49
+ * simple named error class.
50
+ */
51
+ export declare class ESIRequesError extends Error {
52
+ }
53
+ /**
54
+ * throws when x-esi-error-limit-remain header value is "0". (http status: 420)
55
+ */
56
+ export declare class ESIErrorLimitReachedError extends ESIRequesError {
57
+ constructor();
58
+ valueOf(): number;
59
+ }
60
+ /**
61
+ * @typedef {import("./rq-util.mjs").ESIRequestOptions} ESIRequestOptions
62
+ */
63
+ export declare const isDebug: () => boolean;
64
+ /**
65
+ * @param method
66
+ * @param opt
67
+ * @returns
68
+ */
69
+ export declare const initOptions: (method: string, opt: ESIRequestOptions) => {
70
+ rqopt: RequestInit;
71
+ qss: Record<string, string>;
72
+ };
73
+ /**
74
+ * fetch the extra pages
75
+ *
76
+ * + if the `x-pages` header property ware more than 1
77
+ *
78
+ * @param {string} endpointUrl
79
+ * @param {RequestInit} rqopt request options
80
+ * @param {Record<string, any>} qs queries
81
+ * @param {number} pc pageCount
82
+ * @param {(minus?: number) => void=} increment
83
+ */
84
+ export declare const fetchP: <T extends unknown>(endpointUrl: string, rqopt: RequestInit, qs: Record<string, any>, pc: number, increment?: (minus?: Truthy) => void) => Promise<T | null>;
85
+ /** ### replace (C)urly (B)races (T)oken
86
+ *
87
+ * @example
88
+ * "/characters/{character_id}/skills"
89
+ * // ->
90
+ * "/characters/<char.character_id>/skills"
91
+ *
92
+ * @param {string} endpoint e.g - "/characters/{character_id}/"
93
+ * @param {number[]} ids
94
+ * @returns fragment of qualified endpoint uri or null.
95
+ */
96
+ export declare const replaceCbt: (endpoint: string, ids: number[]) => string;
97
+ /**
98
+ *
99
+ * @param {string} endp this means endpoint url fragment like `/characters/{character_id}/` or `/characters/{character_id}/agents_research/`
100
+ * + The version parameter can be omitted by using `<version>/<endpoint>`
101
+ */
102
+ export declare const curl: (endp: string) => string;
103
+ /**
104
+ * @date 2020/03/31
105
+ * @version 2.0 fix version date string problem (v1.0
106
+ * @type {() => Promise<string>}
107
+ */
108
+ export declare function getSDEVersion(): Promise<string>;
109
+ /**
110
+ * #### Fire a request that does not require authentication.
111
+ *
112
+ * @param {TESIRequestFunctionSignature<ESIRequestOptions>} fn
113
+ */
114
+ export declare function fireRequestsDoesNotRequireAuth(fn: TESIRequestFunctionSignature<ESIRequestOptions>): Promise<void>;
package/rq-util.mjs ADDED
@@ -0,0 +1,262 @@
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
+ // - - - - - - - - - - - - - - - - - - - -
9
+ // imports
10
+ // - - - - - - - - - - - - - - - - - - - -
11
+ import "colors";
12
+ // - - - - - - - - - - - - - - - - - - - -
13
+ // constants, types
14
+ // - - - - - - - - - - - - - - - - - - - -
15
+ // shorthands
16
+ const log = console.log;
17
+ const isArray = Array.isArray;
18
+ /**
19
+ * enable/disable console.log
20
+ */
21
+ let LOG = false;
22
+ /**
23
+ * this always `https://esi.evetech.net`
24
+ */
25
+ export const BASE = "https://esi.evetech.net";
26
+ /**
27
+ * simple named error class.
28
+ */
29
+ export class ESIRequesError extends Error {
30
+ }
31
+ /**
32
+ * throws when x-esi-error-limit-remain header value is "0". (http status: 420)
33
+ */
34
+ export class ESIErrorLimitReachedError extends ESIRequesError {
35
+ constructor() {
36
+ super("Cannot continue ESI request because 'x-esi-error-limit-remain' is zero!");
37
+ }
38
+ valueOf() {
39
+ return 420;
40
+ }
41
+ }
42
+ /**
43
+ * @typedef {import("./rq-util.mjs").ESIRequestOptions} ESIRequestOptions
44
+ */
45
+ // - - - - - - - - - - - - - - - - - - - -
46
+ // utility functions
47
+ // - - - - - - - - - - - - - - - - - - - -
48
+ export const isDebug = () => {
49
+ return process.argv.includes("-debug");
50
+ };
51
+ /**
52
+ * @param method
53
+ * @param opt
54
+ * @returns
55
+ */
56
+ export const initOptions = (method, opt) => {
57
+ /** @type {RequestInit} */
58
+ const rqopt = {
59
+ method,
60
+ mode: "cors",
61
+ cache: "no-cache",
62
+ // @ts-ignore
63
+ signal: opt.cancelable?.signal,
64
+ headers: {}
65
+ };
66
+ const qss = {
67
+ language: "en",
68
+ };
69
+ if (opt.query) {
70
+ // Object.assign(query, options.query); Object.assign is too slow
71
+ const oqs = opt.query;
72
+ Object.keys(oqs).forEach(k => qss[k] = oqs[k]);
73
+ }
74
+ if (opt.auth) {
75
+ // @ts-ignore The header is indeed an object
76
+ rqopt.headers.authorization = `Bearer ${opt.token}`;
77
+ }
78
+ if (opt.body) { // means "POST" method etc
79
+ // @ts-ignore The header is indeed an object
80
+ rqopt.headers["content-type"] = "application/json";
81
+ rqopt.body = JSON.stringify(opt.body);
82
+ }
83
+ return { rqopt, qss };
84
+ };
85
+ /**
86
+ * fetch the extra pages
87
+ *
88
+ * + if the `x-pages` header property ware more than 1
89
+ *
90
+ * @param {string} endpointUrl
91
+ * @param {RequestInit} rqopt request options
92
+ * @param {Record<string, any>} qs queries
93
+ * @param {number} pc pageCount
94
+ * @param {(minus?: number) => void=} increment
95
+ */
96
+ export const fetchP = async (endpointUrl, rqopt, qs, pc, increment = () => { }) => {
97
+ const rqs = [];
98
+ const rqp = new URLSearchParams(qs);
99
+ for (let i = 2; i <= pc;) {
100
+ rqp.set("page", (i++) + "");
101
+ increment();
102
+ rqs.push(fetch(`${endpointUrl}?${rqp + ""}`, rqopt).then(res => res.json()).catch(reason => {
103
+ console.warn(reason);
104
+ return [];
105
+ }).finally(() => {
106
+ increment(1);
107
+ }));
108
+ }
109
+ return Promise.all(rqs).then(jsons => {
110
+ // DEVNOTE: let check the page 2, type is array?
111
+ if (isArray(jsons[0])) {
112
+ let combined = [];
113
+ for (let i = 0, end = jsons.length; i < end;) {
114
+ combined = combined.concat(jsons[i++]);
115
+ }
116
+ return combined;
117
+ }
118
+ LOG && log("> > > pages result are object < < < --", jsons);
119
+ return null;
120
+ });
121
+ };
122
+ /** ### replace (C)urly (B)races (T)oken
123
+ *
124
+ * @example
125
+ * "/characters/{character_id}/skills"
126
+ * // ->
127
+ * "/characters/<char.character_id>/skills"
128
+ *
129
+ * @param {string} endpoint e.g - "/characters/{character_id}/"
130
+ * @param {number[]} ids
131
+ * @returns fragment of qualified endpoint uri or null.
132
+ */
133
+ export const replaceCbt = (endpoint, ids) => {
134
+ const re = /{([\w]+)}/g;
135
+ /** @type {RegExpExecArray?} */
136
+ let m;
137
+ let idx = 0;
138
+ while (m = re.exec(endpoint)) {
139
+ endpoint = endpoint.replace(m[0], ids[idx++] + "");
140
+ }
141
+ return endpoint;
142
+ };
143
+ /**
144
+ *
145
+ * @param {string} endp this means endpoint url fragment like `/characters/{character_id}/` or `/characters/{character_id}/agents_research/`
146
+ * + The version parameter can be omitted by using `<version>/<endpoint>`
147
+ */
148
+ export const curl = (endp) => {
149
+ endp = endp.replace(/^\/+|\/+$/g, "");
150
+ return `${BASE}/latest/${endp}/`;
151
+ };
152
+ /**
153
+ * @date 2020/03/31
154
+ * @version 2.0 fix version date string problem (v1.0
155
+ * @type {() => Promise<string>}
156
+ */
157
+ export async function getSDEVersion() {
158
+ const sdeZipUrl = "https://eve-static-data-export.s3-eu-west-1.amazonaws.com/tranquility/sde.zip";
159
+ const date = await fetch(sdeZipUrl, { method: "head", mode: "cors" }).then((/** @type {Response} */ res) => res.headers.get("last-modified")).catch(reason => {
160
+ console.log(reason);
161
+ return new Date();
162
+ });
163
+ if (date) {
164
+ const YMD = new Date(date).toLocaleString(void 0, {
165
+ year: "numeric",
166
+ month: "2-digit",
167
+ day: "2-digit",
168
+ // DEVNOTE: 191215 - "-" character appeared in node v13.3.0 (maybe
169
+ }).replace(/(-|\/|:| )/g, (match, $1) => {
170
+ switch ($1) {
171
+ case "-":
172
+ case "/":
173
+ case ":": return "";
174
+ case " ": return "@";
175
+ }
176
+ return match;
177
+ });
178
+ return `sde-${YMD}-TRANQUILITY`;
179
+ }
180
+ else {
181
+ return "sde-202Xxxxx-TRANQUILITY";
182
+ }
183
+ }
184
+ // It should complete correctly.
185
+ /**
186
+ * #### Fire a request that does not require authentication.
187
+ *
188
+ * @param {TESIRequestFunctionSignature<ESIRequestOptions>} fn
189
+ */
190
+ export async function fireRequestsDoesNotRequireAuth(fn) {
191
+ const clog = console.log.bind(console, '- - -> Get the character data of "CCP Zoetrope"'.magenta);
192
+ const rlog = console.log.bind(console, '- - -> Run ESI request'.cyan);
193
+ try {
194
+ // - - - - - - - - - - - -
195
+ // Character
196
+ // - - - - - - - - - - - -
197
+ // Here, I borrow data from "CCP Zoetrope".
198
+ clog();
199
+ await fn("get", "/characters/{character_id}/", 2112625428).then(log);
200
+ clog('(portrait)');
201
+ await fn("get", "/characters/{character_id}/portrait/", 2112625428).then(log);
202
+ clog('(affiliation)');
203
+ const affiliation = await fn("post", "/characters/affiliation/", { body: [2112625428] });
204
+ log(affiliation);
205
+ clog('(corporation)');
206
+ await fn("get", "/corporations/{corporation_id}/", affiliation[0].corporation_id).then(log);
207
+ rlog("get:/incursions/".green);
208
+ await fn("get", "/incursions/").then(log);
209
+ // - - - - - - - - - - - -
210
+ // Miscellaneous
211
+ // - - - - - - - - - - - -
212
+ rlog("post:/universe/ids/".green);
213
+ const ids = await fn("post", "/universe/ids/", { body: ["the forge", "plex"] });
214
+ log(ids);
215
+ rlog(`get:/markets/${ids?.regions?.[0].id}/orders/?type_id=${ids?.inventory_types?.[0].id}, item PLEX`.green);
216
+ const orders = await fn("get", "/markets/{region_id}/orders/", ids?.regions?.[0].id, {
217
+ query: {
218
+ // page: 1,
219
+ order_type: "sell",
220
+ type_id: ids?.inventory_types?.[0].id
221
+ }
222
+ });
223
+ log(orders.sort((a, b) => a.price - b.price).slice(0, 5));
224
+ rlog("get:/universe/structures/?filter=market".green);
225
+ // query patameter `filter` is optional
226
+ const structures = await fn("get", "/universe/structures/", {
227
+ query: {
228
+ filter: "market"
229
+ }
230
+ });
231
+ log(`/universe/structures/[0]=${structures[0]}, length=${structures.length}`);
232
+ // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
233
+ // The following is code to observe the behavior of completion by generics.
234
+ // Authentication is required, so an error will occur.
235
+ // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
236
+ let ok = await fn("get", "/characters/{character_id}/ship/", 994562, {
237
+ auth: true,
238
+ ignoreError: true,
239
+ token: "token.token.token"
240
+ });
241
+ // in this case, "categories" and "search" is required
242
+ await fn("get", "/characters/{character_id}/search/", 994562, {
243
+ query: {
244
+ categories: ["agent"],
245
+ search: "ok"
246
+ },
247
+ auth: true
248
+ });
249
+ // in this case, "order_type" is required
250
+ await fn("get", "/markets/{region_id}/orders/", 994562, {
251
+ query: {
252
+ order_type: "all"
253
+ },
254
+ });
255
+ // TODO: want TypeScript semantics to throw an error because there is a required query parameter, but it's not possible
256
+ await fn("get", "/characters/{character_id}/search/");
257
+ log(ok);
258
+ }
259
+ catch (e) {
260
+ console.error("Failed to request -", e);
261
+ }
262
+ }
package/tsconfig.json CHANGED
@@ -4,6 +4,7 @@
4
4
  "skipDefaultLibCheck": true,
5
5
  "skipLibCheck": true,
6
6
  "declaration": true,
7
+ // "declarationDir": "./dts",
7
8
  "outDir": ".",
8
9
  "target": "esnext",
9
10
  "module": "esnext",
@@ -13,11 +14,11 @@
13
14
  "strict": true,
14
15
  "moduleResolution": "node",
15
16
  "rootDirs": [
16
- "./"
17
+ "./scripts"
17
18
  ]
18
19
  },
19
20
  "include": [
20
- "./*.mts"
21
+ "./scripts/*.mts"
21
22
  ],
22
23
  "exclude": []
23
24
  }
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * ESI endpoint: /alliances/{alliance_id}/contacts/labels/
2
+ * ESI endpoint: get:/alliances/{alliance_id}/contacts/labels/
3
3
  */
4
4
  /**
5
5
  * 200 ok array
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * ESI endpoint: /alliances/{alliance_id}/contacts/
2
+ * ESI endpoint: get:/alliances/{alliance_id}/contacts/
3
3
  */
4
4
  /**
5
5
  * contact_type string
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * ESI endpoint: /alliances/{alliance_id}/corporations/
2
+ * ESI endpoint: get:/alliances/{alliance_id}/corporations/
3
3
  */
4
4
  /**
5
5
  * 200 ok array
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * ESI endpoint: /alliances/{alliance_id}/icons/
2
+ * ESI endpoint: get:/alliances/{alliance_id}/icons/
3
3
  */
4
4
 
5
5
  /**
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * ESI endpoint: /alliances/{alliance_id}/
2
+ * ESI endpoint: get:/alliances/{alliance_id}/
3
3
  */
4
4
 
5
5
  /**
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * ESI endpoint: /alliances/
2
+ * ESI endpoint: get:/alliances/
3
3
  */
4
4
  /**
5
5
  * 200 ok array
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * ESI endpoint: /characters/{character_id}/agents_research/
2
+ * ESI endpoint: get:/characters/{character_id}/agents_research/
3
3
  */
4
4
  /**
5
5
  * 200 ok array
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * ESI endpoint: /characters/{character_id}/assets/
2
+ * ESI endpoint: get:/characters/{character_id}/assets/
3
3
  */
4
4
  /**
5
5
  * location_flag string
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * ESI endpoint: /characters/{character_id}/attributes/
2
+ * ESI endpoint: get:/characters/{character_id}/attributes/
3
3
  */
4
4
 
5
5
  /**
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * ESI endpoint: /characters/{character_id}/blueprints/
2
+ * ESI endpoint: get:/characters/{character_id}/blueprints/
3
3
  */
4
4
  /**
5
5
  * Type of the location_id
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * ESI endpoint: /characters/{character_id}/bookmarks/folders/
2
+ * ESI endpoint: get:/characters/{character_id}/bookmarks/folders/
3
3
  */
4
4
  /**
5
5
  * 200 ok array
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * ESI endpoint: /characters/{character_id}/bookmarks/
2
+ * ESI endpoint: get:/characters/{character_id}/bookmarks/
3
3
  */
4
4
  /**
5
5
  * 200 ok array
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * ESI endpoint: /characters/{character_id}/calendar/{event_id}/attendees/
2
+ * ESI endpoint: get:/characters/{character_id}/calendar/{event_id}/attendees/
3
3
  */
4
4
  /**
5
5
  * event_response string
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * ESI endpoint: /characters/{character_id}/calendar/{event_id}/
2
+ * ESI endpoint: get:/characters/{character_id}/calendar/{event_id}/
3
3
  */
4
4
  /**
5
5
  * owner_type string
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * ESI endpoint: /characters/{character_id}/calendar/
2
+ * ESI endpoint: get:/characters/{character_id}/calendar/
3
3
  */
4
4
  /**
5
5
  * event_response string
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * ESI endpoint: /characters/{character_id}/clones/
2
+ * ESI endpoint: get:/characters/{character_id}/clones/
3
3
  */
4
4
  /**
5
5
  * location_type string