eve-esi-types 3.1.3 → 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/rq-util.d.mts +3 -14
- package/lib/rq-util.mjs +28 -42
- package/package.json +1 -1
- package/v2/esi-tagged-types.d.ts +1 -1
- package/v2/index.d.ts +63 -16
- package/v2/response-map.d.ts +1 -1
- package/v2/types-index.d.ts +1 -1
package/lib/rq-util.d.mts
CHANGED
|
@@ -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 extends Record<string, unknown> = 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
|
@@ -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
|
-
|
|
338
|
+
const arg = opt.length ? opt[0] : void 0;
|
|
351
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
|
// - - - - - - - - - - - -
|
|
@@ -393,12 +375,15 @@ export async function fireRequestsDoesNotRequireAuth(fn) {
|
|
|
393
375
|
if (is("withError")) {
|
|
394
376
|
await fireWithoutAuth(fn, "get", "/characters/{character_id}/assets/", {
|
|
395
377
|
auth: true,
|
|
396
|
-
pathParams:
|
|
378
|
+
pathParams: ID_SomeEVECharacter,
|
|
379
|
+
token
|
|
380
|
+
}).then(assets => {
|
|
381
|
+
log(assets.slice(0, 5));
|
|
397
382
|
});
|
|
398
383
|
await fireWithoutAuth(fn, "delete", `/characters/${1234}/fittings/${56789}/`, {
|
|
399
384
|
auth: true,
|
|
400
385
|
// pathParams: [1234, 56789], // ✅ At this point, the expected semantic error is successfully triggered as intended.
|
|
401
|
-
}).catch(
|
|
386
|
+
}).catch(log);
|
|
402
387
|
}
|
|
403
388
|
}
|
|
404
389
|
// - - - - - - - - - - - -
|
|
@@ -430,20 +415,21 @@ export async function fireRequestsDoesNotRequireAuth(fn) {
|
|
|
430
415
|
// The following is code to observe the behavior of completion by generics.
|
|
431
416
|
// Authentication is required, so an error will occur.
|
|
432
417
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
433
|
-
let willFailed = await fireWithoutAuth(fn, "get", `/characters/${
|
|
418
|
+
let willFailed = await fireWithoutAuth(fn, "get", `/characters/${ID_SomeEVECharacter}/ship/`, {
|
|
434
419
|
auth: true,
|
|
435
|
-
token
|
|
420
|
+
token //: "token.token.token"
|
|
436
421
|
});
|
|
437
|
-
log(`get:/characters/${
|
|
422
|
+
log(`get:/characters/${ID_SomeEVECharacter}/ship/, returns:`, willFailed);
|
|
438
423
|
// in this case, "categories" and "search" is required
|
|
439
424
|
await fireWithoutAuth(fn, "get", "/characters/{character_id}/search/", {
|
|
440
|
-
pathParams:
|
|
425
|
+
pathParams: ID_SomeEVECharacter,
|
|
441
426
|
query: {
|
|
442
|
-
categories: ["
|
|
443
|
-
search: "
|
|
427
|
+
categories: ["inventory_type"],
|
|
428
|
+
search: "plex"
|
|
444
429
|
},
|
|
445
|
-
auth: true
|
|
446
|
-
|
|
430
|
+
auth: true,
|
|
431
|
+
token
|
|
432
|
+
}).then(log);
|
|
447
433
|
// // TODO: want TypeScript semantics to throw an error because there is a required query parameter, but it's not possible
|
|
448
434
|
// // Or rather, I don't know how to do it.
|
|
449
435
|
// await fireWithoutAuth(fn, "get", "/characters/{character_id}/search/", {
|
package/package.json
CHANGED
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";
|
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
|
|
|
@@ -177,7 +177,7 @@ type ESIEntryKeys = "auth" | "query" | "body" | "pathParams";
|
|
|
177
177
|
*
|
|
178
178
|
* @template T - The original type to be constrained.
|
|
179
179
|
* @template T2 - The type to merge with the constrained type.
|
|
180
|
-
* @template
|
|
180
|
+
* @template RequireKeys - The keys to retain in the resulting type.
|
|
181
181
|
* @template Extras - Automatically derived keys to exclude from the resulting type.
|
|
182
182
|
*
|
|
183
183
|
* @example
|
|
@@ -190,11 +190,10 @@ type ESIEntryKeys = "auth" | "query" | "body" | "pathParams";
|
|
|
190
190
|
*/
|
|
191
191
|
//* ctt
|
|
192
192
|
type RestrictKeys<
|
|
193
|
-
T,
|
|
194
|
-
Extras = Exclude<ESIEntryKeys,
|
|
193
|
+
T, RequireKeys extends keyof T,
|
|
194
|
+
Extras = Exclude<ESIEntryKeys, RequireKeys>
|
|
195
195
|
> = {
|
|
196
|
-
[P in keyof T]: P extends
|
|
197
|
-
P extends Extras ? never : T[P];
|
|
196
|
+
[P in keyof T]: P extends Extras ? never : T[P];
|
|
198
197
|
};
|
|
199
198
|
// type RequireEntry = {
|
|
200
199
|
// auth?: true;
|
|
@@ -230,7 +229,9 @@ declare global {
|
|
|
230
229
|
* ```
|
|
231
230
|
*/
|
|
232
231
|
type RequireThese<T, K extends keyof T> = {
|
|
233
|
-
[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];
|
|
234
235
|
};
|
|
235
236
|
|
|
236
237
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
@@ -262,7 +263,7 @@ declare global {
|
|
|
262
263
|
* The `...options: HasOpt extends 1 ? [Opt] : [Opt?]` parameter is defined this way to enforce that if the endpoint has required parameters,
|
|
263
264
|
* the `options` parameter must be provided. If there are no required parameters, the `options` parameter is optional.
|
|
264
265
|
*/
|
|
265
|
-
type TESIRequestFunctionSignature2<ActualOpt
|
|
266
|
+
type TESIRequestFunctionSignature2<ActualOpt extends Record<string, unknown>> = <
|
|
266
267
|
Mtd extends TESIEntryMethod,
|
|
267
268
|
REP extends ReplacePathParams<ESIEndpointOf<Mtd>> | ESIEndpointOf<Mtd>,
|
|
268
269
|
EPX extends ResolvedEndpoint<REP, Mtd>,
|
|
@@ -272,6 +273,52 @@ declare global {
|
|
|
272
273
|
HasOpt = HasRequireParams<Mtd, EPX, PPM>,
|
|
273
274
|
>(method: Mtd, endpoint: REP, ...options: HasOpt extends 1 ? [Opt] : [Opt?]) => Promise<Ret>;
|
|
274
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
|
+
|
|
275
322
|
/**
|
|
276
323
|
* Represents a function that can make ESI requests for a specific HTTP method.
|
|
277
324
|
*
|
|
@@ -295,7 +342,7 @@ declare global {
|
|
|
295
342
|
* The `...options: HasOpt extends 1 ? [Opt] : [Opt?]` parameter is defined this way to enforce that if the endpoint has required parameters,
|
|
296
343
|
* the `options` parameter must be provided. If there are no required parameters, the `options` parameter is optional.
|
|
297
344
|
*/
|
|
298
|
-
type TESIRequestFunctionEachMethod2<Mtd extends TESIEntryMethod, ActualOpt
|
|
345
|
+
type TESIRequestFunctionEachMethod2<Mtd extends TESIEntryMethod, ActualOpt extends Record<string, unknown>> = <
|
|
299
346
|
REP extends ReplacePathParams<ESIEndpointOf<Mtd>> | ESIEndpointOf<Mtd>,
|
|
300
347
|
EPX extends ResolvedEndpoint<REP, Mtd>,
|
|
301
348
|
PPM extends InferPathParams<REP, EPX>,
|
|
@@ -458,7 +505,7 @@ declare global {
|
|
|
458
505
|
* @template EPx - The endpoint path.
|
|
459
506
|
* @template Opt - The type of the additional options.
|
|
460
507
|
* @template Entry - The entry type to identify parameters for.
|
|
461
|
-
* @template
|
|
508
|
+
* @template RequireKeys - The keys of the entry type that are required parameters.
|
|
462
509
|
*
|
|
463
510
|
* @example
|
|
464
511
|
* ```ts
|
|
@@ -477,10 +524,10 @@ declare global {
|
|
|
477
524
|
EPx extends ESIEndpointOf<M> | string,
|
|
478
525
|
Opt extends Record<string, unknown>,
|
|
479
526
|
AdditionalParams,
|
|
480
|
-
Entry = _ESIResponseType<M, EPx
|
|
481
|
-
|
|
482
|
-
// @ts-expect-
|
|
483
|
-
> = RestrictKeys<Opt,
|
|
527
|
+
Entry = _ESIResponseType<M, EPx> & AdditionalParams,
|
|
528
|
+
RequireKeys = Exclude<keyof (Entry & AdditionalParams), "result" | "tag" | "cachedSeconds">
|
|
529
|
+
// @ts-expect-error
|
|
530
|
+
> = RestrictKeys<Opt, RequireKeys> & Pick<Entry, RequireKeys> & AdditionalParams;
|
|
484
531
|
/*/
|
|
485
532
|
// DEVNOTE: 2025/3/24
|
|
486
533
|
// The definition is simple and highly maintainable, but it is not possible to reference the `pathParams` property when implementing `TESIRequestFunctionSignature2` etc.
|
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";
|