eve-esi-types 3.2.6 → 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 +13 -0
- package/README.md +87 -63
- package/dist/v2/esi-tagged-types.d.ts +77 -44
- package/dist/v2/experimental-esi-types.d.ts +114 -25
- package/dist/v2/index.d.ts +283 -197
- package/dist/v2/response-map.d.ts +1 -1
- package/dist/v2/types-index.d.ts +1 -1
- package/dist/v2/types-util.d.ts +126 -16
- package/dist/v2/util.d.ts +65 -3
- package/lib/console-util.mjs +1 -1
- package/lib/request-api.mjs +10 -11
- package/lib/rq-util.d.mts +72 -17
- package/lib/rq-util.mjs +106 -46
- package/minimal-rq.mjs +2 -2
- package/package.json +3 -3
- package/request-v3.mjs +8 -12
- package/tagged-rq.mjs +3 -2
- /package/{jsconfig.json → tsconfig.json} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,19 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
|
|
5
|
+
## [3.2.7] - 2025-04-28
|
|
6
|
+
|
|
7
|
+
### 🚜 Refactor
|
|
8
|
+
|
|
9
|
+
- Add ESIEntryParamKeys, ESIEntryExtraKeys & ResolveEndpointRequest types
|
|
10
|
+
|
|
11
|
+
### ⚙️ Miscellaneous Tasks
|
|
12
|
+
|
|
13
|
+
- Update CHANGELOG.md
|
|
14
|
+
- Update JSDoc (rename EPX to EPO and add acronym definition)
|
|
15
|
+
- Update CHANGELOG.md
|
|
16
|
+
- Bump version to v3.2.7
|
|
17
|
+
|
|
5
18
|
## [3.2.6] - 2025-04-24
|
|
6
19
|
|
|
7
20
|
### 🐛 Bug Fixes
|
package/README.md
CHANGED
|
@@ -1,105 +1,129 @@
|
|
|
1
|
+
|
|
1
2
|
# eve-esi-types
|
|
2
|
-
Extracted main types of ESI.
|
|
3
|
+
Extracted main types of ESI (EVE Swagger Interface). This package is designed to handle ESI request and response types effectively.
|
|
3
4
|
|
|
4
|
-
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Table of Contents
|
|
8
|
+
1. [Overview](#overview)
|
|
9
|
+
2. [Installation](#installation)
|
|
10
|
+
3. [Usage](#usage)
|
|
11
|
+
4. [API Overview](#api-overview)
|
|
12
|
+
5. [Version Highlights](#version-highlights)
|
|
13
|
+
- [v3.2.7](#v327)
|
|
14
|
+
- [v3.0.0](#v300)
|
|
15
|
+
- [v2.3.0](#v230)
|
|
16
|
+
6. [References](#references)
|
|
5
17
|
|
|
6
|
-
|
|
18
|
+
---
|
|
7
19
|
|
|
8
|
-
|
|
9
|
-
|
|
20
|
+
## Overview
|
|
21
|
+
`eve-esi-types` helps developers interact with the EVE Online ESI API while leveraging strong TypeScript typings.
|
|
10
22
|
|
|
11
|
-
|
|
23
|
+
This package ensures type safety for ESI request parameters, response handling, and authentication requirements.
|
|
12
24
|
|
|
13
|
-
|
|
14
|
-
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
## Installation
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
npm install eve-esi-types
|
|
15
31
|
```
|
|
16
32
|
|
|
17
|
-
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
## Usage
|
|
18
36
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
> you can determine the result type of the ESI request, what query parameters are required,
|
|
22
|
-
> and whether OAuth authentication is necessary (`auth: true`).
|
|
37
|
+
This package is configured to **use ESI version 2 by default**.
|
|
38
|
+
If you need to work with version 1, refer to the [v1 branch](https://github.com/jeffy-g/eve-esi-types/tree/version-1.x).
|
|
23
39
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
// P2 extends IfParameterizedPath<EP, Opt>,
|
|
30
|
-
// Opt extends IdentifyParameters<TESIResponseOKMap[M][EP], ESIRequestOptions>,
|
|
31
|
-
// R extends InferESIResponseResult<M, EP>
|
|
32
|
-
// >(mthd: M, endp: EP, pathParams?: P2, opt?: Opt): Promise<R>;
|
|
40
|
+
### Example Usage
|
|
41
|
+
A sample script, [`request-v3.mjs`](./request-v3.mjs), is provided.
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
node request-v3.mjs
|
|
33
45
|
```
|
|
34
46
|
|
|
35
|
-
|
|
47
|
+
---
|
|
36
48
|
|
|
37
|
-
|
|
49
|
+
## API Overview
|
|
38
50
|
|
|
39
|
-
|
|
51
|
+
The core export of this package is the `TESIRequestFunctionSignature2` type. It specifies the required endpoint,
|
|
40
52
|
|
|
41
|
-
|
|
53
|
+
HTTP method, query parameters, OAuth requirement, and response type for ESI requests.
|
|
42
54
|
|
|
43
|
-
|
|
55
|
+
### Main Function Signature
|
|
44
56
|
|
|
45
57
|
```ts
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
58
|
+
type TESIRequestFunctionSignature2<ActualOpt extends Record<string, unknown>> = <
|
|
59
|
+
Mtd extends TESIEntryMethod,
|
|
60
|
+
REP extends ReplacePathParams<ESIEndpointOf<Mtd>> | ESIEndpointOf<Mtd>,
|
|
61
|
+
EPO extends ResolvedEndpoint<Mtd, REP>,
|
|
62
|
+
Params extends ResolveEndpointParameters<Mtd, REP, EPO, ActualOpt>,
|
|
63
|
+
Opt extends Params["finalOptions"]
|
|
64
|
+
>(
|
|
65
|
+
method: Mtd,
|
|
66
|
+
endpoint: REP,
|
|
67
|
+
...options: Params["optionIsRequire"] extends 1 ? [Opt] : [Opt?]
|
|
68
|
+
) => Promise<Params["result"]>;
|
|
51
69
|
```
|
|
52
70
|
|
|
53
|
-
+
|
|
71
|
+
### Authentication via Environment Variable (v3.2.7+)
|
|
54
72
|
|
|
55
|
-
|
|
56
|
-
// Minimal default ESI request body implementation
|
|
57
|
-
import { esi } from "eve-esi-types/lib/tagged-request-api.mjs";
|
|
73
|
+
You can enable authenticated requests by setting the environment variable `OAUTH_TOKEN` (for testing):
|
|
58
74
|
|
|
59
|
-
|
|
75
|
+
```bash
|
|
76
|
+
export OAUTH_TOKEN=<Your Access Token>
|
|
60
77
|
```
|
|
61
78
|
|
|
62
|
-
|
|
79
|
+
---
|
|
80
|
+
|
|
81
|
+
## Version Highlights
|
|
82
|
+
|
|
83
|
+
### v3.2.7
|
|
84
|
+
- Added support for specifying the `OAUTH_TOKEN` environment variable.
|
|
85
|
+
- Allows authenticated tests to run successfully by providing an OAuth access token.
|
|
63
86
|
|
|
64
|
-
|
|
87
|
+
---
|
|
65
88
|
|
|
66
|
-
|
|
67
|
-
|
|
89
|
+
### v3.0.0
|
|
90
|
+
- Renamed `TESIRequestFunctionSignature` to `TESIRequestFunctionSignature2`.
|
|
91
|
+
- Improved endpoint inference (`RealEP` and `EP`) for better TypeScript type safety.
|
|
68
92
|
|
|
93
|
+
#### New API Example
|
|
94
|
+
Reusable, narrowing-focused API request using `decoreateESIRequestBody`:
|
|
69
95
|
|
|
70
96
|
```ts
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
// If RealEP points to an endpoint origin (not a replaced endpoint), the path parameter is required
|
|
76
|
-
PathParams extends RealEP extends EP ? IfNeedPathParams<EP> : TPathParamsNever,
|
|
77
|
-
Opt extends IdentifyParameters<TESIResponseOKMap[M][EP], ActualOpt & PathParams>,
|
|
78
|
-
R extends InferESIResponseResult<M, EP>
|
|
79
|
-
>(method: M, endpoint: RealEP, options?: Opt) => Promise<R>;
|
|
97
|
+
import * as taggedApi from "eve-esi-types/lib/tagged-request-api.mjs";
|
|
98
|
+
|
|
99
|
+
const esiRequest = taggedApi.decoreateESIRequestBody(...);
|
|
100
|
+
const response = await esiRequest.universe.get("/universe/structures/", { query: { filter: "market" } });
|
|
80
101
|
```
|
|
81
102
|
|
|
82
|
-
|
|
103
|
+
#### Other Renamed Signatures
|
|
104
|
+
- `IESIRequestFunction -> IESIRequestFunction2`
|
|
105
|
+
- `TESIRequestFunctionMethods -> TESIRequestFunctionMethods2`
|
|
83
106
|
|
|
84
|
-
|
|
85
|
-
+ `TESIRequestFunctionMethods` -> `TESIRequestFunctionMethods2`
|
|
86
|
-
+ `TESIRequestFunctionEachMethod` -> `TESIRequestFunctionEachMethod2`
|
|
87
|
-
+ etc. Also, `v2/esi-tagged-types.d.ts` too
|
|
107
|
+
---
|
|
88
108
|
|
|
89
|
-
###
|
|
109
|
+
### v2.3.0
|
|
110
|
+
- Introduced intuitive ESI request handling via **ESI Tagged Types**.
|
|
111
|
+
- Deprecated `injectESIRequestBody` in favor of `decoreateESIRequestBody` in later versions.
|
|
90
112
|
|
|
91
|
-
|
|
113
|
+
Minimal default implementation:
|
|
92
114
|
|
|
93
115
|
```ts
|
|
94
|
-
import
|
|
95
|
-
|
|
96
|
-
const esiRequest = taggedApi.decoreateESIRequestBody(...);
|
|
97
|
-
const ret = await esiRequest.universe.get("/universe/structures/", { query: { filter: "market" }});
|
|
116
|
+
import { esi } from "eve-esi-types/lib/tagged-request-api.mjs";
|
|
117
|
+
const response = await esi.universe.get("/universe/structures/", { query: { filter: "market" } });
|
|
98
118
|
```
|
|
99
119
|
|
|
120
|
+
---
|
|
100
121
|
|
|
101
122
|
## References
|
|
102
123
|
|
|
103
|
-
- [
|
|
124
|
+
- [ESI Types Utility Definitions](./docs/v3/esi-types-util3.md)
|
|
125
|
+
- [ESI Tagged Types Utility Definitions](./docs/esi-tagged-types.md)
|
|
126
|
+
|
|
127
|
+
---
|
|
104
128
|
|
|
105
|
-
|
|
129
|
+
Have questions or issues? Feel free to explore the [GitHub repository](https://github.com/jeffy-g/eve-esi-types) or open an issue!
|
|
@@ -9,15 +9,15 @@
|
|
|
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.7 of the EVE Online ESI response types.
|
|
13
13
|
*/
|
|
14
|
-
import type { TESIResponseOKMap } from "./index.d.ts";
|
|
14
|
+
import type { TESIResponseOKMap, ResolveEndpointParameters } from "./index.d.ts";
|
|
15
15
|
export type * from "./index.d.ts";
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
18
|
* Converts a string to lower camel case.
|
|
19
19
|
*
|
|
20
|
-
* @template S
|
|
20
|
+
* @template S The string to convert.
|
|
21
21
|
* @example
|
|
22
22
|
* // returns "assets"
|
|
23
23
|
* LCamelCase<"Assets">
|
|
@@ -46,7 +46,7 @@ declare type InferSomethingBy<Tag, AsType extends InferSomethingByBrand = InferS
|
|
|
46
46
|
// - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
47
47
|
/**
|
|
48
48
|
* Maps HTTP methods to their corresponding tags.
|
|
49
|
-
* @template M
|
|
49
|
+
* @template M The HTTP method.
|
|
50
50
|
* @date 2025/2/28
|
|
51
51
|
*/
|
|
52
52
|
export declare type ESITags = InferSomethingBy<never, InferSomethingByTags>;
|
|
@@ -61,7 +61,7 @@ export declare type LESITags = LCamelCase<ESITags>;
|
|
|
61
61
|
/**
|
|
62
62
|
* Infers the HTTP method based on the provided tag.
|
|
63
63
|
*
|
|
64
|
-
* @template Tag
|
|
64
|
+
* @template Tag The tag to infer the method for.
|
|
65
65
|
* @date 2025/2/28
|
|
66
66
|
*/
|
|
67
67
|
export declare type InferMethod<Tag> = InferSomethingBy<Tag>;
|
|
@@ -80,16 +80,13 @@ type XPlanetary = InferMethod<"Planetary Interaction">;
|
|
|
80
80
|
*
|
|
81
81
|
* + Customed InferEndpointOrigin
|
|
82
82
|
*
|
|
83
|
-
* @template RealEP
|
|
84
|
-
* @template Endpoints
|
|
85
|
-
*
|
|
86
|
-
* @typeParam RealEP - The type of the real endpoint.
|
|
87
|
-
* @typeParam Endpoints - The type of the possible endpoints.
|
|
83
|
+
* @template RealEP The type of the real endpoint.
|
|
84
|
+
* @template Endpoints The type of the possible endpoints.
|
|
88
85
|
*
|
|
89
86
|
* @returns The inferred endpoint origin.
|
|
90
87
|
*/
|
|
91
88
|
type _InferEndpointOrigin<
|
|
92
|
-
RealEP extends unknown, Endpoints extends
|
|
89
|
+
RealEP extends unknown, Endpoints extends PropertyKey
|
|
93
90
|
> = {
|
|
94
91
|
[EP in Endpoints]: RealEP extends ReplacePathParams<EP>
|
|
95
92
|
? EP : never;
|
|
@@ -97,38 +94,75 @@ type _InferEndpointOrigin<
|
|
|
97
94
|
|
|
98
95
|
/**
|
|
99
96
|
* Creates a function type for making requests to tagged endpoints.
|
|
100
|
-
*
|
|
101
|
-
*
|
|
102
|
-
*
|
|
103
|
-
*
|
|
104
|
-
*
|
|
105
|
-
* @template
|
|
106
|
-
* @template
|
|
107
|
-
* @template
|
|
108
|
-
* @template
|
|
109
|
-
*
|
|
110
|
-
* @
|
|
111
|
-
*
|
|
112
|
-
*
|
|
113
|
-
* @
|
|
114
|
-
*
|
|
115
|
-
*
|
|
97
|
+
*
|
|
98
|
+
* This utility type defines a function signature for interacting with ESI endpoints
|
|
99
|
+
* that are associated with specific tags and HTTP methods. It ensures type safety
|
|
100
|
+
* by inferring the required parameters, options, and response types for the given endpoint.
|
|
101
|
+
*
|
|
102
|
+
* @template M - The HTTP method (e.g., "get", "post").
|
|
103
|
+
* @template Tag - The tag associated with the endpoint (e.g., "Assets", "Skills").
|
|
104
|
+
* @template ActualOpt - A record type representing additional options for the request.
|
|
105
|
+
* @template EndPoints - The possible endpoints associated with the tag and method.
|
|
106
|
+
*
|
|
107
|
+
* @param endpoint - The endpoint path, which can be parameterized or resolved.
|
|
108
|
+
* @param options - An optional object containing additional options for the request.
|
|
109
|
+
* If the endpoint has required parameters, this parameter must be provided.
|
|
110
|
+
* @returns A promise that resolves to the response type of the endpoint.
|
|
111
|
+
*
|
|
116
112
|
* @remarks
|
|
117
|
-
* The `...options:
|
|
118
|
-
* the
|
|
113
|
+
* - The `...options: Params["optionIsRequire"] extends 1 ? [Opt] : [Opt?]` parameter ensures
|
|
114
|
+
* that if the endpoint has required parameters, the `options` parameter must be provided.
|
|
115
|
+
* If there are no required parameters, the `options` parameter is optional.
|
|
116
|
+
* - This type leverages `ResolveEndpointParameters` to infer the required options and response type.
|
|
117
|
+
*
|
|
118
|
+
* @example
|
|
119
|
+
* ```ts
|
|
120
|
+
* // Example: Making a request to the "Assets" tag with the "get" method
|
|
121
|
+
* type AssetsRequest = TaggedEndpointRequestFunction2<"get", "Assets", ESIRequestOptions>;
|
|
122
|
+
* const fetchAssets: AssetsRequest = async (endpoint, ...options) => {
|
|
123
|
+
* // Implementation here
|
|
124
|
+
* throw new Error();
|
|
125
|
+
* };
|
|
126
|
+
* fetchAssets("/characters/{character_id}/assets/", {
|
|
127
|
+
* pathParams: 12345,
|
|
128
|
+
* auth: true,
|
|
129
|
+
* token: "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9..."
|
|
130
|
+
* }).then(response => {
|
|
131
|
+
* console.log(response);
|
|
132
|
+
* });
|
|
133
|
+
* ```
|
|
134
|
+
*
|
|
135
|
+
* @see {@link ResolveEndpointParameters}
|
|
136
|
+
* @see {@link SelectEndpointByTag}
|
|
137
|
+
* @see {@link InferESIResponseResult}
|
|
119
138
|
*/
|
|
139
|
+
/* ctt
|
|
120
140
|
export declare type TaggedEndpointRequestFunction2<
|
|
121
141
|
M extends TESIEntryMethod, Tag extends ESITags,
|
|
122
142
|
ActualOpt extends Record<string, unknown> = {},
|
|
123
143
|
EndPoints extends SelectEndpointByTag<Tag, M> = SelectEndpointByTag<Tag, M>,
|
|
124
144
|
> = <
|
|
125
145
|
REP extends ReplacePathParams<EndPoints> | EndPoints,
|
|
126
|
-
|
|
127
|
-
PPM extends InferPathParams<REP,
|
|
128
|
-
Opt extends IdentifyParameters<M,
|
|
129
|
-
Ret extends InferESIResponseResult<M,
|
|
130
|
-
HasOpt = HasRequireParams<M,
|
|
146
|
+
EPO extends _InferEndpointOrigin<REP, EndPoints> extends never ? REP: _InferEndpointOrigin<REP, EndPoints>,
|
|
147
|
+
PPM extends InferPathParams<REP, EPO>,
|
|
148
|
+
Opt extends IdentifyParameters<M, EPO, ActualOpt, PPM>,
|
|
149
|
+
Ret extends InferESIResponseResult<M, EPO>,
|
|
150
|
+
HasOpt = HasRequireParams<M, EPO, PPM>,
|
|
131
151
|
>(endpoint: REP, ...options: HasOpt extends 1 ? [Opt] : [Opt?]) => Promise<Ret>;
|
|
152
|
+
/*/
|
|
153
|
+
export declare type TaggedEndpointRequestFunction2<
|
|
154
|
+
M extends TESIEntryMethod, Tag extends ESITags,
|
|
155
|
+
ActualOpt extends Record<string, unknown> = {},
|
|
156
|
+
EndPoints extends SelectEndpointByTag<Tag, M> = SelectEndpointByTag<Tag, M>,
|
|
157
|
+
> = <
|
|
158
|
+
REP extends ReplacePathParams<EndPoints> | EndPoints,
|
|
159
|
+
EPO extends _InferEndpointOrigin<REP, EndPoints> extends never ? REP: _InferEndpointOrigin<REP, EndPoints>,
|
|
160
|
+
// @ts-expect-error TODO: 2025/4/28 TS2344: Type 'EPO' does not satisfy the constraint 'ResolvedEndpoint<M, REP>'
|
|
161
|
+
Params extends ResolveEndpointParameters<M, REP, EPO, ActualOpt>,
|
|
162
|
+
Opt extends Params["finalOptions"],
|
|
163
|
+
Ret extends Params["result"],
|
|
164
|
+
>(endpoint: REP, ...options: Params["optionIsRequire"] extends 1 ? [Opt] : [Opt?]) => Promise<Ret>;
|
|
165
|
+
//*/
|
|
132
166
|
|
|
133
167
|
|
|
134
168
|
// - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
@@ -137,8 +171,8 @@ export declare type TaggedEndpointRequestFunction2<
|
|
|
137
171
|
/**
|
|
138
172
|
* Maps tags to their corresponding endpoint request functions.
|
|
139
173
|
*
|
|
140
|
-
* @template Tag
|
|
141
|
-
* @template ActualOpt
|
|
174
|
+
* @template Tag The tag to map.
|
|
175
|
+
* @template ActualOpt The actual options for the request.
|
|
142
176
|
* @date 2025/2/28
|
|
143
177
|
*/
|
|
144
178
|
export declare type ESITaggedEndpointRequest2<Tag extends ESITags, ActualOpt extends Record<string, unknown> = {}> = {
|
|
@@ -153,19 +187,18 @@ export declare type ESITaggedEndpointRequest2<Tag extends ESITags, ActualOpt ext
|
|
|
153
187
|
/**
|
|
154
188
|
* Selects an endpoint by tag and method.
|
|
155
189
|
*
|
|
156
|
-
* @template Tag
|
|
157
|
-
* @template M
|
|
158
|
-
* @template EP - The endpoint path.
|
|
190
|
+
* @template Tag The tag associated with the endpoint.
|
|
191
|
+
* @template M The HTTP method.
|
|
159
192
|
* @date 2025/2/28
|
|
160
193
|
*/
|
|
161
194
|
export declare type SelectEndpointByTag<
|
|
162
195
|
Tag extends ESITags, M extends TESIEntryMethod
|
|
163
196
|
> = {
|
|
164
|
-
[EP in
|
|
197
|
+
[EP in ESIEndpointOf<M>]: TESIResponseOKMap[M][EP] extends { tag: infer ActualTag }
|
|
165
198
|
? ActualTag extends Tag
|
|
166
199
|
? EP : never
|
|
167
200
|
: never;
|
|
168
|
-
}[
|
|
201
|
+
}[ESIEndpointOf<M>];
|
|
169
202
|
/* ctt
|
|
170
203
|
type XAssetsEndpointGet = SelectEndpointByTag<"Assets", "get">;
|
|
171
204
|
type XAssetsEndpointPost = SelectEndpointByTag<"Assets", "post">;
|
|
@@ -175,7 +208,7 @@ type XAssetsEndpointPost = SelectEndpointByTag<"Assets", "post">;
|
|
|
175
208
|
/**
|
|
176
209
|
* Maps lower camel case tags to their corresponding endpoint request functions.
|
|
177
210
|
*
|
|
178
|
-
* @template ActualOpt
|
|
211
|
+
* @template ActualOpt The actual options for the request.
|
|
179
212
|
* @date 2025/3/12
|
|
180
213
|
*/
|
|
181
214
|
export declare type TaggedESIRequestMap2<ActualOpt extends Record<string, unknown> = {}> = {
|
|
@@ -189,9 +222,9 @@ export declare type TaggedESIRequestMap2<ActualOpt extends Record<string, unknow
|
|
|
189
222
|
* const esiRq: TaggedESIRequestMapPartial2<"factionWarfare" | "wallet">;
|
|
190
223
|
* ```
|
|
191
224
|
*
|
|
192
|
-
* @template
|
|
225
|
+
* @template LowerTags The properties to require in the partial map.
|
|
193
226
|
* @date 2025/2/28
|
|
194
227
|
*/
|
|
195
|
-
export declare type TaggedESIRequestMapPartial2<
|
|
228
|
+
export declare type TaggedESIRequestMapPartial2<LowerTags extends LCamelCase<ESITags>> = RequireThese<Partial<TaggedESIRequestMap2>, LowerTags>;
|
|
196
229
|
|
|
197
230
|
export as namespace XESI;
|
|
@@ -9,9 +9,98 @@
|
|
|
9
9
|
* THIS DTS IS AUTO GENERATED, DO NOT EDIT
|
|
10
10
|
*
|
|
11
11
|
* @file eve-esi-types/v2/experimental-esi-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.7 of the EVE Online ESI response types.
|
|
13
13
|
*/
|
|
14
|
-
import type {
|
|
14
|
+
import type {
|
|
15
|
+
Split,
|
|
16
|
+
UnionToTuple,
|
|
17
|
+
RestrictKeys,
|
|
18
|
+
_ESIResponseType,
|
|
19
|
+
ESIEntryExtraKeys,
|
|
20
|
+
PickPathParameters,
|
|
21
|
+
ExtractPathParamKeys,
|
|
22
|
+
CombineIntersection,
|
|
23
|
+
} from "./index.d.ts";
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Resolves the final request-parameter shape and response type for an ESI endpoint,
|
|
28
|
+
* and indicates whether any parameters are actually required.
|
|
29
|
+
*
|
|
30
|
+
* @template M The HTTP method (e.g. `"get"`, `"post"`) of the request.
|
|
31
|
+
* @template EPx The endpoint path, constrained to `ESIEndpointOf<M>` or a string.
|
|
32
|
+
* @template Opt A record type of user-supplied options (e.g. query/body/path params).
|
|
33
|
+
* @template PathParams A record type representing the path-parameter properties.
|
|
34
|
+
* @template EntryWithParams
|
|
35
|
+
* By default, the merged type of the raw ESI response payload
|
|
36
|
+
* (`_ESIResponseType<M, EPx>`) and `PathParams`.
|
|
37
|
+
* @template RequireKeys
|
|
38
|
+
* The keys in `EntryWithParams` that represent actual request parameters,
|
|
39
|
+
* i.e. all keys minus the built-in ESI metadata (`result`, `tag`, `cachedSeconds`).
|
|
40
|
+
* @template FinalOpt
|
|
41
|
+
* The flattened intersection of:
|
|
42
|
+
* - the subset of `Opt` whose keys are in `RequireKeys`, and
|
|
43
|
+
* - a `Pick` of `EntryWithParams` over those same keys.
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* ```ts
|
|
47
|
+
* // /characters/{character_id}/attributes/
|
|
48
|
+
* type ExampleEntry = {
|
|
49
|
+
* result: GetCharactersCharacterIdAttributesOk;
|
|
50
|
+
* tag: "Skills";
|
|
51
|
+
* cachedSeconds: 120;
|
|
52
|
+
* auth: true;
|
|
53
|
+
* };
|
|
54
|
+
* type ExampleOpt = { auth: true; token: string };
|
|
55
|
+
* type ExamplePath = { character_id: number };
|
|
56
|
+
*
|
|
57
|
+
* // Suppose _ESIResponseType<"get", "/characters/{character_id}/attributes/"> = ExampleEntry
|
|
58
|
+
* type Desc = ResolveEndpointRequest<
|
|
59
|
+
* "get",
|
|
60
|
+
* "/characters/{character_id}/attributes/",
|
|
61
|
+
* ExampleOpt,
|
|
62
|
+
* ExamplePath
|
|
63
|
+
* >;
|
|
64
|
+
* // Desc resolves to:
|
|
65
|
+
* // [
|
|
66
|
+
* // { auth: true; token: string; character_id: number; },
|
|
67
|
+
* // GetCharactersCharacterIdAttributesOk,
|
|
68
|
+
* // 1
|
|
69
|
+
* // ]
|
|
70
|
+
* ```
|
|
71
|
+
*
|
|
72
|
+
* @see {@link ESIEndpointOf}
|
|
73
|
+
* @see {@link _ESIResponseType}
|
|
74
|
+
*/
|
|
75
|
+
export type ResolveEndpointRequest<
|
|
76
|
+
M extends TESIEntryMethod,
|
|
77
|
+
EPx extends ESIEndpointOf<M> | string,
|
|
78
|
+
Opt extends Record<string, unknown>,
|
|
79
|
+
PathParams extends Record<string, unknown>,
|
|
80
|
+
EntryWithParams = _ESIResponseType<M, EPx> & PathParams,
|
|
81
|
+
RequireKeys extends keyof EntryWithParams = Exclude<keyof EntryWithParams, ESIEntryExtraKeys>,
|
|
82
|
+
FinalOpt = CombineIntersection< RestrictKeys<Opt, RequireKeys> & Pick<EntryWithParams, RequireKeys> >
|
|
83
|
+
> = [
|
|
84
|
+
[RequireKeys] extends [never] ? [FinalOpt?] : [FinalOpt],
|
|
85
|
+
EntryWithParams extends { result: infer R } ? R : never,
|
|
86
|
+
];
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
type TESIRequestFunctionContext<
|
|
90
|
+
Mtd extends TESIEntryMethod = TESIEntryMethod,
|
|
91
|
+
REP extends ReplacePathParams<ESIEndpointOf<Mtd>> | ESIEndpointOf<Mtd> = ReplacePathParams<ESIEndpointOf<Mtd>> | ESIEndpointOf<Mtd>,
|
|
92
|
+
ActualOpt extends Record<string, unknown> = Record<string, unknown>,
|
|
93
|
+
|
|
94
|
+
EPO extends ResolvedEndpoint<Mtd, REP> = ResolvedEndpoint<Mtd, REP>,
|
|
95
|
+
PPM extends InferPathParams<REP, EPO> = InferPathParams<REP, EPO>,
|
|
96
|
+
Opt extends IdentifyParameters<Mtd, EPO, ActualOpt, PPM> = IdentifyParameters<Mtd, EPO, ActualOpt, PPM>,
|
|
97
|
+
Ret extends InferESIResponseResult<Mtd, EPO> = InferESIResponseResult<Mtd, EPO>,
|
|
98
|
+
HasOpt = HasRequireParams<Mtd, EPO, PPM>,
|
|
99
|
+
> = {
|
|
100
|
+
method: Mtd; endpoint: REP;
|
|
101
|
+
} & (HasOpt extends 1 ? { options: Opt } : { options?: Opt }) & {
|
|
102
|
+
result?: Ret;
|
|
103
|
+
};
|
|
15
104
|
|
|
16
105
|
// - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
17
106
|
// TESIRequestFunctionWithContext
|
|
@@ -31,7 +120,7 @@ export type TESIRequestFunctionWithContext<
|
|
|
31
120
|
* This utility type takes an endpoint union (`EPU`) in the format `${TESIEntryMethod}:${ESIEndpointAll}`
|
|
32
121
|
* and infers the response result type from the corresponding ESI response map.
|
|
33
122
|
*
|
|
34
|
-
* @template EPU
|
|
123
|
+
* @template EPU A union of HTTP method and endpoint in the format `${TESIEntryMethod}:${ESIEndpointAll}`.
|
|
35
124
|
*
|
|
36
125
|
* @remarks
|
|
37
126
|
* This type uses advanced TypeScript features such as template literal types and conditional types
|
|
@@ -76,10 +165,10 @@ export type InferESIResponseResultFromUnion<
|
|
|
76
165
|
* This utility type determines which endpoints can be chained after the current endpoint (`EP`),
|
|
77
166
|
* based on the response type (`BaseResut`) and the URL pattern of potential next endpoints.
|
|
78
167
|
*
|
|
79
|
-
* @template M
|
|
80
|
-
* @template EP
|
|
81
|
-
* @template BaseResut
|
|
82
|
-
* @template Endpoints
|
|
168
|
+
* @template M The HTTP method type (e.g., "get", "post", etc.), which must extend `TESIEntryMethod`.
|
|
169
|
+
* @template EP The current ESI endpoint under inspection; it extends `ESIEndpointOf<M>`.
|
|
170
|
+
* @template BaseResut Defaults to `InferESIResponseResult<M, EP>`; it is the inferred response result of the endpoint.
|
|
171
|
+
* @template Endpoints Defaults to `ESIEndpointOf<M>`; represents the union of all endpoints for method `M` to be considered as potential next endpoints.
|
|
83
172
|
*
|
|
84
173
|
* @remarks
|
|
85
174
|
* This type uses advanced TypeScript features such as conditional types, template literal types, and type inference
|
|
@@ -122,11 +211,11 @@ export type SplitEndpointUnion<
|
|
|
122
211
|
* This utility type determines which endpoints can be chained after the current endpoint (`EP`),
|
|
123
212
|
* based on the response type (`BaseResut`) and the URL pattern of potential next endpoints.
|
|
124
213
|
*
|
|
125
|
-
* @template EPU
|
|
126
|
-
* @template M
|
|
127
|
-
* @template EP
|
|
128
|
-
* @template BaseResut
|
|
129
|
-
* @template Endpoints
|
|
214
|
+
* @template EPU A union of HTTP method and endpoint in the format `${TESIEntryMethod}:${ESIEndpointAll}`.
|
|
215
|
+
* @template M The HTTP method extracted from `EPU`.
|
|
216
|
+
* @template EP The current endpoint extracted from `EPU`.
|
|
217
|
+
* @template BaseResut The inferred response result of the endpoint.
|
|
218
|
+
* @template Endpoints The union of all endpoints for the given method.
|
|
130
219
|
*
|
|
131
220
|
* @remarks
|
|
132
221
|
* This type uses advanced TypeScript features such as conditional types and template literal types
|
|
@@ -159,9 +248,9 @@ export type ResolveNextEndpointFromUnion<
|
|
|
159
248
|
* This utility type checks if the response type (`Entry`) of the current endpoint satisfies the requirements
|
|
160
249
|
* for the next endpoint (`NextEP`), such as having the necessary path parameters.
|
|
161
250
|
*
|
|
162
|
-
* @template BaseResut
|
|
163
|
-
* @template NextEP
|
|
164
|
-
* @template Debug
|
|
251
|
+
* @template BaseResut The response type of the current endpoint (e.g., `number[]` or an array of objects).
|
|
252
|
+
* @template NextEP The next endpoint to validate.
|
|
253
|
+
* @template Debug Optional debug flag; if set to `1`, additional debug information is returned.
|
|
165
254
|
*
|
|
166
255
|
* @remarks
|
|
167
256
|
* This type assumes that if the response type is `number[]`, the next endpoint is always valid. For object arrays,
|
|
@@ -186,10 +275,10 @@ export type ValidateNextEndpoint<
|
|
|
186
275
|
* Validates whether the elements of an object array satisfy the path parameter requirements
|
|
187
276
|
* for a given endpoint.
|
|
188
277
|
*
|
|
189
|
-
* @template BaseResut
|
|
190
|
-
* @template NextEP
|
|
191
|
-
* @template Debug
|
|
192
|
-
* @template PathParams
|
|
278
|
+
* @template BaseResut The response type of the current endpoint (e.g., an array of objects).
|
|
279
|
+
* @template NextEP The next endpoint to validate.
|
|
280
|
+
* @template Debug Optional debug flag; if set to `1`, additional debug information is returned.
|
|
281
|
+
* @template PathParams Defaults to `ExtractPathParamsTuple<NextEP>`; represents the path parameters of the next endpoint.
|
|
193
282
|
*
|
|
194
283
|
* @remarks
|
|
195
284
|
* This type assumes that if the response type is an array of objects, it checks whether the required
|
|
@@ -207,7 +296,7 @@ type ValidateEndpointParamsInArray<
|
|
|
207
296
|
BaseResut extends unknown, // SomeType[]
|
|
208
297
|
NextEP extends string,
|
|
209
298
|
Debug = 0,
|
|
210
|
-
PathParams extends any[] =
|
|
299
|
+
PathParams extends any[] = ExtractPathParamKeys<NextEP>,
|
|
211
300
|
> = BaseResut extends (infer O)[]
|
|
212
301
|
? PathParams[1] extends keyof O ? NonNullable<O[PathParams[1]]> extends number
|
|
213
302
|
? Debug extends 1 // development
|
|
@@ -225,9 +314,9 @@ type ValidateEndpointParamsInArray<
|
|
|
225
314
|
* // Does not validate the EP result, just infers the next endpoint to request
|
|
226
315
|
* ```
|
|
227
316
|
*
|
|
228
|
-
* @template M
|
|
229
|
-
* @template EP
|
|
230
|
-
* @template Endpoints
|
|
317
|
+
* @template M The HTTP method to use for the request.
|
|
318
|
+
* @template EP The endpoint from which the next parameterized endpoint to request is inferred.
|
|
319
|
+
* @template Endpoints The possible endpoints for the given method.
|
|
231
320
|
*
|
|
232
321
|
* ```ts
|
|
233
322
|
* type NextEndpoint = ResolveNextEndpointLoos<"get", "/markets/groups/">;
|
|
@@ -276,7 +365,7 @@ export type ESIEndpointUnions = {
|
|
|
276
365
|
* if the inferred response type (`InferESIResponseResultFromUnion<EPU>`) matches the specified type `T`.
|
|
277
366
|
* If it matches, the endpoint is included; otherwise, it is excluded.
|
|
278
367
|
*
|
|
279
|
-
* @template T
|
|
368
|
+
* @template T The response type to filter endpoints by.
|
|
280
369
|
*
|
|
281
370
|
* @example
|
|
282
371
|
* ``` ts
|
|
@@ -295,7 +384,7 @@ export type FilterEndpointUnionsByResponse<T> = {
|
|
|
295
384
|
* `ResolveNextEndpoint2` to determine if the endpoint is valid. If valid, the endpoint
|
|
296
385
|
* is included in the result; otherwise, it is excluded.
|
|
297
386
|
*
|
|
298
|
-
* @template EPUs
|
|
387
|
+
* @template EPUs The list of filtered endpoints to process.
|
|
299
388
|
*
|
|
300
389
|
* @example
|
|
301
390
|
* ``` ts
|