eve-esi-types 2.0.0-beta → 2.0.1-beta
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/esi-request.mjs +1 -1
- package/esi-request.mts +2 -1
- package/package.json +5 -2
- package/v2/index.d.ts +64 -26
- package/v2.mjs +4 -2
- package/v2.mts +7 -4
package/esi-request.mjs
CHANGED
|
@@ -236,9 +236,9 @@ export async function fire(mthd, endp, pathParams, opt = {}) {
|
|
|
236
236
|
async function getEVEStatus() {
|
|
237
237
|
return fire("get", "/status/");
|
|
238
238
|
}
|
|
239
|
-
|
|
240
239
|
// type following and run
|
|
241
240
|
// node esi-request.mjs
|
|
241
|
+
// or yarn test
|
|
242
242
|
getEVEStatus().then(eveStatus => console.log(eveStatus));
|
|
243
243
|
// {
|
|
244
244
|
// "players": 16503,
|
package/esi-request.mts
CHANGED
|
@@ -299,8 +299,9 @@ async function getEVEStatus() {
|
|
|
299
299
|
return fire("get", "/status/");
|
|
300
300
|
}
|
|
301
301
|
|
|
302
|
-
|
|
302
|
+
// type following and run
|
|
303
303
|
// node esi-request.mjs
|
|
304
|
+
// or yarn test
|
|
304
305
|
getEVEStatus().then(eveStatus => console.log(eveStatus));
|
|
305
306
|
// {
|
|
306
307
|
// "players": 16503,
|
package/package.json
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eve-esi-types",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.1-beta",
|
|
4
4
|
"description": "Extracted the main type of ESI. use for ESI request response types",
|
|
5
5
|
"main": "src/index.d.ts",
|
|
6
6
|
"scripts": {
|
|
7
|
-
"
|
|
7
|
+
"v": "jstool -cmd version",
|
|
8
|
+
"v:tag": "bash -c \"ret=$(npm run v); after=$(echo $ret | sed -E 's/.*version updated: ([0-9]+\\.[0-9]+\\.[0-9]+(-\\w+)?).*/\\1/'); echo version=[$after]; git add -u; git commit -m v$after; git tag v$after\"",
|
|
9
|
+
"test": "node esi-request.mjs",
|
|
10
|
+
"test:v2": "node v2.mjs"
|
|
8
11
|
},
|
|
9
12
|
"repository": {
|
|
10
13
|
"type": "git",
|
package/v2/index.d.ts
CHANGED
|
@@ -196,37 +196,52 @@ import "./get_wars_war_id_ok.d.ts";
|
|
|
196
196
|
import "./get_wars_war_id_killmails_ok.d.ts";
|
|
197
197
|
|
|
198
198
|
|
|
199
|
-
// The opposite of Pick. Return type without specified property
|
|
200
|
-
type Flip<T, K extends keyof T> = {
|
|
201
|
-
[P in Exclude<keyof T, K>]: T[P];
|
|
202
|
-
};
|
|
203
199
|
/**
|
|
204
200
|
* mark a specific property as `required`
|
|
205
201
|
*/
|
|
206
202
|
type RequireThese<T, K extends keyof T> = T & Required<Pick<T, K>>;
|
|
207
203
|
|
|
208
|
-
type EndPointEntryMap = TESIResponseOKMap[TESIEntryMethod];
|
|
209
|
-
type AllEndPoints = keyof TESIResponseOKMap[TESIEntryMethod];
|
|
210
|
-
type BasicEntries = EndPointEntryMap[AllEndPoints]
|
|
204
|
+
// type EndPointEntryMap = TESIResponseOKMap[TESIEntryMethod];
|
|
205
|
+
// type AllEndPoints = keyof TESIResponseOKMap[TESIEntryMethod];
|
|
206
|
+
// type BasicEntries = EndPointEntryMap[AllEndPoints];
|
|
211
207
|
|
|
212
208
|
declare global {
|
|
213
209
|
|
|
214
210
|
/**
|
|
215
|
-
*
|
|
211
|
+
* Infer the result type of an ESI response based on the method and endpoint.
|
|
212
|
+
*
|
|
213
|
+
* @template M - The HTTP method (e.g., "get", "post").
|
|
214
|
+
* @template EP - The endpoint path.
|
|
215
|
+
*/
|
|
216
|
+
type InferESIResponseResult<
|
|
217
|
+
M extends keyof TESIResponseOKMap,
|
|
218
|
+
EP extends keyof TESIResponseOKMap[M]
|
|
219
|
+
> = TESIResponseOKMap[M][EP] extends { result: infer U } ? U : never;
|
|
220
|
+
|
|
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>>
|
|
216
229
|
*/
|
|
217
230
|
type IdentifyParameters<
|
|
218
|
-
Entry
|
|
231
|
+
Entry, T,
|
|
219
232
|
Auth = "auth" extends keyof Entry ? (undefined extends Entry["auth"] ? never : "auth") : never,
|
|
220
233
|
Body = "body" extends keyof Entry ? (undefined extends Entry["body"] ? never : "body") : never,
|
|
221
|
-
|
|
222
|
-
// Q = "query" extends keyof Entry ? (undefined extends Entry["query"] ? never : "queries") : never,
|
|
223
|
-
> = RequireThese<T, Extract<Auth | Body/*| Q*/, keyof T>>;
|
|
234
|
+
> = RequireThese<T, Extract<Auth | Body, keyof T>>;
|
|
224
235
|
|
|
225
236
|
/**
|
|
226
|
-
* response
|
|
237
|
+
* Represents a response with no content (HTTP status 204).
|
|
238
|
+
* Although no data is returned, it indicates successful completion by returning a status of 204.
|
|
227
239
|
*/
|
|
228
240
|
type NoContentResponse = { status: 204 };
|
|
241
|
+
|
|
229
242
|
/**
|
|
243
|
+
* Represents the HTTP methods supported by ESI.
|
|
244
|
+
*
|
|
230
245
|
* ```ts
|
|
231
246
|
* "get" | "post" | "put" | "delete"
|
|
232
247
|
* ```
|
|
@@ -234,39 +249,46 @@ declare global {
|
|
|
234
249
|
type TESIEntryMethod = keyof TESIResponseOKMap;
|
|
235
250
|
|
|
236
251
|
/**
|
|
237
|
-
*
|
|
252
|
+
* Represents the endpoints for the "get" method.
|
|
238
253
|
*/
|
|
239
254
|
type TEndPointGet = keyof TESIResponseOKMap["get"];
|
|
240
255
|
/**
|
|
241
|
-
*
|
|
256
|
+
* Represents the endpoints for the "post" method.
|
|
242
257
|
*/
|
|
243
258
|
type TEndPointPost = keyof TESIResponseOKMap["post"];
|
|
244
259
|
/**
|
|
245
|
-
*
|
|
260
|
+
* Represents the endpoints for the "put" method.
|
|
246
261
|
*/
|
|
247
262
|
type TEndPointPut = keyof TESIResponseOKMap["put"];
|
|
248
263
|
/**
|
|
249
|
-
*
|
|
264
|
+
* Represents the endpoints for the "delete" method.
|
|
250
265
|
*/
|
|
251
266
|
type TEndPointDelete = keyof TESIResponseOKMap["delete"];
|
|
252
|
-
|
|
267
|
+
|
|
253
268
|
/**
|
|
254
|
-
* entry details
|
|
269
|
+
* Represents the entry details for the "get" method.
|
|
270
|
+
*
|
|
271
|
+
* @template K - The endpoint key.
|
|
255
272
|
*/
|
|
256
|
-
type TESIResponseGetEntry<K extends TEndPointGet>
|
|
273
|
+
type TESIResponseGetEntry<K extends TEndPointGet> = TESIResponseOKMap["get"][K];
|
|
257
274
|
/**
|
|
258
|
-
* entry details
|
|
275
|
+
* Represents the entry details for the "put" method.
|
|
276
|
+
*
|
|
277
|
+
* @template K - The endpoint key.
|
|
259
278
|
*/
|
|
260
|
-
type TESIResponsePutEntry<K extends TEndPointPut>
|
|
279
|
+
type TESIResponsePutEntry<K extends TEndPointPut> = TESIResponseOKMap["put"][K];
|
|
261
280
|
/**
|
|
262
|
-
* entry details
|
|
281
|
+
* Represents the entry details for the "post" method.
|
|
282
|
+
*
|
|
283
|
+
* @template K - The endpoint key.
|
|
263
284
|
*/
|
|
264
|
-
type TESIResponsePostEntry<K extends TEndPointPost>
|
|
285
|
+
type TESIResponsePostEntry<K extends TEndPointPost> = TESIResponseOKMap["post"][K];
|
|
265
286
|
/**
|
|
266
|
-
* entry details
|
|
287
|
+
* Represents the entry details for the "delete" method.
|
|
288
|
+
*
|
|
289
|
+
* @template K - The endpoint key.
|
|
267
290
|
*/
|
|
268
291
|
type TESIResponseDeleteEntry<K extends TEndPointDelete> = TESIResponseOKMap["delete"][K];
|
|
269
|
-
// type TESIResponseResult = TESIResponseOKMap[TESIEntryMethod][TEndPoint]["result"];
|
|
270
292
|
}
|
|
271
293
|
|
|
272
294
|
export type TESIResponseOKMap = {
|
|
@@ -891,15 +913,23 @@ export type TESIResponseOKMap = {
|
|
|
891
913
|
post: {
|
|
892
914
|
"/ui/autopilot/waypoint/": {
|
|
893
915
|
result: NoContentResponse;
|
|
916
|
+
auth: true;
|
|
917
|
+
query: true;
|
|
894
918
|
},
|
|
895
919
|
"/ui/openwindow/contract/": {
|
|
896
920
|
result: NoContentResponse;
|
|
921
|
+
auth: true;
|
|
922
|
+
query: true;
|
|
897
923
|
},
|
|
898
924
|
"/ui/openwindow/information/": {
|
|
899
925
|
result: NoContentResponse;
|
|
926
|
+
auth: true;
|
|
927
|
+
query: true;
|
|
900
928
|
},
|
|
901
929
|
"/ui/openwindow/marketdetails/": {
|
|
902
930
|
result: NoContentResponse;
|
|
931
|
+
auth: true;
|
|
932
|
+
query: true;
|
|
903
933
|
},
|
|
904
934
|
"/characters/affiliation/": {
|
|
905
935
|
result: PostCharactersAffiliationOk;
|
|
@@ -1019,24 +1049,32 @@ export type TESIResponseOKMap = {
|
|
|
1019
1049
|
delete: {
|
|
1020
1050
|
"/characters/{character_id}/contacts/": {
|
|
1021
1051
|
result: NoContentResponse;
|
|
1052
|
+
auth: true;
|
|
1053
|
+
query: true;
|
|
1022
1054
|
},
|
|
1023
1055
|
"/characters/{character_id}/fittings/{fitting_id}/": {
|
|
1024
1056
|
result: NoContentResponse;
|
|
1057
|
+
auth: true;
|
|
1025
1058
|
},
|
|
1026
1059
|
"/characters/{character_id}/mail/labels/{label_id}/": {
|
|
1027
1060
|
result: NoContentResponse;
|
|
1061
|
+
auth: true;
|
|
1028
1062
|
},
|
|
1029
1063
|
"/characters/{character_id}/mail/{mail_id}/": {
|
|
1030
1064
|
result: NoContentResponse;
|
|
1065
|
+
auth: true;
|
|
1031
1066
|
},
|
|
1032
1067
|
"/fleets/{fleet_id}/members/{member_id}/": {
|
|
1033
1068
|
result: NoContentResponse;
|
|
1069
|
+
auth: true;
|
|
1034
1070
|
},
|
|
1035
1071
|
"/fleets/{fleet_id}/squads/{squad_id}/": {
|
|
1036
1072
|
result: NoContentResponse;
|
|
1073
|
+
auth: true;
|
|
1037
1074
|
},
|
|
1038
1075
|
"/fleets/{fleet_id}/wings/{wing_id}/": {
|
|
1039
1076
|
result: NoContentResponse;
|
|
1077
|
+
auth: true;
|
|
1040
1078
|
}
|
|
1041
1079
|
}
|
|
1042
1080
|
};
|
package/v2.mjs
CHANGED
|
@@ -131,8 +131,8 @@ async function getEVEStatus() {
|
|
|
131
131
|
* fire ESI request
|
|
132
132
|
* @template {TESIEntryMethod} M
|
|
133
133
|
* @template {keyof TESIResponseOKMap[M]} EP
|
|
134
|
-
* @template {IdentifyParameters<TESIResponseOKMap[M][EP]
|
|
135
|
-
* @template {
|
|
134
|
+
* @template {IdentifyParameters<TESIResponseOKMap[M][EP], ESIRequestOptions>} Opt
|
|
135
|
+
* @template {InferESIResponseResult<M, EP>} R
|
|
136
136
|
*
|
|
137
137
|
* @param {M} mthd
|
|
138
138
|
* @param {EP} endp - The endpoint to request.
|
|
@@ -244,7 +244,9 @@ export async function fire(mthd, endp, pathParams, opt) {
|
|
|
244
244
|
throw new ESIRequesError(`message: ${e.message}, endpoint=${endp}`);
|
|
245
245
|
}
|
|
246
246
|
}
|
|
247
|
+
// type following and run
|
|
247
248
|
// node v2.mjs
|
|
249
|
+
// or yarn test:v2
|
|
248
250
|
getEVEStatus().then(eveStatus => console.log(eveStatus));
|
|
249
251
|
// {
|
|
250
252
|
// "players": 16503,
|
package/v2.mts
CHANGED
|
@@ -179,8 +179,8 @@ async function getEVEStatus() {
|
|
|
179
179
|
* fire ESI request
|
|
180
180
|
* @template {TESIEntryMethod} M
|
|
181
181
|
* @template {keyof TESIResponseOKMap[M]} EP
|
|
182
|
-
* @template {IdentifyParameters<TESIResponseOKMap[M][EP]
|
|
183
|
-
* @template {
|
|
182
|
+
* @template {IdentifyParameters<TESIResponseOKMap[M][EP], ESIRequestOptions>} Opt
|
|
183
|
+
* @template {InferESIResponseResult<M, EP>} R
|
|
184
184
|
*
|
|
185
185
|
* @param {M} mthd
|
|
186
186
|
* @param {EP} endp - The endpoint to request.
|
|
@@ -193,8 +193,9 @@ async function getEVEStatus() {
|
|
|
193
193
|
export async function fire<
|
|
194
194
|
M extends TESIEntryMethod,
|
|
195
195
|
EP extends keyof TESIResponseOKMap[M],
|
|
196
|
-
|
|
197
|
-
|
|
196
|
+
// Entry extends TESIResponseOKMap[M][EP],
|
|
197
|
+
Opt extends IdentifyParameters<TESIResponseOKMap[M][EP], ESIRequestOptions>,
|
|
198
|
+
R extends InferESIResponseResult<M, EP>
|
|
198
199
|
>(
|
|
199
200
|
mthd: M, endp: EP, pathParams?: number | number[] | Opt,
|
|
200
201
|
opt?: Opt
|
|
@@ -307,7 +308,9 @@ export async function fire<
|
|
|
307
308
|
}
|
|
308
309
|
}
|
|
309
310
|
|
|
311
|
+
// type following and run
|
|
310
312
|
// node v2.mjs
|
|
313
|
+
// or yarn test:v2
|
|
311
314
|
getEVEStatus().then(eveStatus => console.log(eveStatus));
|
|
312
315
|
// {
|
|
313
316
|
// "players": 16503,
|