eve-esi-types 3.0.4 → 3.1.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/README.md CHANGED
@@ -8,10 +8,10 @@ Extracted main types of ESI. Used for ESI request response types.
8
8
  + If you need to use version 1, please refer to the following link:
9
9
  [eve-esi-types v1](https://github.com/jeffy-g/eve-esi-types/tree/version-1.x)
10
10
 
11
- > Sample code is provided -> [`v2.mjs`](./v2.mjs)
11
+ > Sample code is provided -> [`request-v3.mjs`](./request-v3.mjs)
12
12
 
13
13
  ```shell
14
- $ node v2.mjs
14
+ $ node request-v3.mjs
15
15
  ```
16
16
 
17
17
  ## API
@@ -100,4 +100,6 @@ const ret = await esiRequest.universe.get("/universe/structures/", { query: { fi
100
100
 
101
101
  ## References
102
102
 
103
- - [`ESI Types Utility Definitions`](./esi-types-util3.md)
103
+ - [`ESI Types Utility Definitions`](./docs/esi-types-util3.md)
104
+
105
+ - [`ESI Tagged Types Utility Definitions`](./docs/esi-tagged-types.md)
@@ -0,0 +1,120 @@
1
+ # ESI Tagged Types
2
+
3
+ This document provides an overview of the types defined in the `eve-esi-types/v2/esi-tagged-types.d.ts` file. These types are used to handle EVE Online ESI responses.
4
+
5
+ ## LCamelCase
6
+
7
+ Converts a string to lower camel case.
8
+
9
+ ```typescript
10
+ type LCamelCase<S extends string> = S extends `${infer P1} ${infer P2}`
11
+ ? `${Lowercase<P1>}${Capitalize<P2>}` : Lowercase<S>;
12
+ ```
13
+
14
+ ### Example
15
+
16
+ ```typescript
17
+ // returns "assets"
18
+ LCamelCase<"Assets">
19
+
20
+ // returns "factionWarfare"
21
+ LCamelCase<"Faction Warfare">
22
+ ```
23
+
24
+ ## InferSomethingBy
25
+
26
+ Infers something by a brand.
27
+
28
+ ```typescript
29
+ type InferSomethingByBrand<N = number> = N & { __enum: "InferSomethingBy" };
30
+ type InferSomethingByMethod = InferSomethingByBrand<0>;
31
+ type InferSomethingByTags = InferSomethingByBrand<1>;
32
+ type InferSomethingBy<Tag, AsType extends InferSomethingByBrand = InferSomethingByMethod> = {
33
+ [M in TESIEntryMethod]: TESIResponseOKMap[M] extends Record<`/${string}/`, { tag: infer ActualTag }>
34
+ ? AsType extends InferSomethingByTags
35
+ ? ActualTag : ActualTag extends Tag
36
+ ? M
37
+ : never
38
+ : never;
39
+ }[TESIEntryMethod];
40
+ ```
41
+
42
+ ## ESITags
43
+
44
+ Maps HTTP methods to their corresponding tags.
45
+
46
+ ```typescript
47
+ type ESITags = InferSomethingBy<never, InferSomethingByTags>;
48
+ ```
49
+
50
+ ## InferMethod
51
+
52
+ Infers the HTTP method based on the provided tag.
53
+
54
+ ```typescript
55
+ type InferMethod<Tag> = InferSomethingBy<Tag>;
56
+ ```
57
+
58
+ ## TaggedEndpointRequestFunction2
59
+
60
+ Creates a function type for making requests to tagged endpoints.
61
+
62
+ ```typescript
63
+ type TaggedEndpointRequestFunction2<
64
+ M extends TESIEntryMethod, Tag extends ESITags,
65
+ ActualOpt extends Record<string, unknown> = {},
66
+ EndPoints extends SelectEndpointByTag<Tag, M> = SelectEndpointByTag<Tag, M>,
67
+ > = <
68
+ REP extends ReplacePathParams<EndPoints> | EndPoints,
69
+ EPX extends _InferEndpointOrigin<REP, EndPoints> extends never ? REP: _InferEndpointOrigin<REP, EndPoints>,
70
+ PPM extends InferPathParams<REP, EPX>,
71
+ Opt extends IdentifyParameters<M, EPX, ActualOpt & PPM>,
72
+ Ret extends InferESIResponseResult<M, EPX>,
73
+ HasOpt = HasRequireParams<M, EPX, PPM>,
74
+ >(endpoint: REP, ...options: HasOpt extends 1 ? [Opt] : [Opt?]) => Promise<Ret>;
75
+ ```
76
+
77
+ ## ESITaggedEndpointRequest2
78
+
79
+ Maps tags to their corresponding endpoint request functions.
80
+
81
+ ```typescript
82
+ type ESITaggedEndpointRequest2<Tag extends ESITags, ActualOpt extends Record<string, unknown> = {}> = {
83
+ [tag in Tag]: {
84
+ [method in InferMethod<Tag>]: TaggedEndpointRequestFunction2<method, tag, ActualOpt>;
85
+ };
86
+ }[Tag];
87
+ ```
88
+
89
+ ## SelectEndpointByTag
90
+
91
+ Selects an endpoint by tag and method.
92
+
93
+ ```typescript
94
+ type SelectEndpointByTag<
95
+ Tag extends ESITags, M extends TESIEntryMethod
96
+ > = {
97
+ [EP in keyof TESIResponseOKMap[M]]: TESIResponseOKMap[M][EP] extends { tag: infer ActualTag }
98
+ ? ActualTag extends Tag
99
+ ? EP : never
100
+ : never;
101
+ }[keyof TESIResponseOKMap[M]];
102
+ ```
103
+
104
+ ## TaggedESIRequestMap2
105
+
106
+ Maps lower camel case tags to their corresponding endpoint request functions.
107
+
108
+ ```typescript
109
+ type TaggedESIRequestMap2<ActualOpt extends Record<string, unknown> = {}> = {
110
+ [tag in ESITags as LCamelCase<tag>]: ESITaggedEndpointRequest2<tag, ActualOpt>;
111
+ };
112
+ ```
113
+
114
+ ## TaggedESIRequestMapPartial2
115
+
116
+ Creates a partial map of lower camel case tags to their corresponding endpoint request functions.
117
+
118
+ ```typescript
119
+ type TaggedESIRequestMapPartial2<Props extends LCamelCase<ESITags>> = RequireThese<Partial<TaggedESIRequestMap2>, Props>;
120
+ ```
@@ -0,0 +1,319 @@
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
+ # ESI Types Utility 3.1 Summary
10
+
11
+ This document provides detailed explanations of each type defined in the `eve-esi-types/v2/index.d.ts` file.
12
+
13
+ > ## TESIRequestFunctionSignature2
14
+
15
+ `TESIRequestFunctionSignature2` is a type that defines the signature of an ESI request function where the endpoint can be a real endpoint or a parameterized endpoint. This function sends a request to a specified endpoint and returns a response.
16
+
17
+ #### Type Parameters
18
+
19
+ - `ActualOpt`: The actual type of the options.
20
+ - `M`: The HTTP method to use for the request.
21
+ - `RealEP`: The real path of the ESI endpoint to send the request to.
22
+ - `EPx`: The parameterized path of the ESI endpoint to send the request to.
23
+ - `PathParams`: Parameters to include in the request if the endpoint is parameterized.
24
+ - `Opt`: Options to include in the request. If there is a required parameter, its type will be merged with `ActualOpt`.
25
+ - `R`: The response type.
26
+ - `HasOpt`: Determines if the options parameter is required.
27
+
28
+ #### Parameters
29
+
30
+ - `method`: The HTTP method to use for the request (e.g., "get", "post").
31
+ - `endpoint`: The real path of the ESI endpoint to send the request to.
32
+ - `options`: An optional object containing additional options for the request. If the endpoint has required parameters, this parameter must be provided.
33
+
34
+ #### Returns
35
+
36
+ A `Promise` object containing the response data, with the type inferred based on the method and endpoint.
37
+
38
+ #### Remarks
39
+
40
+ The `...options: HasOpt extends 1 ? [Opt] : [Opt?]` parameter is defined this way to enforce that if the endpoint has required parameters, the `options` parameter must be provided. If there are no required parameters, the `options` parameter is optional.
41
+
42
+
43
+ > ## TESIRequestFunctionEachMethod2
44
+
45
+ `TESIRequestFunctionEachMethod2` is a type that defines the signature of an ESI request function for a specific HTTP method. This function sends a request to a specified endpoint and returns a response.
46
+
47
+ #### Type Parameters
48
+
49
+ - `M`: The HTTP method to use for the request.
50
+ - `ActualOpt`: The actual type of the options.
51
+ - `RealEP`: The real path of the ESI endpoint to send the request to.
52
+ - `EPx`: The parameterized path of the ESI endpoint to send the request to.
53
+ - `PathParams`: Parameters to include in the request if the endpoint is parameterized.
54
+ - `Opt`: Options to include in the request. If there is a required parameter, its type will be merged with `ActualOpt`.
55
+ - `R`: The response type.
56
+ - `HasOpt`: Determines if the options parameter is required.
57
+
58
+ #### Parameters
59
+
60
+ - `endpoint`: The real path of the ESI endpoint to send the request to.
61
+ - `options`: An optional object containing additional options for the request. If the endpoint has required parameters, this parameter must be provided.
62
+
63
+ #### Returns
64
+
65
+ A `Promise` object containing the response data, with the type inferred based on the method and endpoint.
66
+
67
+ #### Remarks
68
+
69
+ The `...options: HasOpt extends 1 ? [Opt] : [Opt?]` parameter is defined this way to enforce that if the endpoint has required parameters, the `options` parameter must be provided. If there are no required parameters, the `options` parameter is optional.
70
+
71
+
72
+
73
+ ## ReplacePathParams
74
+
75
+ `ReplacePathParams` is a type that replaces path parameters in a string with numbers.
76
+
77
+ ```typescript
78
+ type ReplacePathParams<T extends unknown> = T extends `${infer Start}{${infer Param}}${infer End}`
79
+ ? `${Start}${number}${ReplacePathParams<End>}` : T;
80
+ ```
81
+
82
+ <details>
83
+ > Example
84
+
85
+ ```typescript
86
+ type Example = ReplacePathParams<"/characters/{character_id}/fittings/{fitting_id}/">;
87
+ // Result: `/characters/${number}/fittings/${number}/`
88
+ ```
89
+ </details>
90
+
91
+ ## InferPathParams
92
+
93
+ `InferPathParams` is a type that infers the path parameters based on the real endpoint and the resolved endpoint.
94
+
95
+ ```typescript
96
+ type InferPathParams<
97
+ RealEP extends unknown, EPx extends unknown
98
+ > = RealEP extends EPx ? _IfNeedPathParams<EPx> : TPathParamsNever;
99
+ ```
100
+
101
+ ## InferEndpointOrigin
102
+
103
+ `InferEndpointOrigin` is a type that infers the original endpoint based on the real endpoint and the HTTP method. This type maps the real endpoint to its corresponding parameterized endpoint by checking if the real endpoint matches the pattern of any parameterized endpoint.
104
+
105
+ ```typescript
106
+ type InferEndpointOrigin<
107
+ RealEP extends unknown, M extends TESIEntryMethod,
108
+ Endpoints extends ESIEndpointOf<M> = ESIEndpointOf<M>
109
+ > = {
110
+ [EP in Endpoints]: RealEP extends ReplacePathParams<EP>
111
+ ? EP : never;
112
+ }[Endpoints];
113
+ ```
114
+
115
+ <details>
116
+ > Example
117
+
118
+ ```typescript
119
+ type Original = InferEndpointOrigin<"/characters/123/fittings/456/", "delete">;
120
+ // Result: "/characters/{character_id}/fittings/{fitting_id}/"
121
+ ```
122
+ </details>
123
+
124
+
125
+ ## ResolvedEndpoint
126
+
127
+ `ResolvedEndpoint` is a type that determines the resolved endpoint based on the real endpoint and the method.
128
+
129
+ ```typescript
130
+ type ResolvedEndpoint<
131
+ RealEP extends unknown, M extends TESIEntryMethod,
132
+ > = InferEndpointOrigin<RealEP, M> extends never ? RealEP: InferEndpointOrigin<RealEP, M>;
133
+ ```
134
+
135
+ <details>
136
+ > Example
137
+
138
+ ```typescript
139
+ type Resolved = ResolvedEndpoint<"/characters/123/fittings/456/", "delete">;
140
+ // Result: "/characters/{character_id}/fittings/{fitting_id}/"
141
+ ```
142
+ </details>
143
+
144
+ ## PickRequireParams
145
+
146
+ `PickRequireParams` is a type that picks the required parameters from an entry type, including additional parameters. This type excludes the keys "result", "tag", and "cachedSeconds" from the entry type and the additional parameters, and returns the remaining keys as the required parameters.
147
+
148
+ ```typescript
149
+ type PickRequireParams<
150
+ M extends TESIEntryMethod,
151
+ EPx extends ESIEndpointOf<M> | string,
152
+ AdditionalParams,
153
+ Entry = _ESIResponseType<M, EPx>
154
+ > = Exclude<keyof (Entry & AdditionalParams), "result" | "tag" | "cachedSeconds">;
155
+ ```
156
+
157
+ <details>
158
+ > Example
159
+
160
+ ```typescript
161
+ type ExampleEntry = { result: string, tag: string, cachedSeconds: number, auth: string };
162
+ type RequiredParams = PickRequireParams<"get", "/example/endpoint", { auth: string }>;
163
+ // Result: "auth"
164
+ ```
165
+ </details>
166
+
167
+ ## HasRequireParams
168
+
169
+ `HasRequireParams` is a type that determines if the given entry has required parameters, including additional options. This type checks if an entry has any required parameters by excluding the keys "result", "tag", and "cachedSeconds". If any keys remain after this exclusion, it means the entry has required parameters.
170
+
171
+ ```typescript
172
+ type HasRequireParams<
173
+ M extends TESIEntryMethod,
174
+ EPx extends ESIEndpointOf<M> | string,
175
+ AdditionalParams,
176
+ > = PickRequireParams<M, EPx, AdditionalParams> extends never ? 0 : 1;
177
+ ```
178
+
179
+ <details>
180
+ > Example
181
+
182
+ ```typescript
183
+ type ExampleEntry = { result: string, tag: string, cachedSeconds: number, auth: string };
184
+ type HasRequired = HasRequireParams<"get", "/example/endpoint", { auth: string }>;
185
+ // Result: 1
186
+ ```
187
+ </details>
188
+
189
+ ## IfParameterizedPath
190
+
191
+ `IfParameterizedPath` is a type that determines the required number of replacements if `EP` (endpoint) is a parameterized path.
192
+
193
+ ```typescript
194
+ type IfParameterizedPath<EP extends unknown, Opt = never> = EP extends `${string}/{${string}}${string}`
195
+ ? PickPathParameters<EP> extends never
196
+ ? Opt : InferKeysLen<PickPathParameters<EP>> extends 1
197
+ ? number : [number, number]
198
+ : Opt;
199
+ ```
200
+
201
+ ## IdentifyParameters
202
+
203
+ `IdentifyParameters` is a type that identifies the required parameters for a given entry type, including additional options. This type combines the required parameters from the entry type and the additional options, ensuring that all required parameters are marked as required.
204
+
205
+ ```typescript
206
+ type IdentifyParameters<
207
+ M extends TESIEntryMethod,
208
+ EPx extends ESIEndpointOf<M> | string,
209
+ Opt extends Record<string, unknown>,
210
+ Entry = _ESIResponseType<M, EPx>,
211
+ Keys = Exclude<keyof Entry, "result" | "tag" | "cachedSeconds">
212
+ > = RequireThese<Opt, Keys> & Pick<Entry, Keys>;
213
+ ```
214
+
215
+ <details>
216
+ > Example
217
+
218
+ ```typescript
219
+ type ExampleEntry = { result: string, tag: string, cachedSeconds: number, auth: string };
220
+ type ExampleOpt = { auth: string };
221
+ type IdentifiedParams = IdentifyParameters<"get", "/example/endpoint", ExampleOpt, ExampleEntry>;
222
+ // Result: { auth: string } & { auth: string }
223
+ ```
224
+ </details>
225
+
226
+ ## InferESIResponseResult
227
+
228
+ `InferESIResponseResult` is a type that infers the result type of an ESI response based on the method and endpoint.
229
+
230
+ ```typescript
231
+ type InferESIResponseResult<
232
+ M extends TESIEntryMethod,
233
+ EPx extends ESIEndpointOf<M> | string
234
+ > = _ESIResponseType<M, EPx> extends { result: infer U } ? U : never;
235
+ ```
236
+
237
+ <details>
238
+ > Example
239
+
240
+ ```typescript
241
+ type Result = InferESIResponseResult<"get", "/characters/{character_id}/">;
242
+ // Result: The inferred type of the response for the given method and endpoint.
243
+ ```
244
+ </details>
245
+
246
+ ## NoContentResponse
247
+
248
+ `NoContentResponse` is a type that represents a response with no content (HTTP status 204).
249
+
250
+ ```typescript
251
+ type NoContentResponse = { /* status: 204 */ };
252
+ ```
253
+
254
+ ## TESIEntryMethod
255
+
256
+ `TESIEntryMethod` is a type that represents the HTTP methods supported by ESI.
257
+
258
+ ```typescript
259
+ type TESIEntryMethod = keyof TESIResponseOKMap;
260
+ ```
261
+
262
+ <details>
263
+ > Example
264
+
265
+ ```typescript
266
+ "get" | "post" | "put" | "delete"
267
+ ```
268
+ </details>
269
+
270
+ ## ESIEndpointOf
271
+
272
+ `ESIEndpointOf` is a type that represents the endpoints for the specified HTTP method.
273
+
274
+ ```typescript
275
+ type ESIEndpointOf<M extends TESIEntryMethod> = keyof TESIResponseOKMap[M];
276
+ ```
277
+
278
+ <details>
279
+ > Example
280
+
281
+ ```typescript
282
+ type TEndPointGet = ESIEndpointOf<"get">;
283
+ type TEndPointPost = ESIEndpointOf<"post">;
284
+ type TEndPointPut = ESIEndpointOf<"put">;
285
+ type TEndPointDelete = ESIEndpointOf<"delete">;
286
+ ```
287
+ </details>
288
+
289
+ ## TESIResponseGetEntry
290
+
291
+ `TESIResponseGetEntry` is a type that represents the entry details for the "get" method.
292
+
293
+ ```typescript
294
+ type TESIResponseGetEntry<K extends TEndPointGet> = TESIResponseOKMap["get"][K];
295
+ ```
296
+
297
+ ## TESIResponsePutEntry
298
+
299
+ `TESIResponsePutEntry` is a type that represents the entry details for the "put" method.
300
+
301
+ ```typescript
302
+ type TESIResponsePutEntry<K extends TEndPointPut> = TESIResponseOKMap["put"][K];
303
+ ```
304
+
305
+ ## TESIResponsePostEntry
306
+
307
+ `TESIResponsePostEntry` is a type that represents the entry details for the "post" method.
308
+
309
+ ```typescript
310
+ type TESIResponsePostEntry<K extends TEndPointPost> = TESIResponseOKMap["post"][K];
311
+ ```
312
+
313
+ ## TESIResponseDeleteEntry
314
+
315
+ `TESIResponseDeleteEntry` is a type that represents the entry details for the "delete" method.
316
+
317
+ ```typescript
318
+ type TESIResponseDeleteEntry<K extends TEndPointDelete> = TESIResponseOKMap["delete"][K];
319
+ ```
package/lib/rq-util.d.mts CHANGED
@@ -16,7 +16,7 @@
16
16
  // https://opensource.org/licenses/mit-license.php
17
17
  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
18
18
  */
19
- import type { TESIResponseOKMap, TESIRequestFunctionMethods2, TPathParamsNever } from "../v2";
19
+ import type { TESIRequestFunctionMethods2 } from "../v2";
20
20
  import type { TESIErrorStats } from "./esi-error-types";
21
21
  export { isNode } from "./constants.mjs";
22
22
  /**
@@ -181,9 +181,10 @@ export declare function getLogger(): {
181
181
  clog: (...args: any[]) => void;
182
182
  rlog: (...args: any[]) => void;
183
183
  };
184
- export type TFireWithoutAuth = {
185
- fireWithoutAuth<M extends TESIEntryMethod, RealEP extends ReplacePathParams<keyof TESIResponseOKMap[M] & string> | keyof TESIResponseOKMap[M], EP extends InferEndpointOrigin<RealEP, keyof TESIResponseOKMap[M]> extends never ? RealEP : InferEndpointOrigin<RealEP, keyof TESIResponseOKMap[M]>, PathParams extends RealEP extends EP ? IfNeedPathParams<EP> : TPathParamsNever, Opt extends IdentifyParameters<TESIResponseOKMap[M][Extract<EP, keyof TESIResponseOKMap[M]>], ESIRequestOptions & PathParams>, R extends InferESIResponseResult<M, Extract<EP, keyof TESIResponseOKMap[M]>>, HasOpt = HasRequireParams<TESIResponseOKMap[M][Extract<EP, keyof TESIResponseOKMap[M]>]> extends never ? 0 : 1>(fn: TESIRequestFunctionSignature2<ESIRequestOptions> | TESIRequestFunctionMethods2<ESIRequestOptions>, method: M, endpoint: RealEP, ...opt: HasOpt extends 1 ? [Opt] : [Opt?]): Promise<R>;
186
- }["fireWithoutAuth"];
184
+ export type TFireWithoutAuth<ActualOpt = ESIRequestOptions> = <Mtd extends TESIEntryMethod, REP extends ReplacePathParams<ESIEndpointOf<Mtd>> | ESIEndpointOf<Mtd>, EPX extends ResolvedEndpoint<REP, Mtd>, PPM extends InferPathParams<REP, EPX>, Opt extends IdentifyParameters<Mtd, EPX, ActualOpt & PPM>, Ret extends InferESIResponseResult<Mtd, EPX>, HasOpt = HasRequireParams<Mtd, EPX, PPM>, XX = PickRequireParams<Mtd, EPX, PPM>>(fn: TESIRequestFunctionSignature2<ESIRequestOptions> | TESIRequestFunctionMethods2<ESIRequestOptions>, method: Mtd, endpoint: REP, ...opt: HasOpt extends 1 ? [Opt] : [Opt?]) => Promise<Ret>;
185
+ export interface IFireWithoutAuth<ActualOpt = ESIRequestOptions> {
186
+ <Mtd extends TESIEntryMethod, REP extends ReplacePathParams<ESIEndpointOf<Mtd>> | ESIEndpointOf<Mtd>, EPX extends ResolvedEndpoint<REP, Mtd>, PPM extends InferPathParams<REP, EPX>, Opt extends IdentifyParameters<Mtd, EPX, ActualOpt & PPM>, Ret extends InferESIResponseResult<Mtd, EPX>, HasOpt = HasRequireParams<Mtd, EPX, PPM>, XX = PickRequireParams<Mtd, EPX, PPM>>(fn: TESIRequestFunctionSignature2<ActualOpt> | TESIRequestFunctionMethods2<ActualOpt>, method: Mtd, endpoint: REP, ...opt: HasOpt extends 1 ? [Opt] : [Opt?]): Promise<Ret>;
187
+ }
187
188
  /**
188
189
  * Need typescript v5.5 later
189
190
  * @import * as ESI from "../v2";
package/lib/rq-util.mjs CHANGED
@@ -320,19 +320,38 @@ export function getLogger() {
320
320
  const rlog = consoleUtil.getLogger("- - -> Run ESI request".cyan);
321
321
  return { clog, rlog };
322
322
  }
323
+ /* ctt
324
+ // Result: `/characters/${number}/fittings/${number}/`
325
+ type Example = ReplacePathParams<"/characters/{character_id}/fittings/{fitting_id}/">;
326
+
327
+ // Result: "/characters/{character_id}/fittings/{fitting_id}/"
328
+ type ResovedEP = ResolvedEndpoint<"/characters/123/fittings/456/", "delete">;
329
+ // Result: "/characters/{character_id}/fittings/{fitting_id}/"
330
+ type ResovedEP2 = ResolvedEndpoint<"/characters/{character_id}/fittings/{fitting_id}/", "delete">;
331
+ type IncompleteEP = ResolvedEndpoint<"/characters/1234/fittings/{fitting_id}/", "delete">;
332
+
333
+ // Result: "/characters/{character_id}/fittings/{fitting_id}/"
334
+ type EPOriginOK = InferEndpointOrigin<"/characters/123/fittings/456/", "delete">;
335
+ // result: never
336
+ type EPOriginNever = InferEndpointOrigin<"/characters/123/fittings/{fitting_id}/", "delete">;
337
+ // result: never
338
+ type EPOriginNever2 = InferEndpointOrigin<"/characters/{character_id}/fittings/456/", "delete">;
339
+ /*/
340
+ //*/
323
341
  /**
324
342
  * #### Fire a request that does not require authentication.
325
343
  *
326
344
  * @type {import("./rq-util.d.mts").TFireWithoutAuth}
327
345
  */
328
- // @ts-expect-error
329
- const fireWithoutAuth = (fn, method, endpoint, opt) => {
346
+ // @ts-expect -error
347
+ const fireWithoutAuth = (fn, method, endpoint, ...opt) => {
348
+ const arg = opt.length ? opt[0] : void 0;
330
349
  if (typeof fn === "function") {
331
350
  // @ts-expect-error TODO: ts(2345) The argument type does not match the type of the specified parameter
332
- return fn(method, endpoint, opt);
351
+ return fn(method, endpoint, arg);
333
352
  }
334
353
  // @ts-expect-error TODO: ts(2345) The argument type does not match the type of the specified parameter
335
- return fn[method](endpoint, opt);
354
+ return fn[method](endpoint, arg);
336
355
  };
337
356
  /**
338
357
  * Need typescript v5.5 later
@@ -358,7 +377,9 @@ export async function fireRequestsDoesNotRequireAuth(fn) {
358
377
  // Here, I borrow data from "CCP Zoetrope".
359
378
  clog();
360
379
  casefireWithoutAuth: {
361
- await fireWithoutAuth(fn, "get", `/characters/${ID_CCP_Zoetrope}/`).then(log);
380
+ await fireWithoutAuth(fn, "get", `/characters/{character_id}/`, {
381
+ pathParams: ID_CCP_Zoetrope
382
+ }).then(log);
362
383
  clog('(portrait)');
363
384
  await fireWithoutAuth(fn, "get", `/characters/${ID_CCP_Zoetrope}/portrait/`).then(log);
364
385
  clog('(affiliation)');
@@ -368,10 +389,16 @@ export async function fireRequestsDoesNotRequireAuth(fn) {
368
389
  await fireWithoutAuth(fn, "get", `/corporations/${affiliation[0].corporation_id}/`).then(log);
369
390
  rlog("get:/incursions/".green);
370
391
  await fireWithoutAuth(fn, "get", "/incursions/").then(log);
371
- // fireWithoutAuth(fn, "delete", `/characters/${1234}/fittings/${56789}/`, {
372
- // // pathParams: [1234, 56789],
373
- // auth: true
374
- // }).catch(console.log);
392
+ if (is("withError")) {
393
+ await fireWithoutAuth(fn, "get", "/characters/{character_id}/assets/", {
394
+ auth: true,
395
+ pathParams: 12354
396
+ });
397
+ await fireWithoutAuth(fn, "delete", `/characters/${1234}/fittings/${56789}/`, {
398
+ pathParams: [1234, 56789], // ⚠️ TODO: A semantics error should be deliberately caused here
399
+ auth: true
400
+ }).catch(console.log);
401
+ }
375
402
  }
376
403
  // - - - - - - - - - - - -
377
404
  // Miscellaneous
@@ -53,7 +53,7 @@ export function decoreateESIRequestBody(requestBody) {
53
53
  // DEVNOTE: 2025/03/08 - In reality, you only need one function instance for each of "get", "post", "put", and "delete",
54
54
  // so you can just refer to the cached functions as a map.
55
55
  const methodMap = /** @type {TESIRequestFunctionMethods2<Opt>} */ ({});
56
- /** @type {TESIEntryMethod[]} */ (["get", "post", "put", "delete"]).forEach((method) => {
56
+ /** @satisfies {TESIEntryMethod[]} */ (["get", "post", "put", "delete"]).forEach((method) => {
57
57
  methodMap[method] = /** @type {TESIRequestFunctionEachMethod2<typeof method, Opt>} */ (
58
58
  // @ts-expect-error Type peeling due to differences in inference process
59
59
  (e, opt) => requestBody(method, e, opt));
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "eve-esi-types",
3
- "version": "3.0.4",
3
+ "version": "3.1.2",
4
4
  "description": "Extracted the main type of ESI. use for ESI request response types (version 2 only)",
5
5
  "main": "v2/index.d.ts",
6
6
  "scripts": {
7
- "test": "node v2.mjs -debug",
7
+ "test": "node request-v3.mjs -debug",
8
8
  "test:mini": "node minimal-rq.mjs -debug"
9
9
  },
10
10
  "repository": {
@@ -15,6 +15,7 @@
15
15
  "v2",
16
16
  "lib",
17
17
  "web",
18
+ "docs",
18
19
  "*.d.mts",
19
20
  "*.mjs",
20
21
  "LICENSE",
@@ -92,7 +92,7 @@ async function getEVEStatus(fn) {
92
92
  return fn("get", "/status/");
93
93
  }
94
94
  // type following and run
95
- // node v2.mjs
95
+ // node request-v3.mjs
96
96
  // or yarn test
97
97
  if (!is("x")) {
98
98
  getEVEStatus(fire).then(eveStatus => log(eveStatus));
package/tagged-rq.mjs CHANGED
@@ -43,8 +43,8 @@ if (util.is("withError")) {
43
43
  },
44
44
  // token: "s.s.s"
45
45
  })).then(console.log).catch(console.log);
46
- esi.fittings.delete("/characters/{character_id}/fittings/{fitting_id}/", {
47
- pathParams: [1234, 56789],
46
+ esi.fittings.delete("/characters/1234/fittings/56789/", {
47
+ pathParams: [1234, 56789], // ⚠️ TODO: A semantics error should be deliberately caused here
48
48
  auth: true
49
49
  });
50
50
  esi.character.post("/characters/affiliation/", {