eve-esi-types 2.2.1 → 2.2.4
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-types-util.md +30 -15
- package/minimal-rq.d.mts +5 -2
- package/minimal-rq.mjs +69 -13
- package/package.json +5 -6
- package/rq-util.d.mts +14 -9
- package/rq-util.mjs +72 -48
- package/tsconfig.json +3 -1
- package/v2/get_corporations_corporation_id_starbases_starbase_id_ok.d.ts +1 -247
- package/v2/get_corporations_corporation_id_titles_ok.d.ts +1 -165
- package/v2/get_fw_leaderboards_characters_ok.d.ts +4 -44
- package/v2/get_fw_leaderboards_corporations_ok.d.ts +10 -477
- package/v2/get_fw_leaderboards_ok.d.ts +4 -44
- package/v2/index.d.ts +80 -4
- package/v2.d.mts +2 -8
- package/v2.mjs +10 -11
package/v2/index.d.ts
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* THIS TSD IS AUTO GENERATED, DO NOT EDIT
|
|
10
10
|
*
|
|
11
11
|
* @file eve-esi-types/v2/index.d.ts
|
|
12
|
-
* @summary This file is auto-generated and defines version 2.2.
|
|
12
|
+
* @summary This file is auto-generated and defines version 2.2.4 of the EVE Online ESI response types.
|
|
13
13
|
*/
|
|
14
14
|
import "./get_alliances_ok.d.ts";
|
|
15
15
|
import "./get_alliances_alliance_id_ok.d.ts";
|
|
@@ -203,6 +203,57 @@ import "./extra-types.d.ts";
|
|
|
203
203
|
*/
|
|
204
204
|
type RequireThese<T, K extends keyof T> = T & Required<Pick<T, K>>;
|
|
205
205
|
|
|
206
|
+
/**
|
|
207
|
+
* Represents a function that can make ESI requests with various HTTP methods.
|
|
208
|
+
*
|
|
209
|
+
* @template ActualOpt - The actual type of the options.
|
|
210
|
+
*
|
|
211
|
+
* @example
|
|
212
|
+
* ```ts
|
|
213
|
+
* // @ ts-expect-error
|
|
214
|
+
* export const request: IESIRequestFunction<ESIRequestOptions> = (method, endpoint, pathParams, opt) => {
|
|
215
|
+
* // Implementation for "get" | "post" | "put" | "delete" request
|
|
216
|
+
* };
|
|
217
|
+
* // You can easily implement "get" | "post" | "put" | "delete" requests
|
|
218
|
+
* // with code like the following:
|
|
219
|
+
* (["get", "post", "put", "delete"] as (keyof typeof request)[]).forEach((method) => {
|
|
220
|
+
* request[method] = function (this: typeof request, endpoint, params, opt) {
|
|
221
|
+
* return this(method, endpoint, params, opt);
|
|
222
|
+
* } as TESIRequestFunctionEachMethod<typeof method>;
|
|
223
|
+
* });
|
|
224
|
+
* ```
|
|
225
|
+
*/
|
|
226
|
+
export interface IESIRequestFunction<ActualOpt>
|
|
227
|
+
extends TESIRequestFunctionSignature<ActualOpt>, TESIRequestFunctionMethods<ActualOpt> {
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* Represents the methods available for making ESI requests.
|
|
232
|
+
*
|
|
233
|
+
* + This interface is used when you already have implementation code such as
|
|
234
|
+
* TESIRequestFunctionSignature and you want to implement additional shorthand methods.
|
|
235
|
+
*
|
|
236
|
+
* @template ActualOpt - The actual type of the options.
|
|
237
|
+
*
|
|
238
|
+
* @example
|
|
239
|
+
* ```ts
|
|
240
|
+
* export const request: TESIRequestFunctionSignature<ESIRequestOptions> = (method, endpoint, pathParams, opt) => {
|
|
241
|
+
* // Implementation for "get" | "post" | "put" | "delete" request
|
|
242
|
+
* };
|
|
243
|
+
* // You can easily implement "get" | "post" | "put" | "delete" requests
|
|
244
|
+
* // with code like the following:
|
|
245
|
+
* const esiMethods = {} as TESIRequestFunctionMethods<ESIRequestOptions>;
|
|
246
|
+
* (["get", "post", "put", "delete"] as (keyof TESIRequestFunctionMethods)[]).forEach((method) => {
|
|
247
|
+
* esiMethods[method] = function (endpoint, params, opt) {
|
|
248
|
+
* return request(method, endpoint, params, opt);
|
|
249
|
+
* } as TESIRequestFunctionEachMethod<typeof method>;
|
|
250
|
+
* });
|
|
251
|
+
* ```
|
|
252
|
+
*/
|
|
253
|
+
export type TESIRequestFunctionMethods<ActualOpt = {}> = {
|
|
254
|
+
[method in TESIEntryMethod]: TESIRequestFunctionEachMethod<method, ActualOpt>;
|
|
255
|
+
}
|
|
256
|
+
|
|
206
257
|
declare global {
|
|
207
258
|
|
|
208
259
|
/**
|
|
@@ -224,15 +275,40 @@ declare global {
|
|
|
224
275
|
type TESIRequestFunctionSignature<ActualOpt> = <
|
|
225
276
|
M extends TESIEntryMethod,
|
|
226
277
|
EP extends keyof TESIResponseOKMap[M],
|
|
227
|
-
P2 extends
|
|
278
|
+
P2 extends IfParameterizedPath<EP, Opt>,
|
|
228
279
|
Opt extends IdentifyParameters<TESIResponseOKMap[M][EP], ActualOpt>,
|
|
229
280
|
R extends InferESIResponseResult<M, EP>
|
|
230
281
|
>(method: M, endpoint: EP, pathParams?: P2, options?: Opt) => Promise<R>;
|
|
231
282
|
|
|
232
283
|
/**
|
|
233
|
-
*
|
|
284
|
+
* Represents a function that makes an ESI request using a specific HTTP method.
|
|
285
|
+
*
|
|
286
|
+
* @template M - The HTTP method to use for the request (e.g., "get", "post").
|
|
287
|
+
* @template ActualOpt - The actual type of the options to include in the request.
|
|
288
|
+
*
|
|
289
|
+
* @param endpoint - The path of the ESI endpoint to send the request to.
|
|
290
|
+
* @param pathParams - An optional parameter that can be a number, an array of numbers, or other parameters
|
|
291
|
+
* depending on whether the path is parameterized.
|
|
292
|
+
* @param options - An optional object containing additional options for the request.
|
|
293
|
+
*
|
|
294
|
+
* @returns A Promise object containing the response data, with the type inferred based on the method and endpoint.
|
|
234
295
|
*/
|
|
235
|
-
type
|
|
296
|
+
type TESIRequestFunctionEachMethod<M extends TESIEntryMethod, ActualOpt = {}> = <
|
|
297
|
+
EP extends keyof TESIResponseOKMap[M],
|
|
298
|
+
P2 extends IfParameterizedPath<EP, Opt>,
|
|
299
|
+
Opt extends IdentifyParameters<TESIResponseOKMap[M][EP], ActualOpt>,
|
|
300
|
+
R extends InferESIResponseResult<M, EP>
|
|
301
|
+
>(endpoint: EP, pathParams?: P2, options?: Opt) => Promise<R>;
|
|
302
|
+
|
|
303
|
+
// /**
|
|
304
|
+
// * is parameterized path
|
|
305
|
+
// */
|
|
306
|
+
// type IsParameterizedPath<EP, A, B> = EP extends `${string}/{${string}}/${string | ""}` ? A: B;
|
|
307
|
+
/**
|
|
308
|
+
* if parameterized path then specify number type, otherwise will be `Opt` type.
|
|
309
|
+
*/
|
|
310
|
+
type IfParameterizedPath<EP, Opt> = EP extends `${string}/{${string}}/${string | ""}` ? number | number[]: Opt;
|
|
311
|
+
|
|
236
312
|
/**
|
|
237
313
|
* Identifies the required parameters for a given entry type.
|
|
238
314
|
*
|
package/v2.d.mts
CHANGED
|
@@ -11,7 +11,7 @@ import { type ESIRequestOptions } from "./rq-util.mjs";
|
|
|
11
11
|
* fire ESI request
|
|
12
12
|
* @template {TESIEntryMethod} M
|
|
13
13
|
* @template {keyof TESIResponseOKMap[M]} EP
|
|
14
|
-
* @template {
|
|
14
|
+
* @template {IfParameterizedPath<EP, Opt>} P2
|
|
15
15
|
* @template {IdentifyParameters<TESIResponseOKMap[M][EP], ESIRequestOptions>} Opt
|
|
16
16
|
* @template {InferESIResponseResult<M, EP>} R
|
|
17
17
|
*
|
|
@@ -23,10 +23,4 @@ import { type ESIRequestOptions } from "./rq-util.mjs";
|
|
|
23
23
|
* @throws
|
|
24
24
|
* @async
|
|
25
25
|
*/
|
|
26
|
-
export declare function fire<
|
|
27
|
-
M extends TESIEntryMethod,
|
|
28
|
-
EP extends keyof TESIResponseOKMap[M],
|
|
29
|
-
Opt extends IdentifyParameters<TESIResponseOKMap[M][EP], ESIRequestOptions>,
|
|
30
|
-
P2 extends IsParameterizedPath<EP, number | number[], Opt>,
|
|
31
|
-
R extends InferESIResponseResult<M, EP>
|
|
32
|
-
>(mthd: M, endp: EP, pathParams?: P2, opt?: Opt): Promise<R>;
|
|
26
|
+
export declare function fire<M extends TESIEntryMethod, EP extends keyof TESIResponseOKMap[M], P2 extends IfParameterizedPath<EP, Opt>, Opt extends IdentifyParameters<TESIResponseOKMap[M][EP], ESIRequestOptions>, R extends InferESIResponseResult<M, EP>>(mthd: M, endp: EP, pathParams?: P2, opt?: Opt): Promise<R>;
|
package/v2.mjs
CHANGED
|
@@ -29,7 +29,7 @@ const incrementAx = (minus) => minus ? ax-- : ax++;
|
|
|
29
29
|
* fire ESI request
|
|
30
30
|
* @template {TESIEntryMethod} M
|
|
31
31
|
* @template {keyof TESIResponseOKMap[M]} EP
|
|
32
|
-
* @template {
|
|
32
|
+
* @template {IfParameterizedPath<EP, Opt>} P2
|
|
33
33
|
* @template {IdentifyParameters<TESIResponseOKMap[M][EP], ESIRequestOptions>} Opt
|
|
34
34
|
* @template {InferESIResponseResult<M, EP>} R
|
|
35
35
|
*
|
|
@@ -43,11 +43,11 @@ const incrementAx = (minus) => minus ? ax-- : ax++;
|
|
|
43
43
|
*/
|
|
44
44
|
export async function fire(mthd, endp, pathParams, opt) {
|
|
45
45
|
if (typeof pathParams === "number") {
|
|
46
|
-
// @ts-
|
|
46
|
+
// @ts-expect-error
|
|
47
47
|
pathParams = [pathParams]; // as unknown as P2;
|
|
48
48
|
}
|
|
49
49
|
if (isArray(pathParams)) {
|
|
50
|
-
// @ts-
|
|
50
|
+
// @ts-expect-error actualy endp is string
|
|
51
51
|
endp = replaceCbt(endp, pathParams);
|
|
52
52
|
}
|
|
53
53
|
// When only options are provided
|
|
@@ -55,13 +55,13 @@ export async function fire(mthd, endp, pathParams, opt) {
|
|
|
55
55
|
// @ts-ignore
|
|
56
56
|
const actualOpt = opt || pathParams || {};
|
|
57
57
|
const { rqopt, qss } = initOptions(mthd, actualOpt);
|
|
58
|
-
// @ts-
|
|
58
|
+
// @ts-expect-error actualy endp is string
|
|
59
59
|
const endpointUrl = curl(endp);
|
|
60
|
-
const
|
|
60
|
+
const up = new URLSearchParams(qss);
|
|
61
|
+
const url = `${endpointUrl}${up.size ? `?${up}` : ""}`;
|
|
61
62
|
LOG && log(url);
|
|
62
63
|
ax++;
|
|
63
64
|
try {
|
|
64
|
-
// @ts-ignore A silly type error will appear, but ignore it.
|
|
65
65
|
const res = await fetch(url, rqopt).finally(() => ax--);
|
|
66
66
|
const { status } = res;
|
|
67
67
|
if (!res.ok && !actualOpt.ignoreError) {
|
|
@@ -88,19 +88,19 @@ export async function fire(mthd, endp, pathParams, opt) {
|
|
|
88
88
|
}
|
|
89
89
|
// - - - - x-pages response.
|
|
90
90
|
// +undefined is NaN
|
|
91
|
-
// @ts-
|
|
91
|
+
// @ts-expect-error becouse +null is 0
|
|
92
92
|
const pc = +res.headers.get("x-pages");
|
|
93
93
|
// has remaining pages? NaN > 1 === false !isNaN(pageCount)
|
|
94
94
|
if (pc > 1) {
|
|
95
95
|
LOG && log('found "x-pages" header, pages: %d', pc);
|
|
96
|
-
const remData = await fetchP(endpointUrl, rqopt,
|
|
96
|
+
const remData = await fetchP(endpointUrl, rqopt, up, pc, incrementAx);
|
|
97
97
|
// finally, decide product data.
|
|
98
98
|
if (isArray(data) && isArray(remData)) {
|
|
99
99
|
// DEVNOTE: 2019/7/23 15:01:48 - types
|
|
100
100
|
return /** @type {R} */ (data.concat(remData));
|
|
101
101
|
}
|
|
102
102
|
else {
|
|
103
|
-
// @ts-
|
|
103
|
+
// @ts-expect-error TODO: fix type
|
|
104
104
|
remData && Object.assign(data, remData);
|
|
105
105
|
}
|
|
106
106
|
}
|
|
@@ -108,7 +108,7 @@ export async function fire(mthd, endp, pathParams, opt) {
|
|
|
108
108
|
}
|
|
109
109
|
}
|
|
110
110
|
catch (e) {
|
|
111
|
-
// @ts-
|
|
111
|
+
// @ts-expect-error actualy endp is string
|
|
112
112
|
throw new ESIRequesError(`message: ${e.message}, endpoint=${endp}`);
|
|
113
113
|
}
|
|
114
114
|
}
|
|
@@ -123,7 +123,6 @@ async function getEVEStatus(fn) {
|
|
|
123
123
|
return fn("get", "/status/");
|
|
124
124
|
}
|
|
125
125
|
// type following and run
|
|
126
|
-
// bun scripts/v2.mts
|
|
127
126
|
// node v2.mjs
|
|
128
127
|
// or yarn test
|
|
129
128
|
getEVEStatus(fire).then(eveStatus => console.log(eveStatus));
|