eve-esi-types 3.1.0 → 3.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -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
+ ```
@@ -8,7 +8,7 @@
8
8
 
9
9
  # ESI Types Utility 3.1 Summary
10
10
 
11
- This document provides detailed explanations of each type defined in the `index.d.ts` file.
11
+ This document provides detailed explanations of each type defined in the `eve-esi-types/v2/index.d.ts` file.
12
12
 
13
13
  > ## TESIRequestFunctionSignature2
14
14
 
@@ -70,7 +70,7 @@ export const request2 = /** @type {IESIRequestFunction2} */ (async (method, endp
70
70
  //
71
71
  /** @type {TESIEntryMethod[]} */ (["get", "post", "put", "delete"]).forEach((method) => {
72
72
  request2[method] = /** @type {TESIRequestFunctionEachMethod2<typeof method, util.ESIRequestOptions>} */ ((endpoint, opt) => {
73
- // @ts-expect-error TODO: ts(2345)
74
- return request2(method, endpoint, opt);
73
+ // @ts-expect- error TODO: ts(2345)
74
+ return request2(method, endpoint, /** @type {Parameters<typeof request2>[2]} */ (opt));
75
75
  });
76
76
  });
package/lib/rq-util.d.mts CHANGED
@@ -37,14 +37,6 @@ export type ESIRequestOptions = {
37
37
  * will need it for `POST` request etc.
38
38
  */
39
39
  body?: any;
40
- /**
41
- * cancel request immediately
42
- */
43
- cancelable?: AbortController;
44
- /**
45
- * Can be an empty object if no authentication is required.description
46
- */
47
- token?: TAcccessToken;
48
40
  /**
49
41
  * whether an authorization header is required
50
42
  *
@@ -57,7 +49,15 @@ export type ESIRequestOptions = {
57
49
  * @date 2025/3/13
58
50
  * @since v3.0.0
59
51
  */
60
- pathParams?: number | number[];
52
+ pathParams?: number | [number, number];
53
+ /**
54
+ * Can be an empty object if no authentication is required.description
55
+ */
56
+ token?: TAcccessToken;
57
+ /**
58
+ * cancel request immediately
59
+ */
60
+ cancelable?: AbortController;
61
61
  };
62
62
  /**
63
63
  * @typedef {string | number | boolean} Truthy
@@ -141,7 +141,7 @@ export declare const initOptions: (method: string, opt: ESIRequestOptions) => {
141
141
  * fetch the extra pages
142
142
  *
143
143
  * + if the `x-pages` header property ware more than 1
144
- * @template {any} T
144
+ * @template {unknown} T
145
145
  * @param {string} endpointUrl
146
146
  * @param {RequestInit} rqopt request options
147
147
  * @param {URLSearchParams} usp queries
@@ -181,9 +181,9 @@ export declare function getLogger(): {
181
181
  clog: (...args: any[]) => void;
182
182
  rlog: (...args: any[]) => void;
183
183
  };
184
- export type TFireWithoutAuth = <M extends TESIEntryMethod, RealEP extends ReplacePathParams<ESIEndpointOf<M>> | ESIEndpointOf<M>, EPx extends ResolvedEndpoint<RealEP, M>, PathParams extends InferPathParams<RealEP, EPx>, Opt extends IdentifyParameters<M, EPx, ESIRequestOptions & PathParams>, R extends InferESIResponseResult<M, EPx>, HasOpt = HasRequireParams<M, EPx, PathParams>, XX = PickRequireParams<M, EPx, PathParams>>(fn: TESIRequestFunctionSignature2<ESIRequestOptions> | TESIRequestFunctionMethods2<ESIRequestOptions>, method: M, endpoint: RealEP, ...opt: HasOpt extends 1 ? [Opt] : [Opt?]) => Promise<R>;
185
- export interface IFireWithoutAuth {
186
- <M extends TESIEntryMethod, RealEP extends ReplacePathParams<ESIEndpointOf<M>> | ESIEndpointOf<M>, EPx extends ResolvedEndpoint<RealEP, M>, PathParams extends InferPathParams<RealEP, EPx>, Opt extends IdentifyParameters<M, EPx, ESIRequestOptions & PathParams>, R extends InferESIResponseResult<M, EPx>, HasOpt = HasRequireParams<M, EPx, PathParams>, XX = PickRequireParams<M, EPx, PathParams>>(fn: TESIRequestFunctionSignature2<ESIRequestOptions> | TESIRequestFunctionMethods2<ESIRequestOptions>, method: M, endpoint: RealEP, ...opt: HasOpt extends 1 ? [Opt] : [Opt?]): Promise<R>;
184
+ export type TFireWithoutAuth<ActualOpt extends Record<string, unknown> = ESIRequestOptions> = <Mtd extends TESIEntryMethod, REP extends ReplacePathParams<ESIEndpointOf<Mtd>> | ESIEndpointOf<Mtd>, EPX extends ResolvedEndpoint<REP, Mtd>, PPM extends InferPathParams<REP, EPX>, Opt extends IdentifyParameters<Mtd, EPX, ActualOpt, PPM>, Ret extends InferESIResponseResult<Mtd, EPX>, HasOpt = HasRequireParams<Mtd, EPX, PPM>, XX = PickRequireParams<Mtd, EPX, PPM>>(fn: TESIRequestFunctionSignature2<ESIRequestOptions> | TESIRequestFunctionMethods2<ESIRequestOptions>, method: Mtd, endpoint: REP, ...opt: HasOpt extends 1 ? [Opt] : [Opt?]) => Promise<Ret>;
185
+ export interface IFireWithoutAuth<ActualOpt extends Record<string, unknown> = ESIRequestOptions> {
186
+ <Mtd extends TESIEntryMethod, REP extends ReplacePathParams<ESIEndpointOf<Mtd>> | ESIEndpointOf<Mtd>, EPX extends ResolvedEndpoint<REP, Mtd>, PPM extends InferPathParams<REP, EPX>, Opt extends IdentifyParameters<Mtd, EPX, ActualOpt, PPM>, Ret extends InferESIResponseResult<Mtd, EPX>, HasOpt = HasRequireParams<Mtd, EPX, PPM>, XX = PickRequireParams<Mtd, EPX, PPM>>(fn: TESIRequestFunctionSignature2<ActualOpt> | TESIRequestFunctionMethods2<ActualOpt>, method: Mtd, endpoint: REP, ...opt: HasOpt extends 1 ? [Opt] : [Opt?]): Promise<Ret>;
187
187
  }
188
188
  /**
189
189
  * Need typescript v5.5 later
package/lib/rq-util.mjs CHANGED
@@ -228,7 +228,7 @@ export const initOptions = (method, opt) => {
228
228
  * fetch the extra pages
229
229
  *
230
230
  * + if the `x-pages` header property ware more than 1
231
- * @template {any} T
231
+ * @template {unknown} T
232
232
  * @param {string} endpointUrl
233
233
  * @param {RequestInit} rqopt request options
234
234
  * @param {URLSearchParams} usp queries
@@ -347,8 +347,8 @@ type EPOriginNever2 = InferEndpointOrigin<"/characters/{character_id}/fittings/4
347
347
  const fireWithoutAuth = (fn, method, endpoint, ...opt) => {
348
348
  const arg = opt.length ? opt[0] : void 0;
349
349
  if (typeof fn === "function") {
350
- // @ts-expect-error TODO: ts(2345) The argument type does not match the type of the specified parameter
351
- return fn(method, endpoint, arg);
350
+ // @ts-expect- error TODO: ts(2345) The argument type does not match the type of the specified parameter
351
+ return fn(method, endpoint, /** @type {Parameters<typeof fn>[2]} */ (arg));
352
352
  }
353
353
  // @ts-expect-error TODO: ts(2345) The argument type does not match the type of the specified parameter
354
354
  return fn[method](endpoint, arg);
@@ -378,6 +378,7 @@ export async function fireRequestsDoesNotRequireAuth(fn) {
378
378
  clog();
379
379
  casefireWithoutAuth: {
380
380
  await fireWithoutAuth(fn, "get", `/characters/{character_id}/`, {
381
+ // auth: true, // ✅ At this point, the expected semantic error is successfully triggered as intended.
381
382
  pathParams: ID_CCP_Zoetrope
382
383
  }).then(log);
383
384
  clog('(portrait)');
@@ -395,8 +396,8 @@ export async function fireRequestsDoesNotRequireAuth(fn) {
395
396
  pathParams: 12354
396
397
  });
397
398
  await fireWithoutAuth(fn, "delete", `/characters/${1234}/fittings/${56789}/`, {
398
- pathParams: [1234, 56789], // ⚠️ TODO: A semantics error should be deliberately caused here
399
- auth: true
399
+ auth: true,
400
+ // pathParams: [1234, 56789], // ✅ At this point, the expected semantic error is successfully triggered as intended.
400
401
  }).catch(console.log);
401
402
  }
402
403
  }
package/minimal-rq.mjs CHANGED
@@ -29,8 +29,8 @@ const log = util.getUniversalLogger("[request-mini]: ");
29
29
  const esiMethods = /** @type {TESIRequestFunctionMethods2} */ ({});
30
30
  /** @satisfies {TESIEntryMethod[]} */ (["get", "post", "put", "delete"]).forEach((method) => {
31
31
  esiMethods[method] = /** @type {TESIRequestFunctionEachMethod2<typeof method, util.ESIRequestOptions>} */ ((endpoint, opt) => {
32
- // @ts-expect-error ts(2345)
33
- return request2(method, endpoint, opt);
32
+ // @ts-expect -error ts(2345)
33
+ return request2(method, endpoint, /** @type {Parameters<typeof request2>[2]} */ (opt));
34
34
  });
35
35
  });
36
36
  // It should complete correctly.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eve-esi-types",
3
- "version": "3.1.0",
3
+ "version": "3.1.3",
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": {
@@ -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",
package/tagged-rq.mjs CHANGED
@@ -44,7 +44,7 @@ if (util.is("withError")) {
44
44
  // token: "s.s.s"
45
45
  })).then(console.log).catch(console.log);
46
46
  esi.fittings.delete("/characters/1234/fittings/56789/", {
47
- pathParams: [1234, 56789], // ⚠️ TODO: A semantics error should be deliberately caused here
47
+ // pathParams: [1234, 56789], // At this point, the expected semantic error is successfully triggered as intended.
48
48
  auth: true
49
49
  });
50
50
  esi.character.post("/characters/affiliation/", {
@@ -9,7 +9,7 @@
9
9
  * THIS DTS IS AUTO GENERATED, DO NOT EDIT
10
10
  *
11
11
  * @file eve-esi-types/v2/esi-tagged-types.d.ts
12
- * @summary This file is auto-generated and defines version 3.1.0 of the EVE Online ESI response types.
12
+ * @summary This file is auto-generated and defines version 3.1.3 of the EVE Online ESI response types.
13
13
  */
14
14
  import { TESIResponseOKMap } from "./index.d.ts";
15
15
  export * from "./index.d.ts";
@@ -61,26 +61,51 @@ export declare type ESITags = InferSomethingBy<never, InferSomethingByTags>
61
61
  * @date 2025/2/28
62
62
  */
63
63
  export declare type InferMethod<Tag> = InferSomethingBy<Tag>
64
- // type XAssets = InferMethod<"Assets">;
65
- // type XContacts = InferMethod<"Contacts">;
66
- // type XPlanetary = InferMethod<"Planetary Interaction">;
64
+ /* ctt
65
+ type XAssets = InferMethod<"Assets">;
66
+ type XContacts = InferMethod<"Contacts">;
67
+ type XPlanetary = InferMethod<"Planetary Interaction">;
68
+ /*/
69
+ //*/
67
70
 
68
71
  // - - - - - - - - - - - - - - - - - - - - - - - - - -
69
72
  // Utility Type `TaggedEndpointRequestFunction2`
70
73
  // - - - - - - - - - - - - - - - - - - - - - - - - - -
74
+ /**
75
+ * Infers the endpoint origin based on the provided endpoints.
76
+ *
77
+ * + Customed InferEndpointOrigin
78
+ *
79
+ * @template RealEP - The real endpoint type.
80
+ * @template Endpoints - The possible endpoints.
81
+ *
82
+ * @typeParam RealEP - The type of the real endpoint.
83
+ * @typeParam Endpoints - The type of the possible endpoints.
84
+ *
85
+ * @returns The inferred endpoint origin.
86
+ */
87
+ type _InferEndpointOrigin<
88
+ RealEP extends unknown, Endpoints extends string | number | symbol
89
+ > = {
90
+ [EP in Endpoints]: RealEP extends ReplacePathParams<EP>
91
+ ? EP : never;
92
+ }[Endpoints];
93
+
71
94
  /**
72
95
  * Creates a function type for making requests to tagged endpoints.
73
96
  *
74
97
  * @template M - The HTTP method.
75
98
  * @template Tag - The tag associated with the endpoint.
76
99
  * @template ActualOpt - The actual options for the request.
77
- * @template EP - The endpoint path.
78
- * @template P2 - The path parameters.
100
+ * @template EndPoints - The possible endpoints.
101
+ * @template REP - The real endpoint path.
102
+ * @template EPX - The inferred endpoint origin.
103
+ * @template PPM - The path parameters.
79
104
  * @template Opt - The request options.
80
- * @template R - The response type.
105
+ * @template Ret - The response type.
106
+ * @template HasOpt - Indicates if the endpoint has required parameters.
81
107
  *
82
108
  * @param endpoint - The endpoint path.
83
- * @param pathParams - The path parameters.
84
109
  * @param options - An optional object containing additional options for the request. If the endpoint has required parameters, this parameter must be provided.
85
110
  * @returns A promise that resolves to the response.
86
111
  *
@@ -88,17 +113,18 @@ export declare type InferMethod<Tag> = InferSomethingBy<Tag>
88
113
  * The `...options: HasOpt extends 1 ? [Opt] : [Opt?]` parameter is defined this way to enforce that if the endpoint has required parameters,
89
114
  * the `options` parameter must be provided. If there are no required parameters, the `options` parameter is optional.
90
115
  */
91
- // TODO: 2025/3/16 1:20:50 Generics bug maybe OK?
92
- export declare type TaggedEndpointRequestFunction2<M extends TESIEntryMethod, Tag extends ESITags, ActualOpt = {}> = <
93
- RealEP extends ReplacePathParams<ESIEndpointOf<M>> | ESIEndpointOf<M>,
94
- EPx extends ResolvedEndpoint<RealEP, M>,
95
- PathParams extends InferPathParams<RealEP, EPx>,
96
- Opt extends IdentifyParameters<M, EPx, ActualOpt & PathParams>,
97
- R extends InferESIResponseResult<M, EPx>,
98
- HasOpt = HasRequireParams<M, EPx, PathParams>,
99
- // RealEPX = ReplacePathParamsX<RealEPX>,
100
- // EPX = ReplacePathParams<EP>,
101
- >(endpoint: RealEP, ...options: HasOpt extends 1 ? [Opt] : [Opt?]) => Promise<R>;
116
+ export declare type TaggedEndpointRequestFunction2<
117
+ M extends TESIEntryMethod, Tag extends ESITags,
118
+ ActualOpt extends Record<string, unknown> = {},
119
+ EndPoints extends SelectEndpointByTag<Tag, M> = SelectEndpointByTag<Tag, M>,
120
+ > = <
121
+ REP extends ReplacePathParams<EndPoints> | EndPoints,
122
+ EPX extends _InferEndpointOrigin<REP, EndPoints> extends never ? REP: _InferEndpointOrigin<REP, EndPoints>,
123
+ PPM extends InferPathParams<REP, EPX>,
124
+ Opt extends IdentifyParameters<M, EPX, ActualOpt, PPM>,
125
+ Ret extends InferESIResponseResult<M, EPX>,
126
+ HasOpt = HasRequireParams<M, EPX, PPM>,
127
+ >(endpoint: REP, ...options: HasOpt extends 1 ? [Opt] : [Opt?]) => Promise<Ret>;
102
128
 
103
129
 
104
130
  // - - - - - - - - - - - - - - - - - - - - - - - - - -
@@ -108,9 +134,10 @@ export declare type TaggedEndpointRequestFunction2<M extends TESIEntryMethod, Ta
108
134
  * Maps tags to their corresponding endpoint request functions.
109
135
  *
110
136
  * @template Tag - The tag to map.
137
+ * @template ActualOpt - The actual options for the request.
111
138
  * @date 2025/2/28
112
139
  */
113
- export declare type ESITaggedEndpointRequest2<Tag extends ESITags, ActualOpt = {}> = {
140
+ export declare type ESITaggedEndpointRequest2<Tag extends ESITags, ActualOpt extends Record<string, unknown> = {}> = {
114
141
  [tag in Tag]: {
115
142
  [method in InferMethod<Tag>]: TaggedEndpointRequestFunction2<method, tag, ActualOpt>;
116
143
  };
@@ -135,14 +162,19 @@ export declare type SelectEndpointByTag<
135
162
  ? EP : never
136
163
  : never;
137
164
  }[keyof TESIResponseOKMap[M]];
138
- // type XAssetsEndpointGet = SelectEndpointByTag<"Assets", "get">;
139
- // type XAssetsEndpointPost = SelectEndpointByTag<"Assets", "post">;
165
+ /* ctt
166
+ type XAssetsEndpointGet = SelectEndpointByTag<"Assets", "get">;
167
+ type XAssetsEndpointPost = SelectEndpointByTag<"Assets", "post">;
168
+ /*/
169
+ //*/
140
170
 
141
171
  /**
142
172
  * Maps lower camel case tags to their corresponding endpoint request functions.
173
+ *
174
+ * @template ActualOpt - The actual options for the request.
143
175
  * @date 2025/3/12
144
176
  */
145
- export declare type TaggedESIRequestMap2<ActualOpt = {}> = {
177
+ export declare type TaggedESIRequestMap2<ActualOpt extends Record<string, unknown> = {}> = {
146
178
  [tag in ESITags as LCamelCase<tag>]: ESITaggedEndpointRequest2<tag, ActualOpt>;
147
179
  };
148
180
 
package/v2/index.d.ts CHANGED
@@ -9,7 +9,7 @@
9
9
  * THIS DTS IS AUTO GENERATED, DO NOT EDIT
10
10
  *
11
11
  * @file eve-esi-types/v2/index.d.ts
12
- * @summary This file is auto-generated and defines version 3.1.0 of the EVE Online ESI response types.
12
+ * @summary This file is auto-generated and defines version 3.1.3 of the EVE Online ESI response types.
13
13
  */
14
14
  import type { TESIResponseOKMap } from "./response-map.d.ts";
15
15
  export type { TESIResponseOKMap } from "./response-map.d.ts";
@@ -163,6 +163,56 @@ export type __IdentifyParameters<
163
163
  // @ts-expect-error
164
164
  > = RequireThese<Opt, Keys> & Pick<Entry, Keys>;
165
165
 
166
+ // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
167
+ // Internal types
168
+ // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
169
+ /**
170
+ * Defines the keys used in ESI entries.
171
+ */
172
+ type ESIEntryKeys = "auth" | "query" | "body" | "pathParams";
173
+ /**
174
+ * Restricts the keys of a type to the specified ones while excluding extra keys.
175
+ *
176
+ * This utility type is designed to enforce stricter semantics by marking unwanted keys as `never`.
177
+ *
178
+ * @template T - The original type to be constrained.
179
+ * @template T2 - The type to merge with the constrained type.
180
+ * @template K - The keys to retain in the resulting type.
181
+ * @template Extras - Automatically derived keys to exclude from the resulting type.
182
+ *
183
+ * @example
184
+ * ```ts
185
+ * type Original = { auth?: string; query?: string; body?: string; pathParams?: string; extra?: string };
186
+ * type Required = { auth: true; query: { test: "pen" | "pencil" } };
187
+ * type Restricted = RestrictKeys<Original, Required, "auth" | "query">;
188
+ * // Result: { auth: true; query: { test: "pen" | "pencil" }; body?: undefined; pathParams?: undefined; extra?: string | undefined }
189
+ * ```
190
+ */
191
+ //* ctt
192
+ type RestrictKeys<
193
+ T, K extends keyof T,
194
+ Extras = Exclude<ESIEntryKeys, K>
195
+ > = {
196
+ [P in keyof T]: P extends K ? Pick<T, P>[P] :
197
+ P extends Extras ? never : T[P];
198
+ };
199
+ // type RequireEntry = {
200
+ // auth?: true;
201
+ // query?: { test: "pen" | "pencil" };
202
+ // body?: string;
203
+ // pathParams?: string;
204
+ // extra?: string
205
+ // };
206
+ // type Restricted = RestrictKeys<RequireEntry, "auth" | "query">;
207
+ /*/
208
+ type RestrictKeys<
209
+ T, T2,
210
+ K extends keyof T,
211
+ Extras = Exclude<ESIEntryKeys, K>
212
+ > = T2 & {
213
+ [P in keyof T as P extends K ? never : P]: P extends Extras ? never : T[P];
214
+ };
215
+ //*/
166
216
 
167
217
  declare global {
168
218
 
@@ -195,12 +245,12 @@ declare global {
195
245
  * This function sends a request to a specified endpoint and returns a response.
196
246
  *
197
247
  * @template ActualOpt - The actual type of the option.
198
- * @template M - The HTTP method to use for the request
199
- * @template RealEP - The real path of the ESI endpoint to send the request to
200
- * @template EP - The parameterized path of the ESI endpoint to send the request to
201
- * @template PathParams - Parameters to include in the request if the endpoint is parameterized
248
+ * @template Mtd - The HTTP method to use for the request
249
+ * @template REP - The real path of the ESI endpoint to send the request to
250
+ * @template EPX - The parameterized path of the ESI endpoint to send the request to
251
+ * @template PPM - Parameters to include in the request if the endpoint is parameterized
202
252
  * @template Opt - Options to include in the request. If there is a required parameter, its type will be merged with `ActualOpt`
203
- * @template R - The response type
253
+ * @template Ret - The response type
204
254
  *
205
255
  * @param method - The HTTP method to use for the request (e.g., "get", "post").
206
256
  * @param endpoint - The real path of the ESI endpoint to send the request to.
@@ -213,28 +263,28 @@ declare global {
213
263
  * the `options` parameter must be provided. If there are no required parameters, the `options` parameter is optional.
214
264
  */
215
265
  type TESIRequestFunctionSignature2<ActualOpt> = <
216
- M extends TESIEntryMethod,
217
- RealEP extends ReplacePathParams<ESIEndpointOf<M>> | ESIEndpointOf<M>,
218
- EPx extends ResolvedEndpoint<RealEP, M>,
219
- PathParams extends InferPathParams<RealEP, EPx>,
220
- Opt extends IdentifyParameters<M, EPx, ActualOpt & PathParams>,
221
- R extends InferESIResponseResult<M, EPx>,
222
- HasOpt = HasRequireParams<M, EPx, PathParams>,
223
- >(method: M, endpoint: RealEP, ...options: HasOpt extends 1 ? [Opt] : [Opt?]) => Promise<R>;
266
+ Mtd extends TESIEntryMethod,
267
+ REP extends ReplacePathParams<ESIEndpointOf<Mtd>> | ESIEndpointOf<Mtd>,
268
+ EPX extends ResolvedEndpoint<REP, Mtd>,
269
+ PPM extends InferPathParams<REP, EPX>,
270
+ Opt extends IdentifyParameters<Mtd, EPX, ActualOpt, PPM>,
271
+ Ret extends InferESIResponseResult<Mtd, EPX>,
272
+ HasOpt = HasRequireParams<Mtd, EPX, PPM>,
273
+ >(method: Mtd, endpoint: REP, ...options: HasOpt extends 1 ? [Opt] : [Opt?]) => Promise<Ret>;
224
274
 
225
275
  /**
226
276
  * Represents a function that can make ESI requests for a specific HTTP method.
227
277
  *
228
278
  * This type is used to define functions that send requests to specific ESI endpoints using a given HTTP method.
229
279
  *
230
- * @template M - The HTTP method to use for the request.
280
+ * @template Mtd - The HTTP method to use for the request.
231
281
  * @template ActualOpt - The actual type of the options.
232
282
  *
233
- * @template RealEP - The real path of the ESI endpoint to send the request to.
234
- * @template EP - The parameterized path of the ESI endpoint to send the request to.
235
- * @template PathParams - Parameters to include in the request if the endpoint is parameterized.
283
+ * @template REP - The real path of the ESI endpoint to send the request to.
284
+ * @template EPX - The parameterized path of the ESI endpoint to send the request to.
285
+ * @template PPM - Parameters to include in the request if the endpoint is parameterized.
236
286
  * @template Opt - Options to include in the request. If there is a required parameter, its type will be merged with `ActualOpt`.
237
- * @template R - The response type.
287
+ * @template Ret - The response type.
238
288
  *
239
289
  * @param endpoint - The real path of the ESI endpoint to send the request to.
240
290
  * @param options - An optional object containing additional options for the request. If the endpoint has required parameters, this parameter must be provided.
@@ -245,14 +295,14 @@ declare global {
245
295
  * The `...options: HasOpt extends 1 ? [Opt] : [Opt?]` parameter is defined this way to enforce that if the endpoint has required parameters,
246
296
  * the `options` parameter must be provided. If there are no required parameters, the `options` parameter is optional.
247
297
  */
248
- type TESIRequestFunctionEachMethod2<M extends TESIEntryMethod, ActualOpt = {}> = <
249
- RealEP extends ReplacePathParams<ESIEndpointOf<M>> | ESIEndpointOf<M>,
250
- EPx extends ResolvedEndpoint<RealEP, M>,
251
- PathParams extends InferPathParams<RealEP, EPx>,
252
- Opt extends IdentifyParameters<M, EPx, ActualOpt & PathParams>,
253
- R extends InferESIResponseResult<M, EPx>,
254
- HasOpt = HasRequireParams<M, EPx, PathParams>,
255
- >(endpoint: RealEP, ...options: HasOpt extends 1 ? [Opt] : [Opt?]) => Promise<R>;
298
+ type TESIRequestFunctionEachMethod2<Mtd extends TESIEntryMethod, ActualOpt = {}> = <
299
+ REP extends ReplacePathParams<ESIEndpointOf<Mtd>> | ESIEndpointOf<Mtd>,
300
+ EPX extends ResolvedEndpoint<REP, Mtd>,
301
+ PPM extends InferPathParams<REP, EPX>,
302
+ Opt extends IdentifyParameters<Mtd, EPX, ActualOpt, PPM>,
303
+ Ret extends InferESIResponseResult<Mtd, EPX>,
304
+ HasOpt extends HasRequireParams<Mtd, EPX, PPM> = HasRequireParams<Mtd, EPX, PPM>,
305
+ >(endpoint: REP, ...options: HasOpt extends 1 ? [Opt] : [Opt?]) => Promise<Ret>;
256
306
 
257
307
  /**
258
308
  * Replaces path parameters in a string with numbers.
@@ -426,20 +476,23 @@ declare global {
426
476
  M extends TESIEntryMethod,
427
477
  EPx extends ESIEndpointOf<M> | string,
428
478
  Opt extends Record<string, unknown>,
479
+ AdditionalParams,
429
480
  Entry = _ESIResponseType<M, EPx>,
430
- Keys = Exclude<keyof Entry, "result" | "tag" | "cachedSeconds">
431
- // @ts-expect-error
432
- > = RequireThese<Opt, Keys> & Pick<Entry, Keys>;
481
+ Keys = Exclude<keyof (Entry & AdditionalParams), "result" | "tag" | "cachedSeconds">
482
+ // @ts-expect- error
483
+ > = RestrictKeys<Opt, Keys> & Pick<Entry, Keys> & AdditionalParams;
433
484
  /*/
485
+ // DEVNOTE: 2025/3/24
486
+ // The definition is simple and highly maintainable, but it is not possible to reference the `pathParams` property when implementing `TESIRequestFunctionSignature2` etc.
434
487
  type IdentifyParameters<
435
- Entry, Opt,
436
- Keys = Exclude<keyof Entry, "result" | "tag" | "cachedSeconds">
437
- // @ts-expect-error
438
- > = RequireThese<Opt, Keys> & Pick<Entry, Keys>;
439
- // type IdentifyParameters<
440
- // Entry, Opt,
441
- // Keys = Exclude<keyof Entry, "result">
442
- // > = Opt & (Keys extends keyof Entry ? Pick<Entry, Keys> : {});
488
+ M extends TESIEntryMethod,
489
+ EPx extends ESIEndpointOf<M> | string,
490
+ Opt extends Record<string, unknown>,
491
+ AdditionalParams,
492
+ Entry = _ESIResponseType<M, EPx>,
493
+ Keys = Exclude<keyof (Entry & AdditionalParams), "result" | "tag" | "cachedSeconds">
494
+ // @ts-expect- error
495
+ > = RestrictKeys<Opt, Pick<Entry, Keys> & AdditionalParams, Keys>;
443
496
  //*/
444
497
 
445
498
  /**
@@ -9,7 +9,7 @@
9
9
  * THIS DTS IS AUTO GENERATED, DO NOT EDIT
10
10
  *
11
11
  * @file eve-esi-types/v2/response-map.d.ts
12
- * @summary This file is auto-generated and defines version 3.1.0 of the EVE Online ESI response types.
12
+ * @summary This file is auto-generated and defines version 3.1.3 of the EVE Online ESI response types.
13
13
  */
14
14
  import "./types-index.d.ts";
15
15
 
@@ -9,7 +9,7 @@
9
9
  * THIS DTS IS AUTO GENERATED, DO NOT EDIT
10
10
  *
11
11
  * @file eve-esi-types/v2/types-index.d.ts
12
- * @summary This file is auto-generated and defines version 3.1.0 of the EVE Online ESI response types.
12
+ * @summary This file is auto-generated and defines version 3.1.3 of the EVE Online ESI response types.
13
13
  */
14
14
  import "./get_wars_ok.d.ts";
15
15
  import "./get_status_ok.d.ts";