eve-esi-types 3.1.2 → 3.1.3
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 -13
- package/lib/rq-util.mjs +6 -5
- 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 +68 -15
- 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,9 +181,9 @@ export declare function getLogger(): {
|
|
|
181
181
|
clog: (...args: any[]) => void;
|
|
182
182
|
rlog: (...args: any[]) => void;
|
|
183
183
|
};
|
|
184
|
-
export type TFireWithoutAuth<ActualOpt = ESIRequestOptions> = <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
|
|
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
|
|
184
|
+
export type TFireWithoutAuth<ActualOpt extends Record<string, unknown> = ESIRequestOptions> = <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<ESIRequestOptions> | TESIRequestFunctionMethods2<ESIRequestOptions>, method: Mtd, endpoint: REP, ...opt: HasOpt extends 1 ? [Opt] : [Opt?]) => Promise<Ret>;
|
|
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
187
|
}
|
|
188
188
|
/**
|
|
189
189
|
* Need typescript v5.5 later
|
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
|
|
@@ -347,8 +347,8 @@ type EPOriginNever2 = InferEndpointOrigin<"/characters/{character_id}/fittings/4
|
|
|
347
347
|
const fireWithoutAuth = (fn, method, endpoint, ...opt) => {
|
|
348
348
|
const arg = opt.length ? opt[0] : void 0;
|
|
349
349
|
if (typeof fn === "function") {
|
|
350
|
-
// @ts-expect-error TODO: ts(2345) The argument type does not match the type of the specified parameter
|
|
351
|
-
return fn(method, endpoint, arg);
|
|
350
|
+
// @ts-expect- error TODO: ts(2345) The argument type does not match the type of the specified parameter
|
|
351
|
+
return fn(method, endpoint, /** @type {Parameters<typeof fn>[2]} */ (arg));
|
|
352
352
|
}
|
|
353
353
|
// @ts-expect-error TODO: ts(2345) The argument type does not match the type of the specified parameter
|
|
354
354
|
return fn[method](endpoint, arg);
|
|
@@ -378,6 +378,7 @@ export async function fireRequestsDoesNotRequireAuth(fn) {
|
|
|
378
378
|
clog();
|
|
379
379
|
casefireWithoutAuth: {
|
|
380
380
|
await fireWithoutAuth(fn, "get", `/characters/{character_id}/`, {
|
|
381
|
+
// auth: true, // ✅ At this point, the expected semantic error is successfully triggered as intended.
|
|
381
382
|
pathParams: ID_CCP_Zoetrope
|
|
382
383
|
}).then(log);
|
|
383
384
|
clog('(portrait)');
|
|
@@ -395,8 +396,8 @@ export async function fireRequestsDoesNotRequireAuth(fn) {
|
|
|
395
396
|
pathParams: 12354
|
|
396
397
|
});
|
|
397
398
|
await fireWithoutAuth(fn, "delete", `/characters/${1234}/fittings/${56789}/`, {
|
|
398
|
-
|
|
399
|
-
|
|
399
|
+
auth: true,
|
|
400
|
+
// pathParams: [1234, 56789], // ✅ At this point, the expected semantic error is successfully triggered as intended.
|
|
400
401
|
}).catch(console.log);
|
|
401
402
|
}
|
|
402
403
|
}
|
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.3 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.3 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";
|
|
@@ -163,6 +163,56 @@ 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 K - 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, K extends keyof T,
|
|
194
|
+
Extras = Exclude<ESIEntryKeys, K>
|
|
195
|
+
> = {
|
|
196
|
+
[P in keyof T]: P extends K ? Pick<T, P>[P] :
|
|
197
|
+
P extends Extras ? never : T[P];
|
|
198
|
+
};
|
|
199
|
+
// type RequireEntry = {
|
|
200
|
+
// auth?: true;
|
|
201
|
+
// query?: { test: "pen" | "pencil" };
|
|
202
|
+
// body?: string;
|
|
203
|
+
// pathParams?: string;
|
|
204
|
+
// extra?: string
|
|
205
|
+
// };
|
|
206
|
+
// type Restricted = RestrictKeys<RequireEntry, "auth" | "query">;
|
|
207
|
+
/*/
|
|
208
|
+
type RestrictKeys<
|
|
209
|
+
T, T2,
|
|
210
|
+
K extends keyof T,
|
|
211
|
+
Extras = Exclude<ESIEntryKeys, K>
|
|
212
|
+
> = T2 & {
|
|
213
|
+
[P in keyof T as P extends K ? never : P]: P extends Extras ? never : T[P];
|
|
214
|
+
};
|
|
215
|
+
//*/
|
|
166
216
|
|
|
167
217
|
declare global {
|
|
168
218
|
|
|
@@ -217,7 +267,7 @@ declare global {
|
|
|
217
267
|
REP extends ReplacePathParams<ESIEndpointOf<Mtd>> | ESIEndpointOf<Mtd>,
|
|
218
268
|
EPX extends ResolvedEndpoint<REP, Mtd>,
|
|
219
269
|
PPM extends InferPathParams<REP, EPX>,
|
|
220
|
-
Opt extends IdentifyParameters<Mtd, EPX, ActualOpt
|
|
270
|
+
Opt extends IdentifyParameters<Mtd, EPX, ActualOpt, PPM>,
|
|
221
271
|
Ret extends InferESIResponseResult<Mtd, EPX>,
|
|
222
272
|
HasOpt = HasRequireParams<Mtd, EPX, PPM>,
|
|
223
273
|
>(method: Mtd, endpoint: REP, ...options: HasOpt extends 1 ? [Opt] : [Opt?]) => Promise<Ret>;
|
|
@@ -249,9 +299,9 @@ declare global {
|
|
|
249
299
|
REP extends ReplacePathParams<ESIEndpointOf<Mtd>> | ESIEndpointOf<Mtd>,
|
|
250
300
|
EPX extends ResolvedEndpoint<REP, Mtd>,
|
|
251
301
|
PPM extends InferPathParams<REP, EPX>,
|
|
252
|
-
Opt extends IdentifyParameters<Mtd, EPX, ActualOpt
|
|
302
|
+
Opt extends IdentifyParameters<Mtd, EPX, ActualOpt, PPM>,
|
|
253
303
|
Ret extends InferESIResponseResult<Mtd, EPX>,
|
|
254
|
-
HasOpt = HasRequireParams<Mtd, EPX, PPM>,
|
|
304
|
+
HasOpt extends HasRequireParams<Mtd, EPX, PPM> = HasRequireParams<Mtd, EPX, PPM>,
|
|
255
305
|
>(endpoint: REP, ...options: HasOpt extends 1 ? [Opt] : [Opt?]) => Promise<Ret>;
|
|
256
306
|
|
|
257
307
|
/**
|
|
@@ -426,20 +476,23 @@ declare global {
|
|
|
426
476
|
M extends TESIEntryMethod,
|
|
427
477
|
EPx extends ESIEndpointOf<M> | string,
|
|
428
478
|
Opt extends Record<string, unknown>,
|
|
479
|
+
AdditionalParams,
|
|
429
480
|
Entry = _ESIResponseType<M, EPx>,
|
|
430
|
-
Keys = Exclude<keyof Entry, "result" | "tag" | "cachedSeconds">
|
|
431
|
-
// @ts-expect-error
|
|
432
|
-
> =
|
|
481
|
+
Keys = Exclude<keyof (Entry & AdditionalParams), "result" | "tag" | "cachedSeconds">
|
|
482
|
+
// @ts-expect- error
|
|
483
|
+
> = RestrictKeys<Opt, Keys> & Pick<Entry, Keys> & AdditionalParams;
|
|
433
484
|
/*/
|
|
485
|
+
// DEVNOTE: 2025/3/24
|
|
486
|
+
// The definition is simple and highly maintainable, but it is not possible to reference the `pathParams` property when implementing `TESIRequestFunctionSignature2` etc.
|
|
434
487
|
type IdentifyParameters<
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
488
|
+
M extends TESIEntryMethod,
|
|
489
|
+
EPx extends ESIEndpointOf<M> | string,
|
|
490
|
+
Opt extends Record<string, unknown>,
|
|
491
|
+
AdditionalParams,
|
|
492
|
+
Entry = _ESIResponseType<M, EPx>,
|
|
493
|
+
Keys = Exclude<keyof (Entry & AdditionalParams), "result" | "tag" | "cachedSeconds">
|
|
494
|
+
// @ts-expect- error
|
|
495
|
+
> = RestrictKeys<Opt, Pick<Entry, Keys> & AdditionalParams, Keys>;
|
|
443
496
|
//*/
|
|
444
497
|
|
|
445
498
|
/**
|
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.3 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.3 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";
|