eve-esi-types 3.2.1 → 3.2.2
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 +27 -8
- package/package.json +1 -1
- package/v2/esi-tagged-types.d.ts +1 -1
- package/v2/experimental-esi-types.d.ts +287 -0
- package/v2/index.d.ts +6 -2
- package/v2/response-map.d.ts +1 -1
- package/v2/types-index.d.ts +1 -1
- package/v2/types-util.d.ts +3 -147
- package/v2/util.d.ts +19 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,18 +2,33 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
|
|
5
|
-
## [3.2.
|
|
5
|
+
## [3.2.2] - 2025-04-21
|
|
6
6
|
|
|
7
|
-
###
|
|
8
|
-
|
|
7
|
+
### 🚜 Refactor
|
|
8
|
+
|
|
9
|
+
- *(types)* Make `NoContentResponse` a branded type
|
|
10
|
+
- Move experimental types to experimental-esi-types.d.ts
|
|
11
|
+
|
|
12
|
+
### ⚙️ Miscellaneous Tasks
|
|
9
13
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
14
|
+
- Bump version to v3.2.2
|
|
15
|
+
|
|
16
|
+
## [3.2.1] - 2025-04-19
|
|
17
|
+
|
|
18
|
+
### 🐛 Bug Fixes
|
|
19
|
+
|
|
20
|
+
- Package.json "files"
|
|
21
|
+
|
|
22
|
+
### 🚜 Refactor
|
|
23
|
+
|
|
24
|
+
- *(types)* Consolidate redundant type definitions
|
|
25
|
+
- *(types)* Improve clarity and validation in endpoint utility types
|
|
26
|
+
|
|
27
|
+
### ⚙️ Miscellaneous Tasks
|
|
13
28
|
|
|
14
|
-
|
|
15
|
-
- Confirmed removal of the unused "opportunities" ESI endpoint, as per official deprecation notice.
|
|
29
|
+
- *(release)* V3.2.1
|
|
16
30
|
|
|
31
|
+
## [3.2.0] - 2025-04-16
|
|
17
32
|
|
|
18
33
|
### ⚙️ Miscellaneous Tasks
|
|
19
34
|
|
|
@@ -142,7 +157,10 @@ All notable changes to this project will be documented in this file.
|
|
|
142
157
|
|
|
143
158
|
### ⚙️ Miscellaneous Tasks
|
|
144
159
|
|
|
160
|
+
- Jsdoc etc
|
|
161
|
+
- Move files
|
|
145
162
|
- Jsdoc of `initOptions`, refactor `injectESIRequestBody`
|
|
163
|
+
- Jsdoc
|
|
146
164
|
- ESITagsWithMethodList -> ESITagMethodMapping
|
|
147
165
|
- Apply `Object.freeze` to result of `injectESIRequestBody`
|
|
148
166
|
- *(release)* V2.3.4 release
|
|
@@ -180,3 +198,4 @@ All notable changes to this project will be documented in this file.
|
|
|
180
198
|
|
|
181
199
|
- Remove non-functional bookmarks endpoints in ESI
|
|
182
200
|
|
|
201
|
+
<!-- generated by git-cliff -->
|
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.2.
|
|
12
|
+
* @summary This file is auto-generated and defines version 3.2.2 of the EVE Online ESI response types.
|
|
13
13
|
*/
|
|
14
14
|
import type { TESIResponseOKMap } from "./index.d.ts";
|
|
15
15
|
export type * from "./index.d.ts";
|
|
@@ -0,0 +1,287 @@
|
|
|
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/experimental-esi-types.d.ts
|
|
12
|
+
* @summary This file is auto-generated and defines version 3.2.2 of the EVE Online ESI response types.
|
|
13
|
+
*/
|
|
14
|
+
import type { _ESIResponseType, PickPathParameters, UnionToTuple, Split } from "./index.d.ts";
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Infers the response result type of an ESI endpoint based on a union of HTTP method and endpoint.
|
|
18
|
+
*
|
|
19
|
+
* This utility type takes an endpoint union (`EPU`) in the format `${TESIEntryMethod}:${ESIEndpointAll}`
|
|
20
|
+
* and infers the response result type from the corresponding ESI response map.
|
|
21
|
+
*
|
|
22
|
+
* @template EPU - A union of HTTP method and endpoint in the format `${TESIEntryMethod}:${ESIEndpointAll}`.
|
|
23
|
+
*
|
|
24
|
+
* @remarks
|
|
25
|
+
* This type uses advanced TypeScript features such as template literal types and conditional types
|
|
26
|
+
* to infer the response result type of a given ESI endpoint.
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* ``` ts
|
|
30
|
+
* type ResponseResult = InferESIResponseResultFromUnion<"get:/characters/{character_id}/">;
|
|
31
|
+
* // Result: The inferred response result type for the given method and endpoint.
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
export type InferESIResponseResultFromUnion<
|
|
35
|
+
EP extends unknown
|
|
36
|
+
// EP extends ESIEndpointUnions
|
|
37
|
+
> = EP extends `${infer M}:${infer EPRest}`
|
|
38
|
+
/* ctt
|
|
39
|
+
? M extends TESIEntryMethod
|
|
40
|
+
? EPRest extends ESIEndpointOf<M>
|
|
41
|
+
? _ESIResponseType<M, EPRest> extends { result: infer U }
|
|
42
|
+
? U : never
|
|
43
|
+
: never
|
|
44
|
+
: never
|
|
45
|
+
: never;
|
|
46
|
+
/*/
|
|
47
|
+
? EPRest extends (
|
|
48
|
+
M extends TESIEntryMethod ? ESIEndpointOf<M> : never
|
|
49
|
+
)
|
|
50
|
+
? _ESIResponseType<M, EPRest> extends { result: infer U }
|
|
51
|
+
? U : never
|
|
52
|
+
: never
|
|
53
|
+
: never;
|
|
54
|
+
//*/
|
|
55
|
+
|
|
56
|
+
// - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
57
|
+
// Next Endpoint
|
|
58
|
+
// - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
59
|
+
/**
|
|
60
|
+
* @experimental
|
|
61
|
+
*
|
|
62
|
+
* Resolves the next applicable ESI endpoint based on the current endpoint and its response type.
|
|
63
|
+
*
|
|
64
|
+
* This utility type determines which endpoints can be chained after the current endpoint (`EP`),
|
|
65
|
+
* based on the response type (`BaseResut`) and the URL pattern of potential next endpoints.
|
|
66
|
+
*
|
|
67
|
+
* @template M - The HTTP method type (e.g., "get", "post", etc.), which must extend `TESIEntryMethod`.
|
|
68
|
+
* @template EP - The current ESI endpoint under inspection; it extends `ESIEndpointOf<M>`.
|
|
69
|
+
* @template BaseResut - Defaults to `InferESIResponseResult<M, EP>`; it is the inferred response result of the endpoint.
|
|
70
|
+
* @template Endpoints - Defaults to `ESIEndpointOf<M>`; represents the union of all endpoints for method `M` to be considered as potential next endpoints.
|
|
71
|
+
*
|
|
72
|
+
* @remarks
|
|
73
|
+
* This type uses advanced TypeScript features such as conditional types, template literal types, and type inference
|
|
74
|
+
* to perform endpoint validation and chaining.
|
|
75
|
+
*
|
|
76
|
+
* @example
|
|
77
|
+
* ```ts
|
|
78
|
+
* type NextEndpoint = ResolveNextEndpoint<"get", "/universe/graphics/">;
|
|
79
|
+
* // Result: Union of endpoints like "/universe/graphics/{graphic_id}/" if they match the template and response type constraint.
|
|
80
|
+
* ```
|
|
81
|
+
*/
|
|
82
|
+
export type ResolveNextEndpoint<
|
|
83
|
+
M extends TESIEntryMethod,
|
|
84
|
+
EP extends Exclude<ESIEndpointOf<M>, symbol> = Exclude<ESIEndpointOf<M>, symbol>,
|
|
85
|
+
BaseResut extends InferESIResponseResult<M, EP> = InferESIResponseResult<M, EP>,
|
|
86
|
+
// Endpoints extends ESIEndpointAll = ESIEndpointAll,
|
|
87
|
+
Endpoints extends ESIEndpointOf<M> = ESIEndpointOf<M>,
|
|
88
|
+
> = {
|
|
89
|
+
[NextEP in Endpoints]: NextEP extends `${EP}${string}{${string}}/${string}`
|
|
90
|
+
? ValidateNextEndpoint<BaseResut, NextEP> extends 1
|
|
91
|
+
? NextEP : never
|
|
92
|
+
// ? [EP, NextEP, BaseResut] : never
|
|
93
|
+
: never;
|
|
94
|
+
}[Endpoints];
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Resolves the next applicable ESI endpoint based on a union of HTTP method and endpoint.
|
|
98
|
+
*
|
|
99
|
+
* This utility type determines which endpoints can be chained after the current endpoint (`EP`),
|
|
100
|
+
* based on the response type (`BaseResut`) and the URL pattern of potential next endpoints.
|
|
101
|
+
*
|
|
102
|
+
* @template EPU - A union of HTTP method and endpoint in the format `${TESIEntryMethod}:${ESIEndpointAll}`.
|
|
103
|
+
* @template M - The HTTP method extracted from `EPU`.
|
|
104
|
+
* @template EP - The current endpoint extracted from `EPU`.
|
|
105
|
+
* @template BaseResut - The inferred response result of the endpoint.
|
|
106
|
+
* @template Endpoints - The union of all endpoints for the given method.
|
|
107
|
+
*
|
|
108
|
+
* @remarks
|
|
109
|
+
* This type uses advanced TypeScript features such as conditional types and template literal types
|
|
110
|
+
* to infer the next valid endpoint based on the current endpoint and its response type.
|
|
111
|
+
*
|
|
112
|
+
* @example
|
|
113
|
+
* ``` ts
|
|
114
|
+
* type NextEndpoint = ResolveNextEndpointFromUnion<"get:/universe/graphics/">;
|
|
115
|
+
* // Result: Union of endpoints like "/universe/graphics/{graphic_id}/" if they match the template and response type constraint.
|
|
116
|
+
* ```
|
|
117
|
+
*/
|
|
118
|
+
export type ResolveNextEndpointFromUnion<
|
|
119
|
+
EPU extends ESIEndpointUnions,
|
|
120
|
+
SplitM_EP = Split<EPU>,
|
|
121
|
+
M extends TESIEntryMethod = SplitM_EP[0],
|
|
122
|
+
EP extends Exclude<ESIEndpointOf<M>, symbol> = SplitM_EP[1],
|
|
123
|
+
BaseResut extends InferESIResponseResult<M, EP> = InferESIResponseResult<M, EP>,
|
|
124
|
+
Endpoints extends ESIEndpointOf<M> = ESIEndpointOf<M>,
|
|
125
|
+
> = {
|
|
126
|
+
[NextEP in Endpoints]: NextEP extends `${EP}${string}{${string}}/${string}`
|
|
127
|
+
? ValidateNextEndpoint<BaseResut, NextEP> extends 1
|
|
128
|
+
? NextEP : never
|
|
129
|
+
// ? [EP, NextEP, BaseResut] : never
|
|
130
|
+
: never;
|
|
131
|
+
}[Endpoints];
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Validates whether a given endpoint can be the next endpoint in a chain based on the response type of the current endpoint.
|
|
135
|
+
*
|
|
136
|
+
* This utility type checks if the response type (`Entry`) of the current endpoint satisfies the requirements
|
|
137
|
+
* for the next endpoint (`NextEP`), such as having the necessary path parameters.
|
|
138
|
+
*
|
|
139
|
+
* @template BaseResut - The response type of the current endpoint (e.g., `number[]` or an array of objects).
|
|
140
|
+
* @template NextEP - The next endpoint to validate.
|
|
141
|
+
* @template Debug - Optional debug flag; if set to `1`, additional debug information is returned.
|
|
142
|
+
*
|
|
143
|
+
* @remarks
|
|
144
|
+
* This type assumes that if the response type is `number[]`, the next endpoint is always valid. For object arrays,
|
|
145
|
+
* it checks if the required path parameters can be inferred from the response type.
|
|
146
|
+
*
|
|
147
|
+
* ```ts
|
|
148
|
+
* type IsValid = ValidateNextEndpoint<GetCharactersCharacterIdMailOk, "/characters/{character_id}/mail/{mail_id}/">;
|
|
149
|
+
* // or
|
|
150
|
+
* type IsValid = ValidateNextEndpoint<GetCharactersCharacterIdMail_200Ok[], "/characters/{character_id}/mail/{mail_id}/">;
|
|
151
|
+
* // Result: 1 if valid, 0 otherwise.
|
|
152
|
+
* ```
|
|
153
|
+
*/
|
|
154
|
+
export type ValidateNextEndpoint<
|
|
155
|
+
BaseResut extends unknown, // number[] or SomeType[]
|
|
156
|
+
NextEP extends string,
|
|
157
|
+
Debug = 0,
|
|
158
|
+
> =
|
|
159
|
+
// If it is simply a number[], it is unconditionally assumed that there is a next endpoint.
|
|
160
|
+
BaseResut extends number[] ? 1 : ValidateEndpointParamsInArray<BaseResut, NextEP, Debug>;
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* Validates whether the elements of an object array satisfy the path parameter requirements
|
|
164
|
+
* for a given endpoint.
|
|
165
|
+
*
|
|
166
|
+
* @template BaseResut - The response type of the current endpoint (e.g., an array of objects).
|
|
167
|
+
* @template NextEP - The next endpoint to validate.
|
|
168
|
+
* @template Debug - Optional debug flag; if set to `1`, additional debug information is returned.
|
|
169
|
+
* @template PathParams - Defaults to `UnionToTuple<PickPathParameters<NextEP>>`; represents the path parameters of the next endpoint.
|
|
170
|
+
*
|
|
171
|
+
* @remarks
|
|
172
|
+
* This type assumes that if the response type is an array of objects, it checks whether the required
|
|
173
|
+
* path parameters can be inferred from the properties of the objects in the array.
|
|
174
|
+
*
|
|
175
|
+
* @example
|
|
176
|
+
* ```ts
|
|
177
|
+
* type IsValid = ValidateEndpointParamsInArray<GetCharactersCharacterIdMailOk, "/characters/{character_id}/mail/{mail_id}/">;
|
|
178
|
+
* // or
|
|
179
|
+
* type IsValid = ValidateEndpointParamsInArray<GetCharactersCharacterIdMail_200Ok[], "/characters/{character_id}/mail/{mail_id}/">;
|
|
180
|
+
* // Result: 1 if valid, 0 otherwise.
|
|
181
|
+
* ```
|
|
182
|
+
*/
|
|
183
|
+
type ValidateEndpointParamsInArray<
|
|
184
|
+
BaseResut extends unknown, // SomeType[]
|
|
185
|
+
NextEP extends string,
|
|
186
|
+
Debug = 0,
|
|
187
|
+
PathParams = UnionToTuple<PickPathParameters<NextEP>>,
|
|
188
|
+
> = BaseResut extends (infer O)[]
|
|
189
|
+
? NonNullable<O[PathParams[1]]> extends number
|
|
190
|
+
? Debug extends 1 // development
|
|
191
|
+
? [O, PathParams] : 1
|
|
192
|
+
: 0
|
|
193
|
+
: 0;
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* `ResolveNextEndpointLoos` is a utility type that infers the next endpoint based on the current endpoint and method.
|
|
197
|
+
*
|
|
198
|
+
* DONE: 2025/4/11 15:45:01
|
|
199
|
+
* ``` jsonc
|
|
200
|
+
* // Infer the next parameterized endpoint to request from the EP
|
|
201
|
+
* // Does not validate the EP result, just infers the next endpoint to request
|
|
202
|
+
* ```
|
|
203
|
+
*
|
|
204
|
+
* @template M - The HTTP method to use for the request.
|
|
205
|
+
* @template EP - The endpoint from which the next parameterized endpoint to request is inferred.
|
|
206
|
+
* @template Endpoints - The possible endpoints for the given method.
|
|
207
|
+
*
|
|
208
|
+
* ```ts
|
|
209
|
+
* type NextEndpoint = ResolveNextEndpointLoos<"get", "/markets/groups/">;
|
|
210
|
+
* // Result: "/markets/groups/{market_group_id}/"
|
|
211
|
+
* ```
|
|
212
|
+
* @remarks
|
|
213
|
+
* This type is useful for chaining requests or determining the next endpoint to call based on the current endpoint.
|
|
214
|
+
* It does not validate the response type of the endpoint, only the URL pattern.
|
|
215
|
+
*/
|
|
216
|
+
export type ResolveNextEndpointLoos<
|
|
217
|
+
M extends TESIEntryMethod,
|
|
218
|
+
//* ctt
|
|
219
|
+
// DEVNOTE: As it turns out, the behavior of this utility type is broken unless you use the "skipLibCheck=true".
|
|
220
|
+
EP extends ESIEndpointOf<M> = ESIEndpointOf<M>,
|
|
221
|
+
Endpoints extends ESIEndpointOf<M> = ESIEndpointOf<M>,
|
|
222
|
+
/*/
|
|
223
|
+
// This fix is required for skipLibCheck=false
|
|
224
|
+
EP extends Exclude<ESIEndpointOf<M>, symbol> = Exclude<ESIEndpointOf<M>, symbol>,
|
|
225
|
+
Endpoints extends Exclude<ESIEndpointOf<M>, symbol> = Exclude<ESIEndpointOf<M>, symbol>,
|
|
226
|
+
//*/
|
|
227
|
+
> = {
|
|
228
|
+
[NextEP in Endpoints]: NextEP extends `${EP}{${string}}${string}` ? NextEP : never
|
|
229
|
+
}[Endpoints];
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* @see For the meaning of this type of comment trick, see {@link ResolveNextEndpointLoos} line comment.
|
|
233
|
+
*/
|
|
234
|
+
export type ESIEndpointUnions = {
|
|
235
|
+
[M in TESIEntryMethod]: `${M}:${
|
|
236
|
+
//* ctt
|
|
237
|
+
ESIEndpointOf<M>
|
|
238
|
+
/*/
|
|
239
|
+
Exclude<ESIEndpointOf<M>, symbol>
|
|
240
|
+
//*/
|
|
241
|
+
}`;
|
|
242
|
+
}[TESIEntryMethod];
|
|
243
|
+
|
|
244
|
+
|
|
245
|
+
// - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
246
|
+
// Filter Endpoint
|
|
247
|
+
// - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
248
|
+
/**
|
|
249
|
+
* Filters ESI endpoints based on the response type.
|
|
250
|
+
*
|
|
251
|
+
* This utility type iterates over all ESI endpoint unions (`ESIEndpointUnions`) and checks
|
|
252
|
+
* if the inferred response type (`InferESIResponseResultEX<EPU>`) matches the specified type `T`.
|
|
253
|
+
* If it matches, the endpoint is included; otherwise, it is excluded.
|
|
254
|
+
*
|
|
255
|
+
* @template T - The response type to filter endpoints by.
|
|
256
|
+
*
|
|
257
|
+
* @example
|
|
258
|
+
* ``` ts
|
|
259
|
+
* type NumberEndpoints = FilterEndpointUnionsByResponse<number>;
|
|
260
|
+
* // Result: Union of endpoints whose response type is `number`.
|
|
261
|
+
* ```
|
|
262
|
+
*/
|
|
263
|
+
export type FilterEndpointUnionsByResponse<T> = {
|
|
264
|
+
[EPU in ESIEndpointUnions]: InferESIResponseResultFromUnion<EPU> extends T ? EPU : never;
|
|
265
|
+
}[ESIEndpointUnions];
|
|
266
|
+
|
|
267
|
+
/**
|
|
268
|
+
* Extracts valid next ESI endpoints from a filtered list of endpoints.
|
|
269
|
+
*
|
|
270
|
+
* This utility type iterates over a list of filtered endpoints (`EPUs`) and applies
|
|
271
|
+
* `ResolveNextEndpoint2` to determine if the endpoint is valid. If valid, the endpoint
|
|
272
|
+
* is included in the result; otherwise, it is excluded.
|
|
273
|
+
*
|
|
274
|
+
* @template EPUs - The list of filtered endpoints to process.
|
|
275
|
+
*
|
|
276
|
+
* @example
|
|
277
|
+
* ``` ts
|
|
278
|
+
* type ValidEndpoints = ExtractValidNextEndpoints<FilterEndpointsByResponse<number[]>>;
|
|
279
|
+
* // Result: Union of valid next endpoints.
|
|
280
|
+
* ```
|
|
281
|
+
*/
|
|
282
|
+
export type ExtractValidNextEndpoints<
|
|
283
|
+
T = number[], EPUs = FilterEndpointUnionsByResponse<T>
|
|
284
|
+
> = {
|
|
285
|
+
[EPU in EPUs]: ResolveNextEndpointFromUnion<EPU>;
|
|
286
|
+
// [EPU in EPUs]: ResolveNextEndpointFromUnion<EPU> extends never ? never : EPU;
|
|
287
|
+
}[EPUs];
|
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.2.
|
|
12
|
+
* @summary This file is auto-generated and defines version 3.2.2 of the EVE Online ESI response types.
|
|
13
13
|
*/
|
|
14
14
|
import type { TESIResponseOKMap } from "./response-map.d.ts";
|
|
15
15
|
import type { PickPathParameters, InferKeysLen } from "./util.d.ts";
|
|
@@ -438,10 +438,14 @@ declare global {
|
|
|
438
438
|
/*
|
|
439
439
|
*/
|
|
440
440
|
|
|
441
|
+
// declare const NO_CONTENT_RESPONSE: unique symbol;
|
|
442
|
+
// type NoContentResponse = {
|
|
443
|
+
// [NO_CONTENT_RESPONSE]: never;
|
|
444
|
+
// };
|
|
441
445
|
/**
|
|
442
446
|
* Represents a response with no content (HTTP status 204).
|
|
443
447
|
*/
|
|
444
|
-
type NoContentResponse = { /* status: 204 */ };
|
|
448
|
+
type NoContentResponse = { /* status: 204 */ } & { __status: 204 };
|
|
445
449
|
|
|
446
450
|
/**
|
|
447
451
|
* Represents the HTTP methods supported by ESI.
|
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.2.
|
|
12
|
+
* @summary This file is auto-generated and defines version 3.2.2 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.2.
|
|
12
|
+
* @summary This file is auto-generated and defines version 3.2.2 of the EVE Online ESI response types.
|
|
13
13
|
*/
|
|
14
14
|
import "./globals/alliance.d.ts";
|
|
15
15
|
import "./globals/assets.d.ts";
|
package/v2/types-util.d.ts
CHANGED
|
@@ -9,156 +9,11 @@
|
|
|
9
9
|
* THIS DTS IS AUTO GENERATED, DO NOT EDIT
|
|
10
10
|
*
|
|
11
11
|
* @file eve-esi-types/v2/types-util.d.ts
|
|
12
|
-
* @summary This file is auto-generated and defines version 3.2.
|
|
12
|
+
* @summary This file is auto-generated and defines version 3.2.2 of the EVE Online ESI response types.
|
|
13
13
|
*/
|
|
14
14
|
import type { TESIResponseOKMap } from "./response-map.d.ts";
|
|
15
|
-
import type { PickPathParameters, UnionToTuple } from "./index.d.ts";
|
|
16
15
|
|
|
17
16
|
|
|
18
|
-
/**
|
|
19
|
-
* @experimental
|
|
20
|
-
*
|
|
21
|
-
* Resolves the next applicable ESI endpoint based on the current endpoint and its response type.
|
|
22
|
-
*
|
|
23
|
-
* This utility type determines which endpoints can be chained after the current endpoint (`EP`),
|
|
24
|
-
* based on the response type (`BaseResut`) and the URL pattern of potential next endpoints.
|
|
25
|
-
*
|
|
26
|
-
* @template M - The HTTP method type (e.g., "get", "post", etc.), which must extend `TESIEntryMethod`.
|
|
27
|
-
* @template EP - The current ESI endpoint under inspection; it extends `ESIEndpointOf<M>`.
|
|
28
|
-
* @template BaseResut - Defaults to `InferESIResponseResult<M, EP>`; it is the inferred response result of the endpoint.
|
|
29
|
-
* @template Endpoints - Defaults to `ESIEndpointOf<M>`; represents the union of all endpoints for method `M` to be considered as potential next endpoints.
|
|
30
|
-
*
|
|
31
|
-
* @remarks
|
|
32
|
-
* This type uses advanced TypeScript features such as conditional types, template literal types, and type inference
|
|
33
|
-
* to perform endpoint validation and chaining.
|
|
34
|
-
*
|
|
35
|
-
* @example
|
|
36
|
-
* ```typescript
|
|
37
|
-
* type NextEndpoint = ResolveNextEndpoint<"get", "/characters/{character_id}/">;
|
|
38
|
-
* // Result: Union of endpoints like "/characters/{character_id}/assets" if they match the template and response type constraint.
|
|
39
|
-
* ```
|
|
40
|
-
*/
|
|
41
|
-
export type ResolveNextEndpoint<
|
|
42
|
-
M extends TESIEntryMethod,
|
|
43
|
-
EP extends Exclude<ESIEndpointOf<M>, symbol> = Exclude<ESIEndpointOf<M>, symbol>,
|
|
44
|
-
BaseResut extends InferESIResponseResult<M, EP> = InferESIResponseResult<M, EP>,
|
|
45
|
-
// Endpoints extends ESIEndpointAll = ESIEndpointAll,
|
|
46
|
-
Endpoints extends ESIEndpointOf<M> = ESIEndpointOf<M>,
|
|
47
|
-
> = {
|
|
48
|
-
[NextEP in Endpoints]: NextEP extends `${EP}${string}{${string}}/${string}`
|
|
49
|
-
? ValidateNextEndpoint<BaseResut, NextEP> extends 1
|
|
50
|
-
? NextEP : never
|
|
51
|
-
// ? [EP, NextEP, BaseResut] : never
|
|
52
|
-
: never;
|
|
53
|
-
}[Endpoints];
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* Validates whether a given endpoint can be the next endpoint in a chain based on the response type of the current endpoint.
|
|
57
|
-
*
|
|
58
|
-
* This utility type checks if the response type (`Entry`) of the current endpoint satisfies the requirements
|
|
59
|
-
* for the next endpoint (`NextEP`), such as having the necessary path parameters.
|
|
60
|
-
*
|
|
61
|
-
* @template Entry - The response type of the current endpoint (e.g., `number[]` or an array of objects).
|
|
62
|
-
* @template NextEP - The next endpoint to validate.
|
|
63
|
-
* @template Debug - Optional debug flag; if set to `1`, additional debug information is returned.
|
|
64
|
-
* @template PathParams - Defaults to `UnionToTuple<PickPathParameters<NextEP>>`; represents the path parameters of the next endpoint.
|
|
65
|
-
*
|
|
66
|
-
* @remarks
|
|
67
|
-
* This type assumes that if the response type is `number[]`, the next endpoint is always valid. For object arrays,
|
|
68
|
-
* it checks if the required path parameters can be inferred from the response type.
|
|
69
|
-
*
|
|
70
|
-
* ```typescript
|
|
71
|
-
* type IsValid = ValidateNextEndpoint<GetCharactersCharacterIdMail_200Ok[], "/characters/{character_id}/mail/{mail_id}/">;
|
|
72
|
-
* // Result: 1 if valid, 0 otherwise.
|
|
73
|
-
* ```
|
|
74
|
-
*/
|
|
75
|
-
export type ValidateNextEndpoint<
|
|
76
|
-
Entry extends unknown, // number[] or SomeType[]
|
|
77
|
-
NextEP extends string,
|
|
78
|
-
Debug = 0,
|
|
79
|
-
PathParams = UnionToTuple<PickPathParameters<NextEP>>,
|
|
80
|
-
> =
|
|
81
|
-
//* ctt
|
|
82
|
-
// development
|
|
83
|
-
// If it is simply a number[], it is unconditionally assumed that there is a next endpoint.
|
|
84
|
-
Entry extends number[]
|
|
85
|
-
? 1
|
|
86
|
-
: Entry extends (infer O)[]
|
|
87
|
-
? NonNullable<O[PathParams[1]]> extends number
|
|
88
|
-
? Debug extends 1
|
|
89
|
-
? [NextEP, O, PathParams]
|
|
90
|
-
: 1
|
|
91
|
-
: 0
|
|
92
|
-
: 0;
|
|
93
|
-
/*/
|
|
94
|
-
// production
|
|
95
|
-
Entry extends number[] // If it is simply a number[], it is unconditionally assumed that there is a next endpoint.
|
|
96
|
-
? 1 : Entry extends (infer O)[]
|
|
97
|
-
? NonNullable<O[PathParams[1]]> extends number
|
|
98
|
-
? 1: 0
|
|
99
|
-
: 0;
|
|
100
|
-
//*/
|
|
101
|
-
|
|
102
|
-
/**
|
|
103
|
-
* `ResolveNextEndpointLoos` is a utility type that infers the next endpoint based on the current endpoint and method.
|
|
104
|
-
*
|
|
105
|
-
* DONE: 2025/4/11 15:45:01
|
|
106
|
-
* ``` jsonc
|
|
107
|
-
* // Infer the next parameterized endpoint to request from the EP
|
|
108
|
-
* // Does not validate the EP result, just infers the next endpoint to request
|
|
109
|
-
* ```
|
|
110
|
-
*
|
|
111
|
-
* @template M - The HTTP method to use for the request.
|
|
112
|
-
* @template EP - The endpoint from which the next parameterized endpoint to request is inferred.
|
|
113
|
-
* @template Endpoints - The possible endpoints for the given method.
|
|
114
|
-
*
|
|
115
|
-
* ```ts
|
|
116
|
-
* type NextEndpoint = ResolveNextEndpointLoos<"get", "/markets/groups/">;
|
|
117
|
-
* // Result: "/markets/groups/{market_group_id}/"
|
|
118
|
-
* ```
|
|
119
|
-
* @remarks
|
|
120
|
-
* This type is useful for chaining requests or determining the next endpoint to call based on the current endpoint.
|
|
121
|
-
* It does not validate the response type of the endpoint, only the URL pattern.
|
|
122
|
-
*/
|
|
123
|
-
export type ResolveNextEndpointLoos<
|
|
124
|
-
M extends TESIEntryMethod,
|
|
125
|
-
//* ctt
|
|
126
|
-
// DEVNOTE: As it turns out, the behavior of this utility type is broken unless you use the "skipLibCheck=true".
|
|
127
|
-
EP extends ESIEndpointOf<M> = ESIEndpointOf<M>,
|
|
128
|
-
Endpoints extends ESIEndpointOf<M> = ESIEndpointOf<M>,
|
|
129
|
-
/*/
|
|
130
|
-
// This fix is required for skipLibCheck=false
|
|
131
|
-
EP extends Exclude<ESIEndpointOf<M>, symbol> = Exclude<ESIEndpointOf<M>, symbol>,
|
|
132
|
-
Endpoints extends Exclude<ESIEndpointOf<M>, symbol> = Exclude<ESIEndpointOf<M>, symbol>,
|
|
133
|
-
//*/
|
|
134
|
-
> = {
|
|
135
|
-
[NextEP in Endpoints]: NextEP extends `${EP}{${string}}${string}` ? NextEP : never
|
|
136
|
-
}[Endpoints];
|
|
137
|
-
|
|
138
|
-
/**
|
|
139
|
-
* @see For the meaning of this type of comment trick, see {@link ResolveNextEndpointLoos} line comment.
|
|
140
|
-
*/
|
|
141
|
-
type ESIEndpointUnions = {
|
|
142
|
-
[M in TESIEntryMethod]: `${M}:${
|
|
143
|
-
//* ctt
|
|
144
|
-
ESIEndpointOf<M>
|
|
145
|
-
/*/
|
|
146
|
-
Exclude<ESIEndpointOf<M>, symbol>
|
|
147
|
-
//*/
|
|
148
|
-
}`;
|
|
149
|
-
}[TESIEntryMethod];
|
|
150
|
-
export type InferESIResponseResultEX<
|
|
151
|
-
EP extends unknown
|
|
152
|
-
// EP extends ESIEndpointUnions
|
|
153
|
-
> = EP extends `${infer M}:${infer EPRest}`
|
|
154
|
-
? M extends TESIEntryMethod
|
|
155
|
-
? EPRest extends ESIEndpointOf<M>
|
|
156
|
-
? _ESIResponseType<M, EPRest> extends { result: infer U }
|
|
157
|
-
? U : never
|
|
158
|
-
: never
|
|
159
|
-
: never
|
|
160
|
-
: never;
|
|
161
|
-
|
|
162
17
|
/**
|
|
163
18
|
* Represents a function that can make ESI requests with various HTTP methods.
|
|
164
19
|
*
|
|
@@ -250,7 +105,8 @@ export declare type TPathParamsNever = { /* pathParams?: never */ };
|
|
|
250
105
|
* HTTP method and endpoint.
|
|
251
106
|
*
|
|
252
107
|
* @template M - The HTTP method to use for the request.
|
|
253
|
-
* @template EPx - The endpoint path.
|
|
108
|
+
* @template EPx - The endpoint path.
|
|
109
|
+
* include `string` in the `EPx` constraints to avoid breaking typescript inference.
|
|
254
110
|
*
|
|
255
111
|
* @example
|
|
256
112
|
* ```ts
|
package/v2/util.d.ts
CHANGED
|
@@ -51,3 +51,22 @@ export type UnionToTuple<T> = UnionToIntersection<
|
|
|
51
51
|
* @date 2025/2/11 18:12:02
|
|
52
52
|
*/
|
|
53
53
|
export type InferKeysLen<T> = UnionToTuple<T>["length"];
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Splits a string by a delimiter and returns a tuple of the resulting substrings.
|
|
57
|
+
* @example
|
|
58
|
+
* Split<"get:/characters/{character_id}/wallet/", ":">
|
|
59
|
+
* // Result: ["get", "/characters/{character_id}/wallet/"]
|
|
60
|
+
*/
|
|
61
|
+
export type Split<S extends string, D extends string = ":"> =
|
|
62
|
+
S extends `${infer T}${D}${infer U}`
|
|
63
|
+
? [T, ...Split<U, D>]
|
|
64
|
+
: [S];
|
|
65
|
+
|
|
66
|
+
// // Test cases
|
|
67
|
+
// type Test1 = Split<"get:/characters/{character_id}/wallet/">;
|
|
68
|
+
// // Expected: ["get", "/characters/{character_id}/wallet/"]
|
|
69
|
+
// type Test2 = Split<"a.b.c", ".">;
|
|
70
|
+
// // Expected: ['a', 'b', 'c']
|
|
71
|
+
// type Test3 = Split<"hello", ",">;
|
|
72
|
+
// // Expected: ['hello']
|