eve-esi-types 3.2.4 → 3.2.7
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/CHANGELOG.md +39 -0
- package/README.md +87 -63
- package/{v2 → dist/v2}/esi-tagged-types.d.ts +77 -44
- package/{v2 → dist/v2}/experimental-esi-types.d.ts +139 -29
- package/dist/v2/index.d.ts +621 -0
- package/{v2 → dist/v2}/response-map.d.ts +1 -1
- package/{v2 → dist/v2}/types-index.d.ts +1 -1
- package/dist/v2/types-util.d.ts +281 -0
- package/dist/v2/util.d.ts +149 -0
- package/lib/console-util.mjs +1 -1
- package/lib/request-api.d.mts +4 -4
- package/lib/request-api.mjs +15 -16
- package/lib/rq-util.d.mts +76 -15
- package/lib/rq-util.mjs +122 -48
- package/lib/tagged-request-api.d.mts +2 -2
- package/lib/tagged-request-api.mjs +2 -2
- package/minimal-rq.mjs +5 -5
- package/package.json +5 -5
- package/request-v3.d.mts +1 -8
- package/request-v3.mjs +16 -19
- package/tagged-rq.mjs +17 -6
- package/{jsconfig.json → tsconfig.json} +5 -5
- package/v2/index.d.ts +0 -515
- package/v2/types-util.d.ts +0 -171
- package/v2/util.d.ts +0 -72
- /package/{v2 → dist/v2}/globals/alliance.d.ts +0 -0
- /package/{v2 → dist/v2}/globals/assets.d.ts +0 -0
- /package/{v2 → dist/v2}/globals/calendar.d.ts +0 -0
- /package/{v2 → dist/v2}/globals/character.d.ts +0 -0
- /package/{v2 → dist/v2}/globals/clones.d.ts +0 -0
- /package/{v2 → dist/v2}/globals/contacts.d.ts +0 -0
- /package/{v2 → dist/v2}/globals/contracts.d.ts +0 -0
- /package/{v2 → dist/v2}/globals/corporation.d.ts +0 -0
- /package/{v2 → dist/v2}/globals/dogma.d.ts +0 -0
- /package/{v2 → dist/v2}/globals/extra-types.d.ts +0 -0
- /package/{v2 → dist/v2}/globals/factionwarfare.d.ts +0 -0
- /package/{v2 → dist/v2}/globals/fittings.d.ts +0 -0
- /package/{v2 → dist/v2}/globals/fleets.d.ts +0 -0
- /package/{v2 → dist/v2}/globals/incursions.d.ts +0 -0
- /package/{v2 → dist/v2}/globals/industry.d.ts +0 -0
- /package/{v2 → dist/v2}/globals/insurance.d.ts +0 -0
- /package/{v2 → dist/v2}/globals/killmails.d.ts +0 -0
- /package/{v2 → dist/v2}/globals/location.d.ts +0 -0
- /package/{v2 → dist/v2}/globals/loyalty.d.ts +0 -0
- /package/{v2 → dist/v2}/globals/mail.d.ts +0 -0
- /package/{v2 → dist/v2}/globals/market.d.ts +0 -0
- /package/{v2 → dist/v2}/globals/planetaryinteraction.d.ts +0 -0
- /package/{v2 → dist/v2}/globals/routes.d.ts +0 -0
- /package/{v2 → dist/v2}/globals/search.d.ts +0 -0
- /package/{v2 → dist/v2}/globals/skills.d.ts +0 -0
- /package/{v2 → dist/v2}/globals/sovereignty.d.ts +0 -0
- /package/{v2 → dist/v2}/globals/status.d.ts +0 -0
- /package/{v2 → dist/v2}/globals/universe.d.ts +0 -0
- /package/{v2 → dist/v2}/globals/wallet.d.ts +0 -0
- /package/{v2 → dist/v2}/globals/wars.d.ts +0 -0
package/tagged-rq.mjs
CHANGED
|
@@ -5,13 +5,14 @@
|
|
|
5
5
|
// https://opensource.org/licenses/mit-license.php
|
|
6
6
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
7
7
|
*/
|
|
8
|
-
/// <reference types="./v2"/>
|
|
8
|
+
/// <reference types="./dist/v2"/>
|
|
9
9
|
/**
|
|
10
10
|
* @file tagged-rq.mts
|
|
11
11
|
* @command node tagged-rq.mjs -x -debug
|
|
12
12
|
*/
|
|
13
13
|
import { esi } from "./lib/tagged-request-api.mjs";
|
|
14
14
|
import * as util from "./lib/rq-util.mjs";
|
|
15
|
+
const ID_CCP_Zoetrope = 2112625428;
|
|
15
16
|
// Furthermore, the endpoint selected is narrowed down by "tags" and "method".
|
|
16
17
|
esi.alliance.get("/alliances/").then(aIds => {
|
|
17
18
|
console.log(`get:alliances, id size=${aIds.length}`);
|
|
@@ -19,7 +20,7 @@ esi.alliance.get("/alliances/").then(aIds => {
|
|
|
19
20
|
// esi.alliance.get(`/alliances/${aid}/`).then(console.log);
|
|
20
21
|
// }
|
|
21
22
|
});
|
|
22
|
-
esi.character.get("/characters/{character_id}/", { pathParams:
|
|
23
|
+
esi.character.get("/characters/{character_id}/", { pathParams: ID_CCP_Zoetrope }).then(console.log);
|
|
23
24
|
esi.universe.post("/universe/ids/", {
|
|
24
25
|
body: ["the forge", "plex"]
|
|
25
26
|
}).then(console.log);
|
|
@@ -27,22 +28,32 @@ esi.universe.post("/universe/names/", {
|
|
|
27
28
|
body: [44992, 434243723, 109299958, 10000002]
|
|
28
29
|
}).then(console.log);
|
|
29
30
|
esi.universe.get("/universe/structures/", { query: { filter: "market" } }).then(console.log);
|
|
31
|
+
esi.wars.get("/wars/", { query: { max_war_id: 20 } }).then(warIds => {
|
|
32
|
+
console.log(`get:alliances, id size=${warIds.length}`);
|
|
33
|
+
// for (const wid of warIds) {
|
|
34
|
+
// esi.wars.get(`/wars/${wid}/`).then(console.log);
|
|
35
|
+
// }
|
|
36
|
+
});
|
|
37
|
+
esi.character.post("/characters/affiliation/", {
|
|
38
|
+
body: [ID_CCP_Zoetrope]
|
|
39
|
+
}).then(console.log);
|
|
30
40
|
// node tagged-rq.mjs -x -debug -withError
|
|
31
41
|
if (util.is("withError")) {
|
|
32
|
-
esi.assets.get(
|
|
42
|
+
esi.assets.get(`/characters/${ID_CCP_Zoetrope}/assets/`, {
|
|
33
43
|
auth: true
|
|
34
44
|
}).then(console.log).catch(console.log);
|
|
35
|
-
esi.mail.post("/characters/
|
|
45
|
+
esi.mail.post("/characters/{character_id}/mail/", ({
|
|
36
46
|
auth: true,
|
|
47
|
+
pathParams: ID_CCP_Zoetrope, // ✅ At this point, the expected semantic error is successfully triggered as intended.
|
|
37
48
|
body: {
|
|
38
49
|
subject: "test!!",
|
|
39
50
|
body: "",
|
|
40
51
|
recipients: [{
|
|
41
|
-
recipient_id:
|
|
52
|
+
recipient_id: ID_CCP_Zoetrope, recipient_type: "character"
|
|
42
53
|
}]
|
|
43
54
|
},
|
|
44
55
|
// token: "s.s.s"
|
|
45
|
-
})).then(console.log).catch(console.log);
|
|
56
|
+
}) /* satisfies Pick<TESIResponsePostEntry<"/characters/{character_id}/mail/">, "auth" | "body"> & { pathParams: number } */).then(console.log).catch(console.log);
|
|
46
57
|
esi.fittings.delete("/characters/1234/fittings/56789/", {
|
|
47
58
|
// pathParams: [1234, 56789], // ✅ At this point, the expected semantic error is successfully triggered as intended.
|
|
48
59
|
auth: true
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/tsconfig",
|
|
3
3
|
"compilerOptions": {
|
|
4
|
-
//
|
|
4
|
+
// "skipDefaultLibCheck": true,
|
|
5
5
|
// "skipLibCheck": true,
|
|
6
6
|
// This flag is required
|
|
7
7
|
"checkJs": true,
|
|
8
8
|
// This flag is required
|
|
9
9
|
"strict": true,
|
|
10
10
|
"noEmit": true,
|
|
11
|
-
"
|
|
12
|
-
// "
|
|
11
|
+
"allowJs": true,
|
|
12
|
+
// "listFiles": true,
|
|
13
13
|
// "target": "esnext",
|
|
14
14
|
// "module": "esnext",
|
|
15
|
-
|
|
15
|
+
"diagnostics": true,
|
|
16
16
|
// "moduleResolution": "node",
|
|
17
17
|
"rootDirs": [
|
|
18
18
|
"./"
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"./*.mjs",
|
|
23
23
|
"./lib/*.mjs",
|
|
24
24
|
// "./lib/*.d.mts",
|
|
25
|
-
"./v2/**/*.d.ts"
|
|
25
|
+
"./dist/v2/**/*.d.ts"
|
|
26
26
|
],
|
|
27
27
|
"exclude": [
|
|
28
28
|
]
|
package/v2/index.d.ts
DELETED
|
@@ -1,515 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
3
|
-
// Copyright (C) 2025 jeffy-g <hirotom1107@gmail.com>
|
|
4
|
-
// Released under the MIT license
|
|
5
|
-
// https://opensource.org/licenses/mit-license.php
|
|
6
|
-
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
7
|
-
*/
|
|
8
|
-
/**
|
|
9
|
-
* THIS DTS IS AUTO GENERATED, DO NOT EDIT
|
|
10
|
-
*
|
|
11
|
-
* @file eve-esi-types/v2/index.d.ts
|
|
12
|
-
* @summary This file is auto-generated and defines version 3.2.4 of the EVE Online ESI response types.
|
|
13
|
-
*/
|
|
14
|
-
import type { TESIResponseOKMap } from "./response-map.d.ts";
|
|
15
|
-
import type { PickPathParameters, InferKeysLen } from "./util.d.ts";
|
|
16
|
-
import type {
|
|
17
|
-
_ESIResponseType,
|
|
18
|
-
_IfNeedPathParams,
|
|
19
|
-
TPathParamsNever,
|
|
20
|
-
// ESIEndpointUnions,
|
|
21
|
-
// IESIRequestFunction2,
|
|
22
|
-
// InferESIResponseResultEX,
|
|
23
|
-
// TESICachedSeconds, TESIRequestFunctionMethods2,
|
|
24
|
-
// __IdentifyParameters, __InferESIResponseResult,
|
|
25
|
-
} from "./types-util.d.ts";
|
|
26
|
-
export type * from "./response-map.d.ts";
|
|
27
|
-
export type * from "./types-util.d.ts";
|
|
28
|
-
export type * from "./util.d.ts";
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
32
|
-
// Internal types
|
|
33
|
-
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
34
|
-
/**
|
|
35
|
-
* Defines the keys used in ESI entries.
|
|
36
|
-
*/
|
|
37
|
-
type ESIEntryKeys = "auth" | "query" | "body" | "pathParams";
|
|
38
|
-
/**
|
|
39
|
-
* Restricts the keys of a type to the specified ones while excluding extra keys.
|
|
40
|
-
*
|
|
41
|
-
* This utility type is designed to enforce stricter semantics by marking unwanted keys as `never`.
|
|
42
|
-
*
|
|
43
|
-
* @template T - The original type to be constrained.
|
|
44
|
-
* @template T2 - The type to merge with the constrained type.
|
|
45
|
-
* @template RequireKeys - The keys to retain in the resulting type.
|
|
46
|
-
* @template Extras - Automatically derived keys to exclude from the resulting type.
|
|
47
|
-
*
|
|
48
|
-
* @example
|
|
49
|
-
* ```ts
|
|
50
|
-
* type Original = { auth?: string; query?: string; body?: string; pathParams?: string; extra?: string };
|
|
51
|
-
* type Required = { auth: true; query: { test: "pen" | "pencil" } };
|
|
52
|
-
* type Restricted = RestrictKeys<Original, Required, "auth" | "query">;
|
|
53
|
-
* // Result: { auth: true; query: { test: "pen" | "pencil" }; body?: undefined; pathParams?: undefined; extra?: string | undefined }
|
|
54
|
-
* ```
|
|
55
|
-
*/
|
|
56
|
-
//* ctt
|
|
57
|
-
type RestrictKeys<
|
|
58
|
-
T, RequireKeys extends keyof T,
|
|
59
|
-
Extras = Exclude<ESIEntryKeys, RequireKeys>
|
|
60
|
-
> = {
|
|
61
|
-
[P in keyof T]: P extends Extras ? never : T[P];
|
|
62
|
-
};
|
|
63
|
-
// type RequireEntry = {
|
|
64
|
-
// auth?: true;
|
|
65
|
-
// query?: { test: "pen" | "pencil" };
|
|
66
|
-
// body?: string;
|
|
67
|
-
// pathParams?: string;
|
|
68
|
-
// extra?: string
|
|
69
|
-
// };
|
|
70
|
-
// type Restricted = RestrictKeys<RequireEntry, "auth" | "query">;
|
|
71
|
-
/*/
|
|
72
|
-
type RestrictKeys<
|
|
73
|
-
T, T2,
|
|
74
|
-
K extends keyof T,
|
|
75
|
-
Extras = Exclude<ESIEntryKeys, K>
|
|
76
|
-
> = T2 & {
|
|
77
|
-
[P in keyof T as P extends K ? never : P]: P extends Extras ? never : T[P];
|
|
78
|
-
};
|
|
79
|
-
//*/
|
|
80
|
-
|
|
81
|
-
declare global {
|
|
82
|
-
|
|
83
|
-
type __ShiftType = 1;
|
|
84
|
-
/**
|
|
85
|
-
* Marks specific properties of a type as required.
|
|
86
|
-
*
|
|
87
|
-
* @template T - The original type.
|
|
88
|
-
* @template K - The keys of the properties to mark as required.
|
|
89
|
-
*
|
|
90
|
-
* @example
|
|
91
|
-
* ```ts
|
|
92
|
-
* type Original = { a?: number; b?: string; c: boolean };
|
|
93
|
-
* type RequiredA = RequireThese<Original, 'a'>;
|
|
94
|
-
* // Result: { a: number; b?: string; c: boolean }
|
|
95
|
-
* ```
|
|
96
|
-
* @see Documentation of [`RequireThese`](https://github.com/jeffy-g/eve-esi-types/blob/master/docs/v2/require-these.md)
|
|
97
|
-
*/
|
|
98
|
-
type RequireThese<T, K extends keyof T> = {
|
|
99
|
-
[P in keyof T as P extends K ? P : never]-?: T[P];
|
|
100
|
-
} & {
|
|
101
|
-
[P in keyof T as P extends K ? never : P]: T[P];
|
|
102
|
-
};
|
|
103
|
-
|
|
104
|
-
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
105
|
-
// Version 3 types
|
|
106
|
-
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
107
|
-
/**
|
|
108
|
-
* ### ESI request function with real endpoint signature
|
|
109
|
-
*
|
|
110
|
-
* TESIRequestFunctionSignature2 is a type that defines the signature of an ESI request function
|
|
111
|
-
* where the endpoint can be a real endpoint or a parameterized endpoint.
|
|
112
|
-
*
|
|
113
|
-
* This function sends a request to a specified endpoint and returns a response.
|
|
114
|
-
*
|
|
115
|
-
* @template ActualOpt - The actual type of the option.
|
|
116
|
-
* @template Mtd - The HTTP method to use for the request
|
|
117
|
-
* @template REP - The real path of the ESI endpoint to send the request to
|
|
118
|
-
* @template EPX - The parameterized path of the ESI endpoint to send the request to
|
|
119
|
-
* @template PPM - Parameters to include in the request if the endpoint is parameterized
|
|
120
|
-
* @template Opt - Options to include in the request. If there is a required parameter, its type will be merged with `ActualOpt`
|
|
121
|
-
* @template Ret - The response type
|
|
122
|
-
*
|
|
123
|
-
* @param method - The HTTP method to use for the request (e.g., "get", "post").
|
|
124
|
-
* @param endpoint - The real path of the ESI endpoint to send the request to.
|
|
125
|
-
* @param options - An optional object containing additional options for the request. If the endpoint has required parameters, this parameter must be provided.
|
|
126
|
-
*
|
|
127
|
-
* @returns A Promise object containing the response data, with the type inferred based on the method and endpoint.
|
|
128
|
-
*
|
|
129
|
-
* @remarks
|
|
130
|
-
* The `...options: HasOpt extends 1 ? [Opt] : [Opt?]` parameter is defined this way to enforce that if the endpoint has required parameters,
|
|
131
|
-
* the `options` parameter must be provided. If there are no required parameters, the `options` parameter is optional.
|
|
132
|
-
*/
|
|
133
|
-
type TESIRequestFunctionSignature2<ActualOpt extends Record<string, unknown>> = <
|
|
134
|
-
Mtd extends TESIEntryMethod,
|
|
135
|
-
REP extends ReplacePathParams<ESIEndpointOf<Mtd>> | ESIEndpointOf<Mtd>,
|
|
136
|
-
EPX extends ResolvedEndpoint<REP, Mtd>,
|
|
137
|
-
PPM extends InferPathParams<REP, EPX>,
|
|
138
|
-
Opt extends IdentifyParameters<Mtd, EPX, ActualOpt, PPM>,
|
|
139
|
-
Ret extends InferESIResponseResult<Mtd, EPX>,
|
|
140
|
-
HasOpt = HasRequireParams<Mtd, EPX, PPM>,
|
|
141
|
-
>(method: Mtd, endpoint: REP, ...options: HasOpt extends 1 ? [Opt] : [Opt?]) => Promise<Ret>;
|
|
142
|
-
|
|
143
|
-
/**
|
|
144
|
-
* A function signature type for making enhanced ESI requests.
|
|
145
|
-
*
|
|
146
|
-
* This type extends the base ESI request function signature by injecting a prepended parameter to allow for extra
|
|
147
|
-
* context or pre-processing before performing the request. It provides a highly generic interface that adapts to the
|
|
148
|
-
* chosen endpoint method, endpoint configuration, and additional options, making it ideal for advanced API interactions.
|
|
149
|
-
*
|
|
150
|
-
* Generic Parameters:
|
|
151
|
-
* @template PrependParam - The type of the additional parameter that is injected at the beginning of the function call.
|
|
152
|
-
* @template ActualOpt - An object representing the default options (typically extending ESIRequestOptions) used for the request.
|
|
153
|
-
*
|
|
154
|
-
* Function Generic Parameters:
|
|
155
|
-
* @template Mtd - The ESI request method type (e.g., GET, POST) as defined in TESIEntryMethod.
|
|
156
|
-
* @template REP - The endpoint type, which can be either a version with replaced path parameters (via ReplacePathParams)
|
|
157
|
-
* or the raw ESIEndpointOf<Mtd> type.
|
|
158
|
-
* @template EPX - The resolved endpoint type derived from REP and Mtd.
|
|
159
|
-
* @template PPM - The type representing the inferred path parameters extracted from REP and EPX.
|
|
160
|
-
* @template Opt - The type for additional request options, identified based on the method (Mtd), endpoint (EPX), the
|
|
161
|
-
* default options (ActualOpt), and inferred path parameters (PPM).
|
|
162
|
-
* @template Ret - The type of the response result from the ESI request, inferred from the method and endpoint.
|
|
163
|
-
* @template HasOpt - An internal flag used to determine whether request options (Opt) are required (1) or optional.
|
|
164
|
-
*
|
|
165
|
-
* Parameters:
|
|
166
|
-
* @param {PrependParam} prependParam - A prepended parameter providing additional context or configuration for the request.
|
|
167
|
-
* @param {Mtd} method - The ESI request method.
|
|
168
|
-
* @param {REP} endpoint - The API endpoint, which might include path parameter replacements.
|
|
169
|
-
* @param {...(HasOpt extends 1 ? [Opt] : [Opt?])} options - Additional options for the request; required if HasOpt is 1,
|
|
170
|
-
* otherwise optional.
|
|
171
|
-
*
|
|
172
|
-
* @returns {Promise<Ret>} A promise that resolves with the result type `Ret`, representing the response data from the ESI endpoint.
|
|
173
|
-
* @see Documentation of [`TESIEnhancedRequestFunctionSignature`](https://github.com/jeffy-g/eve-esi-types/blob/master/docs/v3/esi-enhanced-function-signature.md)
|
|
174
|
-
*/
|
|
175
|
-
type TESIEnhancedRequestFunctionSignature<
|
|
176
|
-
PrependParam extends unknown, ActualOpt extends Record<string, unknown>
|
|
177
|
-
> = <
|
|
178
|
-
Mtd extends TESIEntryMethod,
|
|
179
|
-
REP extends ReplacePathParams<ESIEndpointOf<Mtd>> | ESIEndpointOf<Mtd>,
|
|
180
|
-
EPX extends ResolvedEndpoint<REP, Mtd>,
|
|
181
|
-
PPM extends InferPathParams<REP, EPX>,
|
|
182
|
-
Opt extends IdentifyParameters<Mtd, EPX, ActualOpt, PPM>,
|
|
183
|
-
Ret extends InferESIResponseResult<Mtd, EPX>,
|
|
184
|
-
HasOpt = HasRequireParams<Mtd, EPX, PPM>
|
|
185
|
-
>(
|
|
186
|
-
prependParam: PrependParam,
|
|
187
|
-
method: Mtd, endpoint: REP, ...options: HasOpt extends 1 ? [Opt] : [Opt?]
|
|
188
|
-
) => Promise<Ret>;
|
|
189
|
-
|
|
190
|
-
/**
|
|
191
|
-
* Represents a function that can make ESI requests for a specific HTTP method.
|
|
192
|
-
*
|
|
193
|
-
* This type is used to define functions that send requests to specific ESI endpoints using a given HTTP method.
|
|
194
|
-
*
|
|
195
|
-
* @template Mtd - The HTTP method to use for the request.
|
|
196
|
-
* @template ActualOpt - The actual type of the options.
|
|
197
|
-
*
|
|
198
|
-
* @template REP - The real path of the ESI endpoint to send the request to.
|
|
199
|
-
* @template EPX - The parameterized path of the ESI endpoint to send the request to.
|
|
200
|
-
* @template PPM - Parameters to include in the request if the endpoint is parameterized.
|
|
201
|
-
* @template Opt - Options to include in the request. If there is a required parameter, its type will be merged with `ActualOpt`.
|
|
202
|
-
* @template Ret - The response type.
|
|
203
|
-
*
|
|
204
|
-
* @param endpoint - The real path of the ESI endpoint to send the request to.
|
|
205
|
-
* @param options - An optional object containing additional options for the request. If the endpoint has required parameters, this parameter must be provided.
|
|
206
|
-
*
|
|
207
|
-
* @returns A Promise object containing the response data, with the type inferred based on the method and endpoint.
|
|
208
|
-
*
|
|
209
|
-
* @remarks
|
|
210
|
-
* The `...options: HasOpt extends 1 ? [Opt] : [Opt?]` parameter is defined this way to enforce that if the endpoint has required parameters,
|
|
211
|
-
* the `options` parameter must be provided. If there are no required parameters, the `options` parameter is optional.
|
|
212
|
-
*/
|
|
213
|
-
type TESIRequestFunctionEachMethod2<Mtd extends TESIEntryMethod, ActualOpt extends Record<string, unknown>> = <
|
|
214
|
-
REP extends ReplacePathParams<ESIEndpointOf<Mtd>> | ESIEndpointOf<Mtd>,
|
|
215
|
-
EPX extends ResolvedEndpoint<REP, Mtd>,
|
|
216
|
-
PPM extends InferPathParams<REP, EPX>,
|
|
217
|
-
Opt extends IdentifyParameters<Mtd, EPX, ActualOpt, PPM>,
|
|
218
|
-
Ret extends InferESIResponseResult<Mtd, EPX>,
|
|
219
|
-
HasOpt extends HasRequireParams<Mtd, EPX, PPM> = HasRequireParams<Mtd, EPX, PPM>,
|
|
220
|
-
>(endpoint: REP, ...options: HasOpt extends 1 ? [Opt] : [Opt?]) => Promise<Ret>;
|
|
221
|
-
|
|
222
|
-
/**
|
|
223
|
-
* Replaces path parameters in a string with numbers.
|
|
224
|
-
*
|
|
225
|
-
* @template T - The string representing the endpoint path.
|
|
226
|
-
* @type {string}
|
|
227
|
-
* @example
|
|
228
|
-
* ```ts
|
|
229
|
-
* type Example = ReplacePathParams<"/characters/{character_id}/fittings/{fitting_id}/">;
|
|
230
|
-
* // Result: `/characters/${number}/fittings/${number}/`
|
|
231
|
-
* ```
|
|
232
|
-
* @see Documentation of [`ReplacePathParams`](https://github.com/jeffy-g/eve-esi-types/blob/master/docs/v3/replace-path-params.md)
|
|
233
|
-
*/
|
|
234
|
-
type ReplacePathParams<T extends unknown> = T extends `${infer Start}{${infer Param}}${infer End}`
|
|
235
|
-
? `${Start}${number}${ReplacePathParams<End>}` : T;
|
|
236
|
-
// type XEPP = ESIEndpointOf<"delete">
|
|
237
|
-
// // incomplete
|
|
238
|
-
// type Example2 = ReplacePathParams<"/characters/1234/fittings/{fitting_id}/">;
|
|
239
|
-
// // Result: `characters/${number}/fittings/${number}/`
|
|
240
|
-
// type Example3 = ReplacePathParams<"/characters/{character_id}/fittings/{fitting_id}/">;
|
|
241
|
-
|
|
242
|
-
/**
|
|
243
|
-
* Infers the path parameters based on the real endpoint and the resolved endpoint.
|
|
244
|
-
*
|
|
245
|
-
* @template RealEP - The real endpoint path.
|
|
246
|
-
* @template EPx - The resolved endpoint path.
|
|
247
|
-
* @returns {TPathParamsNever | _IfNeedPathParams<EPx>}
|
|
248
|
-
* @see {@link _IfNeedPathParams}
|
|
249
|
-
* @see {@link TPathParamsNever}
|
|
250
|
-
* @see Documentation of [`InferPathParams`](https://github.com/jeffy-g/eve-esi-types/blob/master/docs/v3/infer-path-params.md)
|
|
251
|
-
* @date 2025/3/17
|
|
252
|
-
*/
|
|
253
|
-
type InferPathParams<
|
|
254
|
-
RealEP extends unknown, EPx extends unknown
|
|
255
|
-
> = RealEP extends EPx ? _IfNeedPathParams<EPx> : TPathParamsNever;
|
|
256
|
-
|
|
257
|
-
/**
|
|
258
|
-
* Infers the original endpoint based on the real endpoint and the HTTP method.
|
|
259
|
-
*
|
|
260
|
-
* This type maps the real endpoint to its corresponding parameterized endpoint
|
|
261
|
-
* by checking if the real endpoint matches the pattern of any parameterized endpoint.
|
|
262
|
-
*
|
|
263
|
-
* @template RealEP - The real endpoint path.
|
|
264
|
-
* @template M - The HTTP method to use for the request.
|
|
265
|
-
* @template Endpoints - The possible endpoints for the given method.
|
|
266
|
-
*
|
|
267
|
-
* @example
|
|
268
|
-
* ```ts
|
|
269
|
-
* type Original = InferEndpointOrigin<"/characters/123/fittings/456/", "delete">;
|
|
270
|
-
* // Result: "/characters/{character_id}/fittings/{fitting_id}/"
|
|
271
|
-
* ```
|
|
272
|
-
* @see {@link ESIEndpointOf}
|
|
273
|
-
* @see {@link ReplacePathParams}
|
|
274
|
-
* @see Documentation of [`InferEndpointOrigin`](https://github.com/jeffy-g/eve-esi-types/blob/master/docs/v3/infer-endpoint-origin.md)
|
|
275
|
-
*/
|
|
276
|
-
type InferEndpointOrigin<
|
|
277
|
-
RealEP extends unknown, M extends TESIEntryMethod,
|
|
278
|
-
Endpoints extends ESIEndpointOf<M> = ESIEndpointOf<M>
|
|
279
|
-
> = {
|
|
280
|
-
[EP in Endpoints]: RealEP extends ReplacePathParams<EP>
|
|
281
|
-
? EP : never;
|
|
282
|
-
}[Endpoints];
|
|
283
|
-
/**
|
|
284
|
-
* Determines the resolved endpoint based on the real endpoint and the method.
|
|
285
|
-
*
|
|
286
|
-
* @template RealEP - The real endpoint path.
|
|
287
|
-
* @template M - The HTTP method to use for the request.
|
|
288
|
-
*
|
|
289
|
-
* @example
|
|
290
|
-
* ```ts
|
|
291
|
-
* type Resolved = ResolvedEndpoint<"/characters/123/fittings/456/", "delete">;
|
|
292
|
-
* // Result: "/characters/{character_id}/fittings/{fitting_id}/"
|
|
293
|
-
* ```
|
|
294
|
-
* @see {@link InferEndpointOrigin}
|
|
295
|
-
* @see Documentation of [`ResolvedEndpoint`](https://github.com/jeffy-g/eve-esi-types/blob/master/docs/v3/resolved-endpoint.md)
|
|
296
|
-
*/
|
|
297
|
-
type ResolvedEndpoint<
|
|
298
|
-
RealEP extends unknown, M extends TESIEntryMethod,
|
|
299
|
-
> = InferEndpointOrigin<RealEP, M> extends never ? RealEP: InferEndpointOrigin<RealEP, M>;
|
|
300
|
-
|
|
301
|
-
/**
|
|
302
|
-
* Picks the required parameters from an entry type, including additional parameters.
|
|
303
|
-
*
|
|
304
|
-
* This type excludes the keys "result", "tag", and "cachedSeconds" from the entry type and the additional parameters,
|
|
305
|
-
* and returns the remaining keys as the required parameters.
|
|
306
|
-
*
|
|
307
|
-
* @template M - The HTTP method to use for the request.
|
|
308
|
-
* @template EPx - The endpoint path.
|
|
309
|
-
* @template AdditionalParams - Additional parameters to include in the check.
|
|
310
|
-
* @template Entry - The entry type to pick parameters from.
|
|
311
|
-
*
|
|
312
|
-
* @example
|
|
313
|
-
* ```ts
|
|
314
|
-
* type ExampleEntry = { result: string, tag: string, cachedSeconds: number, auth: string };
|
|
315
|
-
* type RequiredParams = PickRequireParams<"get", "/example/endpoint", { auth: string }, ExampleEntry>;
|
|
316
|
-
* // Result: "auth"
|
|
317
|
-
* ```
|
|
318
|
-
* @see {@link ESIEndpointOf}
|
|
319
|
-
* @see {@link _ESIResponseType}
|
|
320
|
-
* @see Documentation of [`PickRequireParams`](https://github.com/jeffy-g/eve-esi-types/blob/master/docs/v3/pick-require-params.md)
|
|
321
|
-
*/
|
|
322
|
-
type PickRequireParams<
|
|
323
|
-
M extends TESIEntryMethod,
|
|
324
|
-
EPx extends ESIEndpointOf<M> | string,
|
|
325
|
-
AdditionalParams,
|
|
326
|
-
Entry = _ESIResponseType<M, EPx>
|
|
327
|
-
> = Exclude<keyof (Entry & AdditionalParams), "result" | "tag" | "cachedSeconds">;
|
|
328
|
-
/**
|
|
329
|
-
* Determines if the given entry has required parameters, including additional options.
|
|
330
|
-
*
|
|
331
|
-
* This type checks if an entry has any required parameters by excluding the keys "result", "tag", and "cachedSeconds".
|
|
332
|
-
* If any keys remain after this exclusion, it means the entry has required parameters.
|
|
333
|
-
*
|
|
334
|
-
* @template M - The HTTP method to use for the request.
|
|
335
|
-
* @template EPx - The endpoint path.
|
|
336
|
-
* @template AdditionalParams - Additional parameters to include in the check.
|
|
337
|
-
*
|
|
338
|
-
* @example
|
|
339
|
-
* ```ts
|
|
340
|
-
* type ExampleEntry = { result: string, tag: string, cachedSeconds: number, auth: string };
|
|
341
|
-
* type HasRequired = HasRequireParams<"get", "/example/endpoint", { auth: string }>; // 1
|
|
342
|
-
* ```
|
|
343
|
-
* @see {@link ESIEndpointOf}
|
|
344
|
-
* @see {@link PickRequireParams}
|
|
345
|
-
* @see Documentation of [`HasRequireParams`](https://github.com/jeffy-g/eve-esi-types/blob/master/docs/v3/has-require-params.md)
|
|
346
|
-
*/
|
|
347
|
-
type HasRequireParams<
|
|
348
|
-
M extends TESIEntryMethod,
|
|
349
|
-
EPx extends ESIEndpointOf<M> | string,
|
|
350
|
-
AdditionalParams,
|
|
351
|
-
> = PickRequireParams<M, EPx, AdditionalParams> extends never ? 0 : 1;
|
|
352
|
-
|
|
353
|
-
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
354
|
-
// Version 2 types
|
|
355
|
-
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
356
|
-
/**
|
|
357
|
-
* If `EP` (endpoint) is a parameterized path, determines the required number of replacements.
|
|
358
|
-
*
|
|
359
|
-
* @template EP The string representing the endpoint path.
|
|
360
|
-
* @template Opt The type to return if `EP` is not parameterized.
|
|
361
|
-
* @returns {number | [number, number] | Opt}
|
|
362
|
-
* Returns `number` if there is one parameter, `[number, number]` if there are two parameters, otherwise `Opt`.
|
|
363
|
-
* @see Documentation of [`IfParameterizedPath`](https://github.com/jeffy-g/eve-esi-types/blob/master/docs/v2/if-parameterized-path.md)
|
|
364
|
-
*/
|
|
365
|
-
type IfParameterizedPath<EP extends unknown, Opt = never> = EP extends `${string}/{${string}}${string}`
|
|
366
|
-
? PickPathParameters<EP> extends never
|
|
367
|
-
? Opt : InferKeysLen<PickPathParameters<EP>> extends 1
|
|
368
|
-
? number : [number, number]
|
|
369
|
-
: Opt;
|
|
370
|
-
|
|
371
|
-
/**
|
|
372
|
-
* Identifies the required parameters for a given entry type, including additional options.
|
|
373
|
-
*
|
|
374
|
-
* This type combines the required parameters from the entry type and the additional options,
|
|
375
|
-
* ensuring that all required parameters are marked as required.
|
|
376
|
-
*
|
|
377
|
-
* @template M - The HTTP method to use for the request.
|
|
378
|
-
* @template EPx - The endpoint path.
|
|
379
|
-
* @template Opt - The type of the additional options.
|
|
380
|
-
* @template Entry - The entry type to identify parameters for.
|
|
381
|
-
* @template RequireKeys - The keys of the entry type that are required parameters.
|
|
382
|
-
*
|
|
383
|
-
* @example
|
|
384
|
-
* ```ts
|
|
385
|
-
* type ExampleEntry = { result: string, tag: string, cachedSeconds: number, auth: string };
|
|
386
|
-
* type ExampleOpt = { auth: string };
|
|
387
|
-
* type IdentifiedParams = IdentifyParameters<"get", "/example/endpoint", ExampleOpt, ExampleEntry>;
|
|
388
|
-
* // Result: { auth: string } & { auth: string }
|
|
389
|
-
* ```
|
|
390
|
-
* @see {@link RequireThese}
|
|
391
|
-
* @see {@link ESIEndpointOf}
|
|
392
|
-
* @see {@link _ESIResponseType}
|
|
393
|
-
* @see Documentation of [`IdentifyParameters`](https://github.com/jeffy-g/eve-esi-types/blob/master/docs/v2/identify-parameters.md)
|
|
394
|
-
*/
|
|
395
|
-
//* ctt
|
|
396
|
-
type IdentifyParameters<
|
|
397
|
-
M extends TESIEntryMethod,
|
|
398
|
-
EPx extends ESIEndpointOf<M> | string,
|
|
399
|
-
Opt extends Record<string, unknown>,
|
|
400
|
-
AdditionalParams,
|
|
401
|
-
Entry = _ESIResponseType<M, EPx> & AdditionalParams,
|
|
402
|
-
RequireKeys = Exclude<keyof (Entry & AdditionalParams), "result" | "tag" | "cachedSeconds">
|
|
403
|
-
// @ts-expect-error
|
|
404
|
-
> = RestrictKeys<Opt, RequireKeys> & Pick<Entry, RequireKeys> & AdditionalParams;
|
|
405
|
-
/*/
|
|
406
|
-
// DEVNOTE: 2025/3/24
|
|
407
|
-
// The definition is simple and highly maintainable, but it is not possible to reference the `pathParams` property when implementing `TESIRequestFunctionSignature2` etc.
|
|
408
|
-
type IdentifyParameters<
|
|
409
|
-
M extends TESIEntryMethod,
|
|
410
|
-
EPx extends ESIEndpointOf<M> | string,
|
|
411
|
-
Opt extends Record<string, unknown>,
|
|
412
|
-
AdditionalParams,
|
|
413
|
-
Entry = _ESIResponseType<M, EPx>,
|
|
414
|
-
Keys = Exclude<keyof (Entry & AdditionalParams), "result" | "tag" | "cachedSeconds">
|
|
415
|
-
// @ts-expect- error
|
|
416
|
-
> = RestrictKeys<Opt, Pick<Entry, Keys> & AdditionalParams, Keys>;
|
|
417
|
-
//*/
|
|
418
|
-
|
|
419
|
-
/**
|
|
420
|
-
* Infers the result type of an ESI response based on the method and endpoint.
|
|
421
|
-
*
|
|
422
|
-
* @template M - The HTTP method to use for the request.
|
|
423
|
-
* @template EPx - The endpoint path.
|
|
424
|
-
*
|
|
425
|
-
* @example
|
|
426
|
-
* ```ts
|
|
427
|
-
* type Result = InferESIResponseResult<"get", "/characters/{character_id}/">;
|
|
428
|
-
* // Result: The inferred type of the response for the given method and endpoint.
|
|
429
|
-
* ```
|
|
430
|
-
* @see {@link ESIEndpointOf}
|
|
431
|
-
* @see {@link _ESIResponseType}
|
|
432
|
-
* @see Documentation of [`InferESIResponseResult`](https://github.com/jeffy-g/eve-esi-types/blob/master/docs/v2/infer-esi-response-result.md)
|
|
433
|
-
*/
|
|
434
|
-
type InferESIResponseResult<
|
|
435
|
-
M extends TESIEntryMethod,
|
|
436
|
-
EPx extends ESIEndpointOf<M> | string
|
|
437
|
-
> = _ESIResponseType<M, EPx> extends { result: infer U } ? U : never;
|
|
438
|
-
/*
|
|
439
|
-
*/
|
|
440
|
-
|
|
441
|
-
// declare const NO_CONTENT_RESPONSE: unique symbol;
|
|
442
|
-
// type NoContentResponse = {
|
|
443
|
-
// [NO_CONTENT_RESPONSE]: never;
|
|
444
|
-
// };
|
|
445
|
-
/**
|
|
446
|
-
* Represents a response with no content (HTTP status 204).
|
|
447
|
-
*/
|
|
448
|
-
type NoContentResponse = { /* status: 204 */ } & { __status: 204 };
|
|
449
|
-
|
|
450
|
-
/**
|
|
451
|
-
* Represents the HTTP methods supported by ESI.
|
|
452
|
-
*
|
|
453
|
-
* ```ts
|
|
454
|
-
* "get" | "post" | "put" | "delete"
|
|
455
|
-
* ```
|
|
456
|
-
*/
|
|
457
|
-
type TESIEntryMethod = keyof TESIResponseOKMap;
|
|
458
|
-
|
|
459
|
-
/**
|
|
460
|
-
* Represents endpoints using `TESIEntryMethod`.
|
|
461
|
-
* @date 2025/3/16
|
|
462
|
-
*/
|
|
463
|
-
type ESIEndpointOf<M extends TESIEntryMethod> = keyof TESIResponseOKMap[M];
|
|
464
|
-
/**
|
|
465
|
-
* Represents the endpoints for the "get" method.
|
|
466
|
-
*/
|
|
467
|
-
type TEndPointGet = ESIEndpointOf<"get">;
|
|
468
|
-
/**
|
|
469
|
-
* Represents the endpoints for the "post" method.
|
|
470
|
-
*/
|
|
471
|
-
type TEndPointPost = ESIEndpointOf<"post">;
|
|
472
|
-
/**
|
|
473
|
-
* Represents the endpoints for the "put" method.
|
|
474
|
-
*/
|
|
475
|
-
type TEndPointPut = ESIEndpointOf<"put">;
|
|
476
|
-
/**
|
|
477
|
-
* Represents the endpoints for the "delete" method.
|
|
478
|
-
*/
|
|
479
|
-
type TEndPointDelete = ESIEndpointOf<"delete">;
|
|
480
|
-
/**
|
|
481
|
-
* Union of all `ESIEndpointOf<TESIEntryMethod>`
|
|
482
|
-
* @date 2025/4/12
|
|
483
|
-
*/
|
|
484
|
-
type ESIEndpointAll = {
|
|
485
|
-
[M in TESIEntryMethod]: ESIEndpointOf<M>;
|
|
486
|
-
}[TESIEntryMethod];
|
|
487
|
-
|
|
488
|
-
// type TESIResponseEntries<
|
|
489
|
-
// M extends TESIEntryMethod, EP extends ESIEndpointOf<M>
|
|
490
|
-
// > = TESIResponseOKMap[M][EP];
|
|
491
|
-
/**
|
|
492
|
-
* Represents the entry details for the "get" method.
|
|
493
|
-
*
|
|
494
|
-
* @template K - The endpoint key.
|
|
495
|
-
*/
|
|
496
|
-
type TESIResponseGetEntry<K extends TEndPointGet> = TESIResponseOKMap["get"][K];
|
|
497
|
-
/**
|
|
498
|
-
* Represents the entry details for the "put" method.
|
|
499
|
-
*
|
|
500
|
-
* @template K - The endpoint key.
|
|
501
|
-
*/
|
|
502
|
-
type TESIResponsePutEntry<K extends TEndPointPut> = TESIResponseOKMap["put"][K];
|
|
503
|
-
/**
|
|
504
|
-
* Represents the entry details for the "post" method.
|
|
505
|
-
*
|
|
506
|
-
* @template K - The endpoint key.
|
|
507
|
-
*/
|
|
508
|
-
type TESIResponsePostEntry<K extends TEndPointPost> = TESIResponseOKMap["post"][K];
|
|
509
|
-
/**
|
|
510
|
-
* Represents the entry details for the "delete" method.
|
|
511
|
-
*
|
|
512
|
-
* @template K - The endpoint key.
|
|
513
|
-
*/
|
|
514
|
-
type TESIResponseDeleteEntry<K extends TEndPointDelete> = TESIResponseOKMap["delete"][K];
|
|
515
|
-
}
|