eve-esi-types 2.0.5-beta → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -3
- package/v2/extra-types.d.ts +1756 -0
- package/v2/index.d.ts +107 -56
- package/v2.mjs +44 -21
package/v2/index.d.ts
CHANGED
|
@@ -194,6 +194,7 @@ import "./get_universe_types_type_id_ok.d.ts";
|
|
|
194
194
|
import "./get_wars_ok.d.ts";
|
|
195
195
|
import "./get_wars_war_id_ok.d.ts";
|
|
196
196
|
import "./get_wars_war_id_killmails_ok.d.ts";
|
|
197
|
+
import "./extra-types.d.ts";
|
|
197
198
|
|
|
198
199
|
|
|
199
200
|
/**
|
|
@@ -207,6 +208,19 @@ type RequireThese<T, K extends keyof T> = T & Required<Pick<T, K>>;
|
|
|
207
208
|
|
|
208
209
|
declare global {
|
|
209
210
|
|
|
211
|
+
/**
|
|
212
|
+
* is parameterized path
|
|
213
|
+
*/
|
|
214
|
+
type IsParameterizedPath<EP, A, B> = EP extends `${string}/{${string}}/${string | ""}` ? A: B;
|
|
215
|
+
/**
|
|
216
|
+
* Identifies the required parameters for a given entry type.
|
|
217
|
+
*
|
|
218
|
+
* @template Entry - The entry type to identify parameters for.
|
|
219
|
+
* @template Opt - The type of the parameters.
|
|
220
|
+
* @type {Opt & Pick<Entry, Exclude<keyof Entry, "result">>}
|
|
221
|
+
*/
|
|
222
|
+
type IdentifyParameters<Entry, Opt> = Opt & Pick<Entry, Exclude<keyof Entry, "result">>;
|
|
223
|
+
|
|
210
224
|
/**
|
|
211
225
|
* Infer the result type of an ESI response based on the method and endpoint.
|
|
212
226
|
*
|
|
@@ -218,21 +232,6 @@ declare global {
|
|
|
218
232
|
EP extends keyof TESIResponseOKMap[M]
|
|
219
233
|
> = TESIResponseOKMap[M][EP] extends { result: infer U } ? U : never;
|
|
220
234
|
|
|
221
|
-
/**
|
|
222
|
-
* Identifies the required parameters for a given entry type.
|
|
223
|
-
*
|
|
224
|
-
* @template Entry - The entry type to identify parameters for.
|
|
225
|
-
* @template T - The type of the parameters.
|
|
226
|
-
* @template Auth - Determines if the "auth" parameter is required. Defaults to `never` if "auth" is not a key in Entry or if "auth" is undefined.
|
|
227
|
-
* @template Body - Determines if the "body" parameter is required. Defaults to `never` if "body" is not a key in Entry or if "body" is undefined.
|
|
228
|
-
* @type RequireThese<T, Extract<Auth | Body, keyof T>>
|
|
229
|
-
*/
|
|
230
|
-
type IdentifyParameters<
|
|
231
|
-
Entry, T,
|
|
232
|
-
Auth = "auth" extends keyof Entry ? (undefined extends Entry["auth"] ? never : "auth") : never,
|
|
233
|
-
Body = "body" extends keyof Entry ? (undefined extends Entry["body"] ? never : "body") : never,
|
|
234
|
-
> = RequireThese<T, Extract<Auth | Body, keyof T>>;
|
|
235
|
-
|
|
236
235
|
/**
|
|
237
236
|
* Represents a response with no content (HTTP status 204).
|
|
238
237
|
* Although no data is returned, it indicates successful completion by returning a status of 204.
|
|
@@ -342,8 +341,10 @@ export type TESIResponseOKMap = {
|
|
|
342
341
|
},
|
|
343
342
|
"/characters/{character_id}/calendar/": {
|
|
344
343
|
result: GetCharactersCharacterIdCalendarOk;
|
|
344
|
+
query: {
|
|
345
|
+
from_event?: number;
|
|
346
|
+
},
|
|
345
347
|
auth: true;
|
|
346
|
-
query: true;
|
|
347
348
|
},
|
|
348
349
|
"/characters/{character_id}/calendar/{event_id}/": {
|
|
349
350
|
result: GetCharactersCharacterIdCalendarEventIdOk;
|
|
@@ -402,8 +403,10 @@ export type TESIResponseOKMap = {
|
|
|
402
403
|
},
|
|
403
404
|
"/characters/{character_id}/industry/jobs/": {
|
|
404
405
|
result: GetCharactersCharacterIdIndustryJobsOk;
|
|
406
|
+
query: {
|
|
407
|
+
include_completed?: boolean;
|
|
408
|
+
},
|
|
405
409
|
auth: true;
|
|
406
|
-
query: true;
|
|
407
410
|
},
|
|
408
411
|
"/characters/{character_id}/killmails/recent/": {
|
|
409
412
|
result: GetCharactersCharacterIdKillmailsRecentOk;
|
|
@@ -419,8 +422,11 @@ export type TESIResponseOKMap = {
|
|
|
419
422
|
},
|
|
420
423
|
"/characters/{character_id}/mail/": {
|
|
421
424
|
result: GetCharactersCharacterIdMailOk;
|
|
425
|
+
query: {
|
|
426
|
+
labels?: GetCharactersCharacterIdMailLabels;
|
|
427
|
+
last_mail_id?: number;
|
|
428
|
+
},
|
|
422
429
|
auth: true;
|
|
423
|
-
query: true;
|
|
424
430
|
},
|
|
425
431
|
"/characters/{character_id}/mail/labels/": {
|
|
426
432
|
result: GetCharactersCharacterIdMailLabelsOk;
|
|
@@ -483,8 +489,12 @@ export type TESIResponseOKMap = {
|
|
|
483
489
|
},
|
|
484
490
|
"/characters/{character_id}/search/": {
|
|
485
491
|
result: GetCharactersCharacterIdSearchOk;
|
|
492
|
+
query: {
|
|
493
|
+
categories: GetCharactersCharacterIdSearchCategories;
|
|
494
|
+
search: GetCharactersCharacterIdSearchSearch;
|
|
495
|
+
strict?: boolean;
|
|
496
|
+
},
|
|
486
497
|
auth: true;
|
|
487
|
-
query: true;
|
|
488
498
|
},
|
|
489
499
|
"/characters/{character_id}/ship/": {
|
|
490
500
|
result: GetCharactersCharacterIdShipOk;
|
|
@@ -516,8 +526,10 @@ export type TESIResponseOKMap = {
|
|
|
516
526
|
},
|
|
517
527
|
"/characters/{character_id}/wallet/transactions/": {
|
|
518
528
|
result: GetCharactersCharacterIdWalletTransactionsOk;
|
|
529
|
+
query: {
|
|
530
|
+
from_id?: number;
|
|
531
|
+
},
|
|
519
532
|
auth: true;
|
|
520
|
-
query: true;
|
|
521
533
|
},
|
|
522
534
|
"/contracts/public/bids/{contract_id}/": {
|
|
523
535
|
result: GetContractsPublicBidsContractIdOk;
|
|
@@ -610,8 +622,10 @@ export type TESIResponseOKMap = {
|
|
|
610
622
|
},
|
|
611
623
|
"/corporations/{corporation_id}/industry/jobs/": {
|
|
612
624
|
result: GetCorporationsCorporationIdIndustryJobsOk;
|
|
625
|
+
query: {
|
|
626
|
+
include_completed?: boolean;
|
|
627
|
+
},
|
|
613
628
|
auth: true;
|
|
614
|
-
query: true;
|
|
615
629
|
},
|
|
616
630
|
"/corporations/{corporation_id}/killmails/recent/": {
|
|
617
631
|
result: GetCorporationsCorporationIdKillmailsRecentOk;
|
|
@@ -671,8 +685,10 @@ export type TESIResponseOKMap = {
|
|
|
671
685
|
},
|
|
672
686
|
"/corporations/{corporation_id}/starbases/{starbase_id}/": {
|
|
673
687
|
result: GetCorporationsCorporationIdStarbasesStarbaseIdOk;
|
|
688
|
+
query: {
|
|
689
|
+
system_id: number;
|
|
690
|
+
},
|
|
674
691
|
auth: true;
|
|
675
|
-
query: true;
|
|
676
692
|
},
|
|
677
693
|
"/corporations/{corporation_id}/structures/": {
|
|
678
694
|
result: GetCorporationsCorporationIdStructuresOk;
|
|
@@ -692,8 +708,10 @@ export type TESIResponseOKMap = {
|
|
|
692
708
|
},
|
|
693
709
|
"/corporations/{corporation_id}/wallets/{division}/transactions/": {
|
|
694
710
|
result: GetCorporationsCorporationIdWalletsDivisionTransactionsOk;
|
|
711
|
+
query: {
|
|
712
|
+
from_id?: number;
|
|
713
|
+
},
|
|
695
714
|
auth: true;
|
|
696
|
-
query: true;
|
|
697
715
|
},
|
|
698
716
|
"/dogma/attributes/": {
|
|
699
717
|
result: GetDogmaAttributesOk;
|
|
@@ -773,11 +791,16 @@ export type TESIResponseOKMap = {
|
|
|
773
791
|
},
|
|
774
792
|
"/markets/{region_id}/history/": {
|
|
775
793
|
result: GetMarketsRegionIdHistoryOk;
|
|
776
|
-
query:
|
|
794
|
+
query: {
|
|
795
|
+
type_id: number;
|
|
796
|
+
}
|
|
777
797
|
},
|
|
778
798
|
"/markets/{region_id}/orders/": {
|
|
779
799
|
result: GetMarketsRegionIdOrdersOk;
|
|
780
|
-
query:
|
|
800
|
+
query: {
|
|
801
|
+
order_type: GetMarketsRegionIdOrdersOrderType;
|
|
802
|
+
type_id?: number;
|
|
803
|
+
}
|
|
781
804
|
},
|
|
782
805
|
"/markets/{region_id}/types/": {
|
|
783
806
|
result: GetMarketsRegionIdTypesOk;
|
|
@@ -796,7 +819,11 @@ export type TESIResponseOKMap = {
|
|
|
796
819
|
},
|
|
797
820
|
"/route/{origin}/{destination}/": {
|
|
798
821
|
result: GetRouteOriginDestinationOk;
|
|
799
|
-
query:
|
|
822
|
+
query: {
|
|
823
|
+
avoid?: GetRouteOriginDestinationAvoid;
|
|
824
|
+
connections?: GetRouteOriginDestinationConnections;
|
|
825
|
+
flag?: GetRouteOriginDestinationFlag;
|
|
826
|
+
}
|
|
800
827
|
},
|
|
801
828
|
"/sovereignty/campaigns/": {
|
|
802
829
|
result: GetSovereigntyCampaignsOk;
|
|
@@ -875,7 +902,9 @@ export type TESIResponseOKMap = {
|
|
|
875
902
|
},
|
|
876
903
|
"/universe/structures/": {
|
|
877
904
|
result: GetUniverseStructuresOk;
|
|
878
|
-
query:
|
|
905
|
+
query: {
|
|
906
|
+
filter?: GetUniverseStructuresFilter;
|
|
907
|
+
}
|
|
879
908
|
},
|
|
880
909
|
"/universe/structures/{structure_id}/": {
|
|
881
910
|
result: GetUniverseStructuresStructureIdOk;
|
|
@@ -901,7 +930,9 @@ export type TESIResponseOKMap = {
|
|
|
901
930
|
},
|
|
902
931
|
"/wars/": {
|
|
903
932
|
result: GetWarsOk;
|
|
904
|
-
query:
|
|
933
|
+
query: {
|
|
934
|
+
max_war_id?: number;
|
|
935
|
+
}
|
|
905
936
|
},
|
|
906
937
|
"/wars/{war_id}/": {
|
|
907
938
|
result: GetWarsWarIdOk;
|
|
@@ -914,77 +945,91 @@ export type TESIResponseOKMap = {
|
|
|
914
945
|
"/ui/autopilot/waypoint/": {
|
|
915
946
|
result: NoContentResponse;
|
|
916
947
|
auth: true;
|
|
917
|
-
query:
|
|
948
|
+
query: {
|
|
949
|
+
add_to_beginning: boolean;
|
|
950
|
+
clear_other_waypoints: boolean;
|
|
951
|
+
destination_id: number;
|
|
952
|
+
}
|
|
918
953
|
},
|
|
919
954
|
"/ui/openwindow/contract/": {
|
|
920
955
|
result: NoContentResponse;
|
|
921
956
|
auth: true;
|
|
922
|
-
query:
|
|
957
|
+
query: {
|
|
958
|
+
contract_id: number;
|
|
959
|
+
}
|
|
923
960
|
},
|
|
924
961
|
"/ui/openwindow/information/": {
|
|
925
962
|
result: NoContentResponse;
|
|
926
963
|
auth: true;
|
|
927
|
-
query:
|
|
964
|
+
query: {
|
|
965
|
+
target_id: number;
|
|
966
|
+
}
|
|
928
967
|
},
|
|
929
968
|
"/ui/openwindow/marketdetails/": {
|
|
930
969
|
result: NoContentResponse;
|
|
931
970
|
auth: true;
|
|
932
|
-
query:
|
|
971
|
+
query: {
|
|
972
|
+
type_id: number;
|
|
973
|
+
}
|
|
933
974
|
},
|
|
934
975
|
"/characters/affiliation/": {
|
|
935
976
|
result: PostCharactersAffiliationOk;
|
|
936
|
-
body:
|
|
977
|
+
body: PostCharactersAffiliationCharacters;
|
|
937
978
|
},
|
|
938
979
|
"/characters/{character_id}/assets/locations/": {
|
|
939
980
|
result: PostCharactersCharacterIdAssetsLocationsOk;
|
|
981
|
+
body: PostCharactersCharacterIdAssetsLocationsItemIds;
|
|
940
982
|
auth: true;
|
|
941
|
-
body: true;
|
|
942
983
|
},
|
|
943
984
|
"/characters/{character_id}/assets/names/": {
|
|
944
985
|
result: PostCharactersCharacterIdAssetsNamesOk;
|
|
986
|
+
body: PostCharactersCharacterIdAssetsNamesItemIds;
|
|
945
987
|
auth: true;
|
|
946
|
-
body: true;
|
|
947
988
|
},
|
|
948
989
|
"/characters/{character_id}/contacts/": {
|
|
949
990
|
result: PostCharactersCharacterIdContactsCreated;
|
|
991
|
+
body: PostCharactersCharacterIdContactsContactIds;
|
|
992
|
+
query: {
|
|
993
|
+
label_ids?: PostCharactersCharacterIdContactsLabelIds;
|
|
994
|
+
standing: number;
|
|
995
|
+
watched?: boolean;
|
|
996
|
+
},
|
|
950
997
|
auth: true;
|
|
951
|
-
body: true;
|
|
952
|
-
query: true;
|
|
953
998
|
},
|
|
954
999
|
"/characters/{character_id}/cspa/": {
|
|
955
1000
|
result: PostCharactersCharacterIdCspaCreated;
|
|
1001
|
+
body: PostCharactersCharacterIdCspaCharacters;
|
|
956
1002
|
auth: true;
|
|
957
|
-
body: true;
|
|
958
1003
|
},
|
|
959
1004
|
"/characters/{character_id}/fittings/": {
|
|
960
1005
|
result: PostCharactersCharacterIdFittingsCreated;
|
|
1006
|
+
body: PostCharactersCharacterIdFittingsFitting;
|
|
961
1007
|
auth: true;
|
|
962
|
-
body: true;
|
|
963
1008
|
},
|
|
964
1009
|
"/characters/{character_id}/mail/": {
|
|
965
1010
|
result: PostCharactersCharacterIdMailCreated;
|
|
1011
|
+
body: PostCharactersCharacterIdMailMail;
|
|
966
1012
|
auth: true;
|
|
967
|
-
body: true;
|
|
968
1013
|
},
|
|
969
1014
|
"/characters/{character_id}/mail/labels/": {
|
|
970
1015
|
result: PostCharactersCharacterIdMailLabelsCreated;
|
|
1016
|
+
body: PostCharactersCharacterIdMailLabelsLabel;
|
|
971
1017
|
auth: true;
|
|
972
|
-
body: true;
|
|
973
1018
|
},
|
|
974
1019
|
"/corporations/{corporation_id}/assets/locations/": {
|
|
975
1020
|
result: PostCorporationsCorporationIdAssetsLocationsOk;
|
|
1021
|
+
body: PostCorporationsCorporationIdAssetsLocationsItemIds;
|
|
976
1022
|
auth: true;
|
|
977
|
-
body: true;
|
|
978
1023
|
},
|
|
979
1024
|
"/corporations/{corporation_id}/assets/names/": {
|
|
980
1025
|
result: PostCorporationsCorporationIdAssetsNamesOk;
|
|
1026
|
+
body: PostCorporationsCorporationIdAssetsNamesItemIds;
|
|
981
1027
|
auth: true;
|
|
982
|
-
body: true;
|
|
983
1028
|
},
|
|
984
1029
|
"/fleets/{fleet_id}/members/": {
|
|
985
1030
|
result: PostFleetsFleetIdMembersInvitation;
|
|
1031
|
+
body: PostFleetsFleetIdMembersInvitation;
|
|
986
1032
|
auth: true;
|
|
987
|
-
body: true;
|
|
988
1033
|
},
|
|
989
1034
|
"/fleets/{fleet_id}/wings/": {
|
|
990
1035
|
result: PostFleetsFleetIdWingsCreated;
|
|
@@ -996,61 +1041,67 @@ export type TESIResponseOKMap = {
|
|
|
996
1041
|
},
|
|
997
1042
|
"/ui/openwindow/newmail/": {
|
|
998
1043
|
result: PostUiOpenwindowNewmailNewMail;
|
|
1044
|
+
body: PostUiOpenwindowNewmailNewMail;
|
|
999
1045
|
auth: true;
|
|
1000
|
-
body: true;
|
|
1001
1046
|
},
|
|
1002
1047
|
"/universe/ids/": {
|
|
1003
1048
|
result: PostUniverseIdsOk;
|
|
1004
|
-
body:
|
|
1049
|
+
body: PostUniverseIdsNames;
|
|
1005
1050
|
},
|
|
1006
1051
|
"/universe/names/": {
|
|
1007
1052
|
result: PostUniverseNamesOk;
|
|
1008
|
-
body:
|
|
1053
|
+
body: PostUniverseNamesIds;
|
|
1009
1054
|
}
|
|
1010
1055
|
},
|
|
1011
1056
|
put: {
|
|
1012
1057
|
"/characters/{character_id}/calendar/{event_id}/": {
|
|
1013
1058
|
result: PutCharactersCharacterIdCalendarEventIdResponse;
|
|
1059
|
+
body: PutCharactersCharacterIdCalendarEventIdResponse;
|
|
1014
1060
|
auth: true;
|
|
1015
|
-
body: true;
|
|
1016
1061
|
},
|
|
1017
1062
|
"/characters/{character_id}/contacts/": {
|
|
1018
1063
|
result: PutCharactersCharacterIdContactsContactIds;
|
|
1064
|
+
body: PutCharactersCharacterIdContactsContactIds;
|
|
1065
|
+
query: {
|
|
1066
|
+
label_ids?: PutCharactersCharacterIdContactsLabelIds;
|
|
1067
|
+
standing: number;
|
|
1068
|
+
watched?: boolean;
|
|
1069
|
+
},
|
|
1019
1070
|
auth: true;
|
|
1020
|
-
body: true;
|
|
1021
|
-
query: true;
|
|
1022
1071
|
},
|
|
1023
1072
|
"/characters/{character_id}/mail/{mail_id}/": {
|
|
1024
1073
|
result: PutCharactersCharacterIdMailMailIdContents;
|
|
1074
|
+
body: PutCharactersCharacterIdMailMailIdContents;
|
|
1025
1075
|
auth: true;
|
|
1026
|
-
body: true;
|
|
1027
1076
|
},
|
|
1028
1077
|
"/fleets/{fleet_id}/": {
|
|
1029
1078
|
result: PutFleetsFleetIdNewSettings;
|
|
1079
|
+
body: PutFleetsFleetIdNewSettings;
|
|
1030
1080
|
auth: true;
|
|
1031
|
-
body: true;
|
|
1032
1081
|
},
|
|
1033
1082
|
"/fleets/{fleet_id}/members/{member_id}/": {
|
|
1034
1083
|
result: PutFleetsFleetIdMembersMemberIdMovement;
|
|
1084
|
+
body: PutFleetsFleetIdMembersMemberIdMovement;
|
|
1035
1085
|
auth: true;
|
|
1036
|
-
body: true;
|
|
1037
1086
|
},
|
|
1038
1087
|
"/fleets/{fleet_id}/squads/{squad_id}/": {
|
|
1039
1088
|
result: PutFleetsFleetIdSquadsSquadIdNaming;
|
|
1089
|
+
body: PutFleetsFleetIdSquadsSquadIdNaming;
|
|
1040
1090
|
auth: true;
|
|
1041
|
-
body: true;
|
|
1042
1091
|
},
|
|
1043
1092
|
"/fleets/{fleet_id}/wings/{wing_id}/": {
|
|
1044
1093
|
result: PutFleetsFleetIdWingsWingIdNaming;
|
|
1094
|
+
body: PutFleetsFleetIdWingsWingIdNaming;
|
|
1045
1095
|
auth: true;
|
|
1046
|
-
body: true;
|
|
1047
1096
|
}
|
|
1048
1097
|
},
|
|
1049
1098
|
delete: {
|
|
1050
1099
|
"/characters/{character_id}/contacts/": {
|
|
1051
1100
|
result: NoContentResponse;
|
|
1052
1101
|
auth: true;
|
|
1053
|
-
query:
|
|
1102
|
+
query: {
|
|
1103
|
+
contact_ids: DeleteCharactersCharacterIdContactsContactIds;
|
|
1104
|
+
}
|
|
1054
1105
|
},
|
|
1055
1106
|
"/characters/{character_id}/fittings/{fitting_id}/": {
|
|
1056
1107
|
result: NoContentResponse;
|
package/v2.mjs
CHANGED
|
@@ -18,12 +18,12 @@ const BASE = "https://esi.evetech.net";
|
|
|
18
18
|
*/
|
|
19
19
|
/**
|
|
20
20
|
* @typedef ESIRequestOptions
|
|
21
|
-
* @prop {Record<string, any>} [
|
|
21
|
+
* @prop {Record<string, any>} [query] query params for ESI request.
|
|
22
22
|
* @prop {any} [body] will need it for `POST` request etc.
|
|
23
|
+
* @prop {true=} [auth] Can be an empty object if no authentication is required.description
|
|
24
|
+
* @prop {string} [token] Can be an empty object if no authentication is required.description
|
|
23
25
|
* @prop {boolean} [ignoreError] if want response data with ignore error then can be set to `true`.
|
|
24
26
|
* @prop {AbortController} [cancelable] cancel request immediately
|
|
25
|
-
* @prop {string} [token] Can be an empty object if no authentication is required.description
|
|
26
|
-
* @prop {true=} [auth] Can be an empty object if no authentication is required.description
|
|
27
27
|
*/
|
|
28
28
|
// - - - - - - - - - - - - - - - - - - - -
|
|
29
29
|
// module vars, functions
|
|
@@ -120,7 +120,27 @@ const curl = (endp) => {
|
|
|
120
120
|
// It should complete correctly.
|
|
121
121
|
async function getEVEStatus() {
|
|
122
122
|
try {
|
|
123
|
-
const ok = await fire("get", "/characters/{character_id}/ship/", 994562, { auth: true
|
|
123
|
+
const ok = await fire("get", "/characters/{character_id}/ship/", 994562, { auth: true });
|
|
124
|
+
// query patameter `filter` is optional
|
|
125
|
+
await fire("get", "/universe/structures/", {
|
|
126
|
+
query: {
|
|
127
|
+
// filter: "market"
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
// in this case, "categories" and "search" is required
|
|
131
|
+
await fire("get", "/characters/{character_id}/search/", 994562, {
|
|
132
|
+
query: {
|
|
133
|
+
categories: ["agent"],
|
|
134
|
+
search: "ok"
|
|
135
|
+
},
|
|
136
|
+
auth: true
|
|
137
|
+
});
|
|
138
|
+
// in this case, "order_type" is required
|
|
139
|
+
await fire("get", "/markets/{region_id}/orders/", 994562, {
|
|
140
|
+
query: {
|
|
141
|
+
order_type: "all"
|
|
142
|
+
},
|
|
143
|
+
});
|
|
124
144
|
console.log(ok);
|
|
125
145
|
}
|
|
126
146
|
catch (error) {
|
|
@@ -132,43 +152,46 @@ async function getEVEStatus() {
|
|
|
132
152
|
* fire ESI request
|
|
133
153
|
* @template {TESIEntryMethod} M
|
|
134
154
|
* @template {keyof TESIResponseOKMap[M]} EP
|
|
155
|
+
* @template {IsParameterizedPath<EP, number | number[], Opt>} P2
|
|
135
156
|
* @template {IdentifyParameters<TESIResponseOKMap[M][EP], ESIRequestOptions>} Opt
|
|
136
157
|
* @template {InferESIResponseResult<M, EP>} R
|
|
137
158
|
*
|
|
138
159
|
* @param {M} mthd
|
|
139
160
|
* @param {EP} endp - The endpoint to request.
|
|
140
|
-
* @param {
|
|
161
|
+
* @param {P2} [pathParams] - Optional path parameters.
|
|
141
162
|
* @param {Opt} [opt] - default is empty object {}. `body` is json string
|
|
142
163
|
* @returns {Promise<R>} - The response from the endpoint.
|
|
143
164
|
* @throws
|
|
144
165
|
* @async
|
|
145
166
|
*/
|
|
146
|
-
export async function fire(mthd, endp, pathParams, opt
|
|
167
|
+
export async function fire(mthd, endp, pathParams, opt) {
|
|
147
168
|
if (typeof pathParams === "number") {
|
|
148
|
-
|
|
169
|
+
// @ts-ignore
|
|
170
|
+
pathParams = [pathParams];
|
|
149
171
|
}
|
|
150
172
|
if (isArray(pathParams)) {
|
|
151
173
|
// @ts-ignore actualy endp is string
|
|
152
174
|
endp = replaceCbt(endp, pathParams);
|
|
153
175
|
}
|
|
154
176
|
// When only options are provided
|
|
155
|
-
|
|
156
|
-
|
|
177
|
+
/** @type {Opt} */
|
|
178
|
+
// @ts-ignore
|
|
179
|
+
const actualOpt = pathParams || opt || {};
|
|
157
180
|
/** @type {RequestInit} */
|
|
158
181
|
const rqopt = {
|
|
159
182
|
method: mthd,
|
|
160
183
|
mode: "cors",
|
|
161
184
|
cache: "no-cache",
|
|
162
185
|
// @ts-ignore
|
|
163
|
-
signal:
|
|
186
|
+
signal: actualOpt.cancelable?.signal,
|
|
164
187
|
headers: {}
|
|
165
188
|
};
|
|
166
189
|
const qss = {
|
|
167
190
|
language: "en",
|
|
168
191
|
};
|
|
169
|
-
if (
|
|
192
|
+
if (actualOpt.query) {
|
|
170
193
|
// Object.assign(queries, options.queries); Object.assign is too slow
|
|
171
|
-
const oqs =
|
|
194
|
+
const oqs = actualOpt.query;
|
|
172
195
|
for (const k of Object.keys(oqs)) {
|
|
173
196
|
qss[k] = oqs[k];
|
|
174
197
|
}
|
|
@@ -176,17 +199,17 @@ export async function fire(mthd, endp, pathParams, opt = {}) {
|
|
|
176
199
|
// DEVNOTE: when datasource is not empty string. (e.g - "singularity"
|
|
177
200
|
// in this case must specify datasource.
|
|
178
201
|
// disabled since `REMOVING DATASOURCE SINGULARITY`
|
|
179
|
-
// if (
|
|
180
|
-
//
|
|
202
|
+
// if (actualOpt.datasource === "singularity") {
|
|
203
|
+
// actualOpt.datasource = "tranquility";
|
|
181
204
|
// }
|
|
182
|
-
if (
|
|
205
|
+
if (actualOpt.auth) {
|
|
183
206
|
// @ts-ignore The header is indeed an object
|
|
184
|
-
rqopt.headers.authorization = `Bearer ${
|
|
207
|
+
rqopt.headers.authorization = `Bearer ${actualOpt.token}`;
|
|
185
208
|
}
|
|
186
|
-
if (
|
|
209
|
+
if (actualOpt.body) { // means "POST" method etc
|
|
187
210
|
// @ts-ignore The header is indeed an object
|
|
188
211
|
rqopt.headers["content-type"] = "application/json";
|
|
189
|
-
rqopt.body = JSON.stringify(
|
|
212
|
+
rqopt.body = JSON.stringify(actualOpt.body);
|
|
190
213
|
}
|
|
191
214
|
// @ts-ignore actualy endp is string
|
|
192
215
|
const endpointUrl = curl(endp);
|
|
@@ -197,9 +220,9 @@ export async function fire(mthd, endp, pathParams, opt = {}) {
|
|
|
197
220
|
ax--;
|
|
198
221
|
});
|
|
199
222
|
const stat = res.status;
|
|
200
|
-
if (!res.ok && !
|
|
223
|
+
if (!res.ok && !actualOpt.ignoreError) {
|
|
201
224
|
if (stat === 420) {
|
|
202
|
-
|
|
225
|
+
actualOpt.cancelable && actualOpt.cancelable.abort();
|
|
203
226
|
throw new ESIErrorLimitReachedError();
|
|
204
227
|
}
|
|
205
228
|
else {
|
|
@@ -215,7 +238,7 @@ export async function fire(mthd, endp, pathParams, opt = {}) {
|
|
|
215
238
|
}
|
|
216
239
|
/** @type {R} */
|
|
217
240
|
const data = await res.json();
|
|
218
|
-
if (
|
|
241
|
+
if (actualOpt.ignoreError) {
|
|
219
242
|
// meaning `forceJson`?
|
|
220
243
|
return data;
|
|
221
244
|
}
|