eve-esi-types 3.1.2 → 3.1.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/lib/request-api.mjs +2 -2
- package/lib/rq-util.d.mts +13 -24
- package/lib/rq-util.mjs +33 -46
- package/minimal-rq.mjs +2 -2
- package/package.json +1 -1
- package/tagged-rq.mjs +1 -1
- package/v2/esi-tagged-types.d.ts +2 -2
- package/v2/index.d.ts +121 -21
- package/v2/response-map.d.ts +1 -1
- package/v2/types-index.d.ts +1 -1
package/lib/request-api.mjs
CHANGED
|
@@ -70,7 +70,7 @@ export const request2 = /** @type {IESIRequestFunction2} */ (async (method, endp
|
|
|
70
70
|
//
|
|
71
71
|
/** @type {TESIEntryMethod[]} */ (["get", "post", "put", "delete"]).forEach((method) => {
|
|
72
72
|
request2[method] = /** @type {TESIRequestFunctionEachMethod2<typeof method, util.ESIRequestOptions>} */ ((endpoint, opt) => {
|
|
73
|
-
// @ts-expect-error TODO: ts(2345)
|
|
74
|
-
return request2(method, endpoint, opt);
|
|
73
|
+
// @ts-expect- error TODO: ts(2345)
|
|
74
|
+
return request2(method, endpoint, /** @type {Parameters<typeof request2>[2]} */ (opt));
|
|
75
75
|
});
|
|
76
76
|
});
|
package/lib/rq-util.d.mts
CHANGED
|
@@ -37,14 +37,6 @@ export type ESIRequestOptions = {
|
|
|
37
37
|
* will need it for `POST` request etc.
|
|
38
38
|
*/
|
|
39
39
|
body?: any;
|
|
40
|
-
/**
|
|
41
|
-
* cancel request immediately
|
|
42
|
-
*/
|
|
43
|
-
cancelable?: AbortController;
|
|
44
|
-
/**
|
|
45
|
-
* Can be an empty object if no authentication is required.description
|
|
46
|
-
*/
|
|
47
|
-
token?: TAcccessToken;
|
|
48
40
|
/**
|
|
49
41
|
* whether an authorization header is required
|
|
50
42
|
*
|
|
@@ -57,7 +49,15 @@ export type ESIRequestOptions = {
|
|
|
57
49
|
* @date 2025/3/13
|
|
58
50
|
* @since v3.0.0
|
|
59
51
|
*/
|
|
60
|
-
pathParams?: number | number
|
|
52
|
+
pathParams?: number | [number, number];
|
|
53
|
+
/**
|
|
54
|
+
* Can be an empty object if no authentication is required.description
|
|
55
|
+
*/
|
|
56
|
+
token?: TAcccessToken;
|
|
57
|
+
/**
|
|
58
|
+
* cancel request immediately
|
|
59
|
+
*/
|
|
60
|
+
cancelable?: AbortController;
|
|
61
61
|
};
|
|
62
62
|
/**
|
|
63
63
|
* @typedef {string | number | boolean} Truthy
|
|
@@ -141,7 +141,7 @@ export declare const initOptions: (method: string, opt: ESIRequestOptions) => {
|
|
|
141
141
|
* fetch the extra pages
|
|
142
142
|
*
|
|
143
143
|
* + if the `x-pages` header property ware more than 1
|
|
144
|
-
* @template {
|
|
144
|
+
* @template {unknown} T
|
|
145
145
|
* @param {string} endpointUrl
|
|
146
146
|
* @param {RequestInit} rqopt request options
|
|
147
147
|
* @param {URLSearchParams} usp queries
|
|
@@ -181,22 +181,11 @@ export declare function getLogger(): {
|
|
|
181
181
|
clog: (...args: any[]) => void;
|
|
182
182
|
rlog: (...args: any[]) => void;
|
|
183
183
|
};
|
|
184
|
-
|
|
185
|
-
export interface IFireWithoutAuth<ActualOpt = ESIRequestOptions> {
|
|
186
|
-
<Mtd extends TESIEntryMethod, REP extends ReplacePathParams<ESIEndpointOf<Mtd>> | ESIEndpointOf<Mtd>, EPX extends ResolvedEndpoint<REP, Mtd>, PPM extends InferPathParams<REP, EPX>, Opt extends IdentifyParameters<Mtd, EPX, ActualOpt & PPM>, Ret extends InferESIResponseResult<Mtd, EPX>, HasOpt = HasRequireParams<Mtd, EPX, PPM>, XX = PickRequireParams<Mtd, EPX, PPM>>(fn: TESIRequestFunctionSignature2<ActualOpt> | TESIRequestFunctionMethods2<ActualOpt>, method: Mtd, endpoint: REP, ...opt: HasOpt extends 1 ? [Opt] : [Opt?]): Promise<Ret>;
|
|
187
|
-
}
|
|
188
|
-
/**
|
|
189
|
-
* Need typescript v5.5 later
|
|
190
|
-
* @import * as ESI from "../v2";
|
|
191
|
-
* @typedef {ESI.TESIResponseOKMap} TESIResponseOKMap
|
|
192
|
-
* @typedef {ESI.TPathParamsNever} TPathParamsNever
|
|
193
|
-
* @typedef {ESI.IESIRequestFunction2<ESIRequestOptions>} IESIRequestFunction2
|
|
194
|
-
* @typedef {ESI.TESIRequestFunctionMethods2<ESIRequestOptions>} TESIRequestFunctionMethods2
|
|
195
|
-
*/
|
|
184
|
+
type TPrependParams = TESIRequestFunctionSignature2<ESIRequestOptions> | TESIRequestFunctionMethods2<ESIRequestOptions>;
|
|
196
185
|
/**
|
|
197
186
|
* #### Fire a request that does not require authentication.
|
|
198
187
|
*
|
|
199
|
-
* @param {
|
|
188
|
+
* @param {TPrependParams} fn
|
|
200
189
|
* @returns {Promise<void>}
|
|
201
190
|
*/
|
|
202
|
-
export declare function fireRequestsDoesNotRequireAuth(fn:
|
|
191
|
+
export declare function fireRequestsDoesNotRequireAuth(fn: TPrependParams): Promise<void>;
|
package/lib/rq-util.mjs
CHANGED
|
@@ -228,7 +228,7 @@ export const initOptions = (method, opt) => {
|
|
|
228
228
|
* fetch the extra pages
|
|
229
229
|
*
|
|
230
230
|
* + if the `x-pages` header property ware more than 1
|
|
231
|
-
* @template {
|
|
231
|
+
* @template {unknown} T
|
|
232
232
|
* @param {string} endpointUrl
|
|
233
233
|
* @param {RequestInit} rqopt request options
|
|
234
234
|
* @param {URLSearchParams} usp queries
|
|
@@ -320,55 +320,37 @@ export function getLogger() {
|
|
|
320
320
|
const rlog = consoleUtil.getLogger("- - -> Run ESI request".cyan);
|
|
321
321
|
return { clog, rlog };
|
|
322
322
|
}
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
type IncompleteEP = ResolvedEndpoint<"/characters/1234/fittings/{fitting_id}/", "delete">;
|
|
332
|
-
|
|
333
|
-
// Result: "/characters/{character_id}/fittings/{fitting_id}/"
|
|
334
|
-
type EPOriginOK = InferEndpointOrigin<"/characters/123/fittings/456/", "delete">;
|
|
335
|
-
// result: never
|
|
336
|
-
type EPOriginNever = InferEndpointOrigin<"/characters/123/fittings/{fitting_id}/", "delete">;
|
|
337
|
-
// result: never
|
|
338
|
-
type EPOriginNever2 = InferEndpointOrigin<"/characters/{character_id}/fittings/456/", "delete">;
|
|
339
|
-
/*/
|
|
340
|
-
//*/
|
|
323
|
+
/**
|
|
324
|
+
* Need typescript v5.5 later
|
|
325
|
+
* @import * as ESI from "../v2";
|
|
326
|
+
* @typedef {ESI.TESIRequestFunctionMethods2<ESIRequestOptions>} TESIRequestFunctionMethods2
|
|
327
|
+
*/
|
|
328
|
+
/**
|
|
329
|
+
* @typedef {TESIRequestFunctionSignature2<ESIRequestOptions> | TESIRequestFunctionMethods2} TPrependParams
|
|
330
|
+
*/
|
|
341
331
|
/**
|
|
342
332
|
* #### Fire a request that does not require authentication.
|
|
343
333
|
*
|
|
344
|
-
* @type {
|
|
334
|
+
* @type {TESIEnhancedRequestFunctionSignature<TPrependParams, ESIRequestOptions>}
|
|
345
335
|
*/
|
|
346
|
-
// @ts-expect -error
|
|
347
336
|
const fireWithoutAuth = (fn, method, endpoint, ...opt) => {
|
|
348
|
-
const arg = opt.length ? opt[0] : void 0;
|
|
349
337
|
if (typeof fn === "function") {
|
|
350
|
-
|
|
351
|
-
return fn(method, endpoint, arg);
|
|
338
|
+
const arg = opt.length ? opt[0] : void 0;
|
|
339
|
+
return fn(method, endpoint, /** @type {Parameters<typeof fn>[2]} */ (arg));
|
|
352
340
|
}
|
|
353
341
|
// @ts-expect-error TODO: ts(2345) The argument type does not match the type of the specified parameter
|
|
354
|
-
return fn[method](endpoint,
|
|
342
|
+
return fn[method](endpoint, ...opt);
|
|
355
343
|
};
|
|
356
|
-
|
|
357
|
-
* Need typescript v5.5 later
|
|
358
|
-
* @import * as ESI from "../v2";
|
|
359
|
-
* @typedef {ESI.TESIResponseOKMap} TESIResponseOKMap
|
|
360
|
-
* @typedef {ESI.TPathParamsNever} TPathParamsNever
|
|
361
|
-
* @typedef {ESI.IESIRequestFunction2<ESIRequestOptions>} IESIRequestFunction2
|
|
362
|
-
* @typedef {ESI.TESIRequestFunctionMethods2<ESIRequestOptions>} TESIRequestFunctionMethods2
|
|
363
|
-
*/
|
|
344
|
+
const token = `token.token.token`;
|
|
364
345
|
/**
|
|
365
346
|
* #### Fire a request that does not require authentication.
|
|
366
347
|
*
|
|
367
|
-
* @param {
|
|
348
|
+
* @param {TPrependParams} fn
|
|
368
349
|
* @returns {Promise<void>}
|
|
369
350
|
*/
|
|
370
351
|
export async function fireRequestsDoesNotRequireAuth(fn) {
|
|
371
352
|
const { clog, rlog } = getLogger();
|
|
353
|
+
const ID_SomeEVECharacter = 90000;
|
|
372
354
|
const ID_CCP_Zoetrope = 2112625428;
|
|
373
355
|
try {
|
|
374
356
|
// - - - - - - - - - - - -
|
|
@@ -378,6 +360,7 @@ export async function fireRequestsDoesNotRequireAuth(fn) {
|
|
|
378
360
|
clog();
|
|
379
361
|
casefireWithoutAuth: {
|
|
380
362
|
await fireWithoutAuth(fn, "get", `/characters/{character_id}/`, {
|
|
363
|
+
// auth: true, // ✅ At this point, the expected semantic error is successfully triggered as intended.
|
|
381
364
|
pathParams: ID_CCP_Zoetrope
|
|
382
365
|
}).then(log);
|
|
383
366
|
clog('(portrait)');
|
|
@@ -392,12 +375,15 @@ export async function fireRequestsDoesNotRequireAuth(fn) {
|
|
|
392
375
|
if (is("withError")) {
|
|
393
376
|
await fireWithoutAuth(fn, "get", "/characters/{character_id}/assets/", {
|
|
394
377
|
auth: true,
|
|
395
|
-
pathParams:
|
|
378
|
+
pathParams: ID_SomeEVECharacter,
|
|
379
|
+
token
|
|
380
|
+
}).then(assets => {
|
|
381
|
+
log(assets.slice(0, 5));
|
|
396
382
|
});
|
|
397
383
|
await fireWithoutAuth(fn, "delete", `/characters/${1234}/fittings/${56789}/`, {
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
}).catch(
|
|
384
|
+
auth: true,
|
|
385
|
+
// pathParams: [1234, 56789], // ✅ At this point, the expected semantic error is successfully triggered as intended.
|
|
386
|
+
}).catch(log);
|
|
401
387
|
}
|
|
402
388
|
}
|
|
403
389
|
// - - - - - - - - - - - -
|
|
@@ -429,20 +415,21 @@ export async function fireRequestsDoesNotRequireAuth(fn) {
|
|
|
429
415
|
// The following is code to observe the behavior of completion by generics.
|
|
430
416
|
// Authentication is required, so an error will occur.
|
|
431
417
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
432
|
-
let willFailed = await fireWithoutAuth(fn, "get", `/characters/${
|
|
418
|
+
let willFailed = await fireWithoutAuth(fn, "get", `/characters/${ID_SomeEVECharacter}/ship/`, {
|
|
433
419
|
auth: true,
|
|
434
|
-
token
|
|
420
|
+
token //: "token.token.token"
|
|
435
421
|
});
|
|
436
|
-
log(`get:/characters/${
|
|
422
|
+
log(`get:/characters/${ID_SomeEVECharacter}/ship/, returns:`, willFailed);
|
|
437
423
|
// in this case, "categories" and "search" is required
|
|
438
424
|
await fireWithoutAuth(fn, "get", "/characters/{character_id}/search/", {
|
|
439
|
-
pathParams:
|
|
425
|
+
pathParams: ID_SomeEVECharacter,
|
|
440
426
|
query: {
|
|
441
|
-
categories: ["
|
|
442
|
-
search: "
|
|
427
|
+
categories: ["inventory_type"],
|
|
428
|
+
search: "plex"
|
|
443
429
|
},
|
|
444
|
-
auth: true
|
|
445
|
-
|
|
430
|
+
auth: true,
|
|
431
|
+
token
|
|
432
|
+
}).then(log);
|
|
446
433
|
// // TODO: want TypeScript semantics to throw an error because there is a required query parameter, but it's not possible
|
|
447
434
|
// // Or rather, I don't know how to do it.
|
|
448
435
|
// await fireWithoutAuth(fn, "get", "/characters/{character_id}/search/", {
|
package/minimal-rq.mjs
CHANGED
|
@@ -29,8 +29,8 @@ const log = util.getUniversalLogger("[request-mini]: ");
|
|
|
29
29
|
const esiMethods = /** @type {TESIRequestFunctionMethods2} */ ({});
|
|
30
30
|
/** @satisfies {TESIEntryMethod[]} */ (["get", "post", "put", "delete"]).forEach((method) => {
|
|
31
31
|
esiMethods[method] = /** @type {TESIRequestFunctionEachMethod2<typeof method, util.ESIRequestOptions>} */ ((endpoint, opt) => {
|
|
32
|
-
// @ts-expect-error ts(2345)
|
|
33
|
-
return request2(method, endpoint, opt);
|
|
32
|
+
// @ts-expect -error ts(2345)
|
|
33
|
+
return request2(method, endpoint, /** @type {Parameters<typeof request2>[2]} */ (opt));
|
|
34
34
|
});
|
|
35
35
|
});
|
|
36
36
|
// It should complete correctly.
|
package/package.json
CHANGED
package/tagged-rq.mjs
CHANGED
|
@@ -44,7 +44,7 @@ if (util.is("withError")) {
|
|
|
44
44
|
// token: "s.s.s"
|
|
45
45
|
})).then(console.log).catch(console.log);
|
|
46
46
|
esi.fittings.delete("/characters/1234/fittings/56789/", {
|
|
47
|
-
pathParams: [1234, 56789], //
|
|
47
|
+
// pathParams: [1234, 56789], // ✅ At this point, the expected semantic error is successfully triggered as intended.
|
|
48
48
|
auth: true
|
|
49
49
|
});
|
|
50
50
|
esi.character.post("/characters/affiliation/", {
|
package/v2/esi-tagged-types.d.ts
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* THIS DTS IS AUTO GENERATED, DO NOT EDIT
|
|
10
10
|
*
|
|
11
11
|
* @file eve-esi-types/v2/esi-tagged-types.d.ts
|
|
12
|
-
* @summary This file is auto-generated and defines version 3.1.
|
|
12
|
+
* @summary This file is auto-generated and defines version 3.1.4 of the EVE Online ESI response types.
|
|
13
13
|
*/
|
|
14
14
|
import { TESIResponseOKMap } from "./index.d.ts";
|
|
15
15
|
export * from "./index.d.ts";
|
|
@@ -121,7 +121,7 @@ export declare type TaggedEndpointRequestFunction2<
|
|
|
121
121
|
REP extends ReplacePathParams<EndPoints> | EndPoints,
|
|
122
122
|
EPX extends _InferEndpointOrigin<REP, EndPoints> extends never ? REP: _InferEndpointOrigin<REP, EndPoints>,
|
|
123
123
|
PPM extends InferPathParams<REP, EPX>,
|
|
124
|
-
Opt extends IdentifyParameters<M, EPX, ActualOpt
|
|
124
|
+
Opt extends IdentifyParameters<M, EPX, ActualOpt, PPM>,
|
|
125
125
|
Ret extends InferESIResponseResult<M, EPX>,
|
|
126
126
|
HasOpt = HasRequireParams<M, EPX, PPM>,
|
|
127
127
|
>(endpoint: REP, ...options: HasOpt extends 1 ? [Opt] : [Opt?]) => Promise<Ret>;
|
package/v2/index.d.ts
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* THIS DTS 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 3.1.
|
|
12
|
+
* @summary This file is auto-generated and defines version 3.1.4 of the EVE Online ESI response types.
|
|
13
13
|
*/
|
|
14
14
|
import type { TESIResponseOKMap } from "./response-map.d.ts";
|
|
15
15
|
export type { TESIResponseOKMap } from "./response-map.d.ts";
|
|
@@ -36,7 +36,7 @@ import type { PickPathParameters, InferKeysLen } from "./util.d.ts";
|
|
|
36
36
|
* });
|
|
37
37
|
* ```
|
|
38
38
|
*/
|
|
39
|
-
export interface IESIRequestFunction2<ActualOpt
|
|
39
|
+
export interface IESIRequestFunction2<ActualOpt extends Record<string, unknown>>
|
|
40
40
|
extends TESIRequestFunctionSignature2<ActualOpt>, TESIRequestFunctionMethods2<ActualOpt> {
|
|
41
41
|
}
|
|
42
42
|
|
|
@@ -63,7 +63,7 @@ export interface IESIRequestFunction2<ActualOpt>
|
|
|
63
63
|
* });
|
|
64
64
|
* ```
|
|
65
65
|
*/
|
|
66
|
-
export type TESIRequestFunctionMethods2<ActualOpt
|
|
66
|
+
export type TESIRequestFunctionMethods2<ActualOpt extends Record<string, unknown>> = {
|
|
67
67
|
[method in TESIEntryMethod]: TESIRequestFunctionEachMethod2<method, ActualOpt>;
|
|
68
68
|
}
|
|
69
69
|
|
|
@@ -163,6 +163,55 @@ export type __IdentifyParameters<
|
|
|
163
163
|
// @ts-expect-error
|
|
164
164
|
> = RequireThese<Opt, Keys> & Pick<Entry, Keys>;
|
|
165
165
|
|
|
166
|
+
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
167
|
+
// Internal types
|
|
168
|
+
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
169
|
+
/**
|
|
170
|
+
* Defines the keys used in ESI entries.
|
|
171
|
+
*/
|
|
172
|
+
type ESIEntryKeys = "auth" | "query" | "body" | "pathParams";
|
|
173
|
+
/**
|
|
174
|
+
* Restricts the keys of a type to the specified ones while excluding extra keys.
|
|
175
|
+
*
|
|
176
|
+
* This utility type is designed to enforce stricter semantics by marking unwanted keys as `never`.
|
|
177
|
+
*
|
|
178
|
+
* @template T - The original type to be constrained.
|
|
179
|
+
* @template T2 - The type to merge with the constrained type.
|
|
180
|
+
* @template RequireKeys - The keys to retain in the resulting type.
|
|
181
|
+
* @template Extras - Automatically derived keys to exclude from the resulting type.
|
|
182
|
+
*
|
|
183
|
+
* @example
|
|
184
|
+
* ```ts
|
|
185
|
+
* type Original = { auth?: string; query?: string; body?: string; pathParams?: string; extra?: string };
|
|
186
|
+
* type Required = { auth: true; query: { test: "pen" | "pencil" } };
|
|
187
|
+
* type Restricted = RestrictKeys<Original, Required, "auth" | "query">;
|
|
188
|
+
* // Result: { auth: true; query: { test: "pen" | "pencil" }; body?: undefined; pathParams?: undefined; extra?: string | undefined }
|
|
189
|
+
* ```
|
|
190
|
+
*/
|
|
191
|
+
//* ctt
|
|
192
|
+
type RestrictKeys<
|
|
193
|
+
T, RequireKeys extends keyof T,
|
|
194
|
+
Extras = Exclude<ESIEntryKeys, RequireKeys>
|
|
195
|
+
> = {
|
|
196
|
+
[P in keyof T]: P extends Extras ? never : T[P];
|
|
197
|
+
};
|
|
198
|
+
// type RequireEntry = {
|
|
199
|
+
// auth?: true;
|
|
200
|
+
// query?: { test: "pen" | "pencil" };
|
|
201
|
+
// body?: string;
|
|
202
|
+
// pathParams?: string;
|
|
203
|
+
// extra?: string
|
|
204
|
+
// };
|
|
205
|
+
// type Restricted = RestrictKeys<RequireEntry, "auth" | "query">;
|
|
206
|
+
/*/
|
|
207
|
+
type RestrictKeys<
|
|
208
|
+
T, T2,
|
|
209
|
+
K extends keyof T,
|
|
210
|
+
Extras = Exclude<ESIEntryKeys, K>
|
|
211
|
+
> = T2 & {
|
|
212
|
+
[P in keyof T as P extends K ? never : P]: P extends Extras ? never : T[P];
|
|
213
|
+
};
|
|
214
|
+
//*/
|
|
166
215
|
|
|
167
216
|
declare global {
|
|
168
217
|
|
|
@@ -180,7 +229,9 @@ declare global {
|
|
|
180
229
|
* ```
|
|
181
230
|
*/
|
|
182
231
|
type RequireThese<T, K extends keyof T> = {
|
|
183
|
-
[P in keyof T
|
|
232
|
+
[P in keyof T as P extends K ? P : never]-?: T[P];
|
|
233
|
+
} & {
|
|
234
|
+
[P in keyof T as P extends K ? never : P]: T[P];
|
|
184
235
|
};
|
|
185
236
|
|
|
186
237
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
@@ -212,16 +263,62 @@ declare global {
|
|
|
212
263
|
* The `...options: HasOpt extends 1 ? [Opt] : [Opt?]` parameter is defined this way to enforce that if the endpoint has required parameters,
|
|
213
264
|
* the `options` parameter must be provided. If there are no required parameters, the `options` parameter is optional.
|
|
214
265
|
*/
|
|
215
|
-
type TESIRequestFunctionSignature2<ActualOpt
|
|
266
|
+
type TESIRequestFunctionSignature2<ActualOpt extends Record<string, unknown>> = <
|
|
216
267
|
Mtd extends TESIEntryMethod,
|
|
217
268
|
REP extends ReplacePathParams<ESIEndpointOf<Mtd>> | ESIEndpointOf<Mtd>,
|
|
218
269
|
EPX extends ResolvedEndpoint<REP, Mtd>,
|
|
219
270
|
PPM extends InferPathParams<REP, EPX>,
|
|
220
|
-
Opt extends IdentifyParameters<Mtd, EPX, ActualOpt
|
|
271
|
+
Opt extends IdentifyParameters<Mtd, EPX, ActualOpt, PPM>,
|
|
221
272
|
Ret extends InferESIResponseResult<Mtd, EPX>,
|
|
222
273
|
HasOpt = HasRequireParams<Mtd, EPX, PPM>,
|
|
223
274
|
>(method: Mtd, endpoint: REP, ...options: HasOpt extends 1 ? [Opt] : [Opt?]) => Promise<Ret>;
|
|
224
275
|
|
|
276
|
+
/**
|
|
277
|
+
* A function signature type for making enhanced ESI requests.
|
|
278
|
+
*
|
|
279
|
+
* This type extends the base ESI request function signature by injecting a prepended parameter to allow for extra
|
|
280
|
+
* context or pre-processing before performing the request. It provides a highly generic interface that adapts to the
|
|
281
|
+
* chosen endpoint method, endpoint configuration, and additional options, making it ideal for advanced API interactions.
|
|
282
|
+
*
|
|
283
|
+
* Generic Parameters:
|
|
284
|
+
* @template PrependParam - The type of the additional parameter that is injected at the beginning of the function call.
|
|
285
|
+
* @template ActualOpt - An object representing the default options (typically extending ESIRequestOptions) used for the request.
|
|
286
|
+
*
|
|
287
|
+
* Function Generic Parameters:
|
|
288
|
+
* @template Mtd - The ESI request method type (e.g., GET, POST) as defined in TESIEntryMethod.
|
|
289
|
+
* @template REP - The endpoint type, which can be either a version with replaced path parameters (via ReplacePathParams)
|
|
290
|
+
* or the raw ESIEndpointOf<Mtd> type.
|
|
291
|
+
* @template EPX - The resolved endpoint type derived from REP and Mtd.
|
|
292
|
+
* @template PPM - The type representing the inferred path parameters extracted from REP and EPX.
|
|
293
|
+
* @template Opt - The type for additional request options, identified based on the method (Mtd), endpoint (EPX), the
|
|
294
|
+
* default options (ActualOpt), and inferred path parameters (PPM).
|
|
295
|
+
* @template Ret - The type of the response result from the ESI request, inferred from the method and endpoint.
|
|
296
|
+
* @template HasOpt - An internal flag used to determine whether request options (Opt) are required (1) or optional.
|
|
297
|
+
*
|
|
298
|
+
* Parameters:
|
|
299
|
+
* @param {PrependParam} prependParam - A prepended parameter providing additional context or configuration for the request.
|
|
300
|
+
* @param {Mtd} method - The ESI request method.
|
|
301
|
+
* @param {REP} endpoint - The API endpoint, which might include path parameter replacements.
|
|
302
|
+
* @param {...(HasOpt extends 1 ? [Opt] : [Opt?])} options - Additional options for the request; required if HasOpt is 1,
|
|
303
|
+
* otherwise optional.
|
|
304
|
+
*
|
|
305
|
+
* @returns {Promise<Ret>} A promise that resolves with the result type `Ret`, representing the response data from the ESI endpoint.
|
|
306
|
+
*/
|
|
307
|
+
type TESIEnhancedRequestFunctionSignature<
|
|
308
|
+
PrependParam extends unknown, ActualOpt extends Record<string, unknown>
|
|
309
|
+
> = <
|
|
310
|
+
Mtd extends TESIEntryMethod,
|
|
311
|
+
REP extends ReplacePathParams<ESIEndpointOf<Mtd>> | ESIEndpointOf<Mtd>,
|
|
312
|
+
EPX extends ResolvedEndpoint<REP, Mtd>,
|
|
313
|
+
PPM extends InferPathParams<REP, EPX>,
|
|
314
|
+
Opt extends IdentifyParameters<Mtd, EPX, ActualOpt, PPM>,
|
|
315
|
+
Ret extends InferESIResponseResult<Mtd, EPX>,
|
|
316
|
+
HasOpt = HasRequireParams<Mtd, EPX, PPM>
|
|
317
|
+
>(
|
|
318
|
+
prependParam: PrependParam,
|
|
319
|
+
method: Mtd, endpoint: REP, ...options: HasOpt extends 1 ? [Opt] : [Opt?]
|
|
320
|
+
) => Promise<Ret>;
|
|
321
|
+
|
|
225
322
|
/**
|
|
226
323
|
* Represents a function that can make ESI requests for a specific HTTP method.
|
|
227
324
|
*
|
|
@@ -245,13 +342,13 @@ declare global {
|
|
|
245
342
|
* The `...options: HasOpt extends 1 ? [Opt] : [Opt?]` parameter is defined this way to enforce that if the endpoint has required parameters,
|
|
246
343
|
* the `options` parameter must be provided. If there are no required parameters, the `options` parameter is optional.
|
|
247
344
|
*/
|
|
248
|
-
type TESIRequestFunctionEachMethod2<Mtd extends TESIEntryMethod, ActualOpt
|
|
345
|
+
type TESIRequestFunctionEachMethod2<Mtd extends TESIEntryMethod, ActualOpt extends Record<string, unknown>> = <
|
|
249
346
|
REP extends ReplacePathParams<ESIEndpointOf<Mtd>> | ESIEndpointOf<Mtd>,
|
|
250
347
|
EPX extends ResolvedEndpoint<REP, Mtd>,
|
|
251
348
|
PPM extends InferPathParams<REP, EPX>,
|
|
252
|
-
Opt extends IdentifyParameters<Mtd, EPX, ActualOpt
|
|
349
|
+
Opt extends IdentifyParameters<Mtd, EPX, ActualOpt, PPM>,
|
|
253
350
|
Ret extends InferESIResponseResult<Mtd, EPX>,
|
|
254
|
-
HasOpt = HasRequireParams<Mtd, EPX, PPM>,
|
|
351
|
+
HasOpt extends HasRequireParams<Mtd, EPX, PPM> = HasRequireParams<Mtd, EPX, PPM>,
|
|
255
352
|
>(endpoint: REP, ...options: HasOpt extends 1 ? [Opt] : [Opt?]) => Promise<Ret>;
|
|
256
353
|
|
|
257
354
|
/**
|
|
@@ -408,7 +505,7 @@ declare global {
|
|
|
408
505
|
* @template EPx - The endpoint path.
|
|
409
506
|
* @template Opt - The type of the additional options.
|
|
410
507
|
* @template Entry - The entry type to identify parameters for.
|
|
411
|
-
* @template
|
|
508
|
+
* @template RequireKeys - The keys of the entry type that are required parameters.
|
|
412
509
|
*
|
|
413
510
|
* @example
|
|
414
511
|
* ```ts
|
|
@@ -426,20 +523,23 @@ declare global {
|
|
|
426
523
|
M extends TESIEntryMethod,
|
|
427
524
|
EPx extends ESIEndpointOf<M> | string,
|
|
428
525
|
Opt extends Record<string, unknown>,
|
|
429
|
-
|
|
430
|
-
|
|
526
|
+
AdditionalParams,
|
|
527
|
+
Entry = _ESIResponseType<M, EPx> & AdditionalParams,
|
|
528
|
+
RequireKeys = Exclude<keyof (Entry & AdditionalParams), "result" | "tag" | "cachedSeconds">
|
|
431
529
|
// @ts-expect-error
|
|
432
|
-
> =
|
|
530
|
+
> = RestrictKeys<Opt, RequireKeys> & Pick<Entry, RequireKeys> & AdditionalParams;
|
|
433
531
|
/*/
|
|
532
|
+
// DEVNOTE: 2025/3/24
|
|
533
|
+
// The definition is simple and highly maintainable, but it is not possible to reference the `pathParams` property when implementing `TESIRequestFunctionSignature2` etc.
|
|
434
534
|
type IdentifyParameters<
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
535
|
+
M extends TESIEntryMethod,
|
|
536
|
+
EPx extends ESIEndpointOf<M> | string,
|
|
537
|
+
Opt extends Record<string, unknown>,
|
|
538
|
+
AdditionalParams,
|
|
539
|
+
Entry = _ESIResponseType<M, EPx>,
|
|
540
|
+
Keys = Exclude<keyof (Entry & AdditionalParams), "result" | "tag" | "cachedSeconds">
|
|
541
|
+
// @ts-expect- error
|
|
542
|
+
> = RestrictKeys<Opt, Pick<Entry, Keys> & AdditionalParams, Keys>;
|
|
443
543
|
//*/
|
|
444
544
|
|
|
445
545
|
/**
|
package/v2/response-map.d.ts
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* THIS DTS IS AUTO GENERATED, DO NOT EDIT
|
|
10
10
|
*
|
|
11
11
|
* @file eve-esi-types/v2/response-map.d.ts
|
|
12
|
-
* @summary This file is auto-generated and defines version 3.1.
|
|
12
|
+
* @summary This file is auto-generated and defines version 3.1.4 of the EVE Online ESI response types.
|
|
13
13
|
*/
|
|
14
14
|
import "./types-index.d.ts";
|
|
15
15
|
|
package/v2/types-index.d.ts
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* THIS DTS IS AUTO GENERATED, DO NOT EDIT
|
|
10
10
|
*
|
|
11
11
|
* @file eve-esi-types/v2/types-index.d.ts
|
|
12
|
-
* @summary This file is auto-generated and defines version 3.1.
|
|
12
|
+
* @summary This file is auto-generated and defines version 3.1.4 of the EVE Online ESI response types.
|
|
13
13
|
*/
|
|
14
14
|
import "./get_wars_ok.d.ts";
|
|
15
15
|
import "./get_status_ok.d.ts";
|