eve-esi-types 3.2.6 → 3.2.8

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.
@@ -9,14 +9,16 @@
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.5 of the EVE Online ESI response types.
12
+ * @summary This file is auto-generated and defines version 3.2.8 of the EVE Online ESI response types.
13
13
  */
14
14
  import type { TESIResponseOKMap } from "./response-map.d.ts";
15
- import type { PickPathParameters, InferKeysLen, CombineIntersection } from "./util.d.ts";
15
+ import type { PickPathParameters, InferKeysLen, CombineIntersection, ExtractPathParamKeys } from "./util.d.ts";
16
16
  import type {
17
+ ESIEntryParamKeys, ESIEntryExtraKeys,
17
18
  _ESIResponseType,
18
19
  _IfNeedPathParams,
19
20
  TPathParamsNever,
21
+ ResolveEndpointParameters
20
22
  // ESIEndpointUnions,
21
23
  // IESIRequestFunction2,
22
24
  // InferESIResponseResultEX,
@@ -31,19 +33,15 @@ export type * from "./util.d.ts";
31
33
  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
32
34
  // Internal types
33
35
  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
34
- /**
35
- * Defines the keys used in ESI entries.
36
- */
37
- type ESIEntryKeys = "auth" | "query" | "body" | "pathParams";
38
36
  /**
39
37
  * Restricts the keys of a type to the specified ones while excluding extra keys.
40
38
  *
41
39
  * This utility type is designed to enforce stricter semantics by marking unwanted keys as `never`.
42
40
  *
43
- * @template T - The original type to be constrained.
44
- * @template T2 - The type to merge with the constrained type.
45
- * @template RequireKeys - The keys to retain in the resulting type.
46
- * @template Extras - Automatically derived keys to exclude from the resulting type.
41
+ * @template T The original type to be constrained.
42
+ * @template T2 The type to merge with the constrained type.
43
+ * @template RequireKeys The keys to retain in the resulting type.
44
+ * @template Extras Automatically derived keys to exclude from the resulting type.
47
45
  *
48
46
  * @example
49
47
  * ```ts
@@ -57,7 +55,7 @@ type ESIEntryKeys = "auth" | "query" | "body" | "pathParams";
57
55
  // incomplete
58
56
  export type RestrictKeys<
59
57
  T, RequireKeys/* extends keyof T */,
60
- Extras = Exclude<ESIEntryKeys, RequireKeys>
58
+ Extras = Exclude<ESIEntryParamKeys, RequireKeys>
61
59
  > = {
62
60
  [P in keyof T]: P extends Extras ? never : T[P];
63
61
  };
@@ -70,13 +68,13 @@ export type RestrictKeys2<
70
68
  {
71
69
  [RQ in keyof T as RQ extends RequireKeys ? RQ : never]-?: T[RQ];
72
70
  } &
73
- // 2. Exclude extra keys from ESIEntryKeys and assign `never`
71
+ // 2. Exclude extra keys from ESIEntryParamKeys and assign `never`
74
72
  {
75
- [Extra in ESIEntryKeys as Extra extends Extras ? Extra : never]?: never;
73
+ [Extra in ESIEntryParamKeys as Extra extends Extras ? Extra : never]?: never;
76
74
  } &
77
- // 3. Include remaining keys (not in ESIEntryKeys) as optional with their original types
75
+ // 3. Include remaining keys (not in ESIEntryParamKeys) as optional with their original types
78
76
  {
79
- [Other in keyof T as Other extends Extras ? (Other extends ESIEntryKeys ? never : Other) : never]?: T[Other];
77
+ [Other in keyof T as Other extends Extras ? (Other extends ESIEntryParamKeys ? never : Other) : never]?: T[Other];
80
78
  }
81
79
  ) extends infer O
82
80
  // Flatten the intersected type into a single object
@@ -91,8 +89,8 @@ declare global {
91
89
  /**
92
90
  * Marks specific properties of a type as required.
93
91
  *
94
- * @template T - The original type.
95
- * @template K - The keys of the properties to mark as required.
92
+ * @template T The original type.
93
+ * @template K The keys of the properties to mark as required.
96
94
  *
97
95
  * @example
98
96
  * ```ts
@@ -112,141 +110,216 @@ declare global {
112
110
  // Version 3 types
113
111
  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
114
112
  /**
115
- * ### ESI request function with real endpoint signature
116
- *
117
- * TESIRequestFunctionSignature2 is a type that defines the signature of an ESI request function
118
- * where the endpoint can be a real endpoint or a parameterized endpoint.
119
- *
120
- * This function sends a request to a specified endpoint and returns a response.
121
- *
122
- * @template ActualOpt - The actual type of the option.
123
- * @template Mtd - The HTTP method to use for the request
124
- * @template REP - The real path of the ESI endpoint to send the request to
125
- * @template EPX - The parameterized path of the ESI endpoint to send the request to
126
- * @template PPM - Parameters to include in the request if the endpoint is parameterized
127
- * @template Opt - Options to include in the request. If there is a required parameter, its type will be merged with `ActualOpt`
128
- * @template Ret - The response type
129
- *
113
+ * Defines the function signature for making ESI requests to specific endpoints.
114
+ *
115
+ * This utility type provides a strongly-typed function signature for interacting with ESI endpoints.
116
+ * It ensures type safety by inferring the required parameters, options, and response types for the given endpoint.
117
+ *
118
+ * @template ActualOpt - A record type representing additional options for the request.
119
+ * @template Mtd - The HTTP method (e.g., "get", "post") to use for the request.
120
+ * @template REP - The real path of the ESI endpoint to send the request to.
121
+ * @template EPO - The parameterized path of the ESI endpoint (e.g., `/characters/{character_id}/assets/`).
122
+ * @template Params - The resolved parameters for the endpoint, including path parameters and user-supplied options.
123
+ * @template Opt - The final options object to include in the request.
124
+ * @template Ret - The response type of the endpoint.
125
+ *
130
126
  * @param method - The HTTP method to use for the request (e.g., "get", "post").
131
127
  * @param endpoint - The real path of the ESI endpoint to send the request to.
132
128
  * @param options - An optional object containing additional options for the request. If the endpoint has required parameters, this parameter must be provided.
133
- *
134
- * @returns A Promise object containing the response data, with the type inferred based on the method and endpoint.
135
- *
129
+ *
130
+ * @returns A `Promise` that resolves to the response type of the endpoint.
131
+ *
136
132
  * @remarks
137
- * The `...options: HasOpt extends 1 ? [Opt] : [Opt?]` parameter is defined this way to enforce that if the endpoint has required parameters,
138
- * the `options` parameter must be provided. If there are no required parameters, the `options` parameter is optional.
133
+ * - The `...options: Params["optionIsRequire"] extends 1 ? [Opt] : [Opt?]` parameter ensures that if the endpoint has required parameters,
134
+ * the `options` parameter must be provided. If there are no required parameters, the `options` parameter is optional.
135
+ * - This type leverages `ResolveEndpointParameters` to infer the required options and response type.
136
+ *
137
+ * @example
138
+ * ```ts
139
+ * // Example: Making a request to the "get" method for a specific endpoint
140
+ * type ESIRequest = TESIRequestFunctionSignature2<ESIRequestOptions>;
141
+ * const runRequest: ESIRequest = async (method, endpoint, ...options) => {
142
+ * // Implementation here
143
+ * throw new Error();
144
+ * };
145
+ * runRequest("get", "/characters/{character_id}/assets/", {
146
+ * pathParams: 12345,
147
+ * auth: true,
148
+ * token: "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9..."
149
+ * }).then(response => {
150
+ * console.log(response);
151
+ * });
152
+ * ```
153
+ *
154
+ * @see {@link ResolveEndpointParameters}
155
+ * @see {@link InferESIResponseResult}
139
156
  */
157
+ /* ctt
140
158
  type TESIRequestFunctionSignature2<ActualOpt extends Record<string, unknown>> = <
141
159
  Mtd extends TESIEntryMethod,
142
160
  REP extends ReplacePathParams<ESIEndpointOf<Mtd>> | ESIEndpointOf<Mtd>,
143
- EPX extends ResolvedEndpoint<REP, Mtd>,
144
- PPM extends InferPathParams<REP, EPX>,
145
- Opt extends IdentifyParameters<Mtd, EPX, ActualOpt, PPM>,
146
- Ret extends InferESIResponseResult<Mtd, EPX>,
147
- HasOpt = HasRequireParams<Mtd, EPX, PPM>,
161
+ EPO extends ResolvedEndpoint<Mtd, REP>,
162
+ PPM extends InferPathParams<REP, EPO>,
163
+ Opt extends IdentifyParameters<Mtd, EPO, ActualOpt, PPM>,
164
+ Ret extends InferESIResponseResult<Mtd, EPO>,
165
+ HasOpt = HasRequireParams<Mtd, EPO, PPM>,
148
166
  >(method: Mtd, endpoint: REP, ...options: HasOpt extends 1 ? [Opt] : [Opt?]) => Promise<Ret>;
149
-
150
-
151
- type TESIRequestFunctionContext<
152
- Mtd extends TESIEntryMethod = TESIEntryMethod,
153
- REP extends ReplacePathParams<ESIEndpointOf<Mtd>> | ESIEndpointOf<Mtd> = ReplacePathParams<ESIEndpointOf<Mtd>> | ESIEndpointOf<Mtd>,
154
- ActualOpt extends Record<string, unknown> = Record<string, unknown>,
155
-
156
- EPX extends ResolvedEndpoint<REP, Mtd> = ResolvedEndpoint<REP, Mtd>,
157
- PPM extends InferPathParams<REP, EPX> = InferPathParams<REP, EPX>,
158
- Opt extends IdentifyParameters<Mtd, EPX, ActualOpt, PPM> = IdentifyParameters<Mtd, EPX, ActualOpt, PPM>,
159
- Ret extends InferESIResponseResult<Mtd, EPX> = InferESIResponseResult<Mtd, EPX>,
160
- HasOpt = HasRequireParams<Mtd, EPX, PPM>,
161
- > = {
162
- method: Mtd; endpoint: REP;
163
- } & (HasOpt extends 1 ? { options: Opt } : { options?: Opt }) & {
164
- result?: Ret;
165
- };
167
+ /*/
168
+ type TESIRequestFunctionSignature2<ActualOpt extends Record<string, unknown>> = <
169
+ Mtd extends TESIEntryMethod,
170
+ REP extends ReplacePathParams<ESIEndpointOf<Mtd>> | ESIEndpointOf<Mtd>,
171
+ EPO extends ResolvedEndpoint<Mtd, REP>,
172
+ Params extends ResolveEndpointParameters<Mtd, REP, EPO, ActualOpt>,
173
+ Opt extends Params["finalOptions"],
174
+ // Ret extends Params["result"],
175
+ >(method: Mtd, endpoint: REP, ...options: Params["optionIsRequire"] extends 1 ? [Opt] : [Opt?]) => Promise<Params["result"]>;
176
+ //*/
166
177
 
167
178
  /**
168
- * A function signature type for making enhanced ESI requests.
179
+ * Defines an enhanced function signature for making ESI requests with an additional prepended parameter.
169
180
  *
170
- * This type extends the base ESI request function signature by injecting a prepended parameter to allow for extra
171
- * context or pre-processing before performing the request. It provides a highly generic interface that adapts to the
172
- * chosen endpoint method, endpoint configuration, and additional options, making it ideal for advanced API interactions.
181
+ * This utility type extends the base ESI request function signature by adding a prepended parameter
182
+ * to allow for extra context or pre-processing before performing the request. It ensures type safety
183
+ * by inferring the required parameters, options, and response types for the given endpoint.
173
184
  *
174
- * Generic Parameters:
175
185
  * @template PrependParam - The type of the additional parameter that is injected at the beginning of the function call.
176
- * @template ActualOpt - An object representing the default options (typically extending ESIRequestOptions) used for the request.
186
+ * @template ActualOpt - A record type representing additional options for the request.
187
+ *
188
+ * @param prependParam - A prepended parameter providing additional context or configuration for the request.
189
+ * @param method - The HTTP method to use for the request (e.g., "get", "post").
190
+ * @param endpoint - The API endpoint, which might include path parameter replacements.
191
+ * @param options - Additional options for the request. If the endpoint has required parameters, this parameter must be provided.
177
192
  *
178
- * Function Generic Parameters:
179
- * @template Mtd - The ESI request method type (e.g., GET, POST) as defined in TESIEntryMethod.
180
- * @template REP - The endpoint type, which can be either a version with replaced path parameters (via ReplacePathParams)
181
- * or the raw ESIEndpointOf<Mtd> type.
182
- * @template EPX - The resolved endpoint type derived from REP and Mtd.
183
- * @template PPM - The type representing the inferred path parameters extracted from REP and EPX.
184
- * @template Opt - The type for additional request options, identified based on the method (Mtd), endpoint (EPX), the
185
- * default options (ActualOpt), and inferred path parameters (PPM).
186
- * @template Ret - The type of the response result from the ESI request, inferred from the method and endpoint.
187
- * @template HasOpt - An internal flag used to determine whether request options (Opt) are required (1) or optional.
193
+ * @returns A `Promise` that resolves to the response type of the endpoint.
188
194
  *
189
- * Parameters:
190
- * @param {PrependParam} prependParam - A prepended parameter providing additional context or configuration for the request.
191
- * @param {Mtd} method - The ESI request method.
192
- * @param {REP} endpoint - The API endpoint, which might include path parameter replacements.
193
- * @param {...(HasOpt extends 1 ? [Opt] : [Opt?])} options - Additional options for the request; required if HasOpt is 1,
194
- * otherwise optional.
195
+ * @remarks
196
+ * - The `...options: Params["optionIsRequire"] extends 1 ? [Opt] : [Opt?]` parameter ensures that if the endpoint has required parameters,
197
+ * the `options` parameter must be provided. If there are no required parameters, the `options` parameter is optional.
198
+ * - This type leverages `ResolveEndpointParameters` to infer the required options and response type.
199
+ *
200
+ * @example
201
+ * ```ts
202
+ * // Example: Making a request with an additional prepended parameter
203
+ * type EnhancedRequest = TESIEnhancedRequestFunctionSignature<
204
+ * { userId: string },
205
+ * ESIRequestOptions
206
+ * >;
207
+ * const fetchWithContext: EnhancedRequest = async (context, method, endpoint, ...options) => {
208
+ * console.log(`User ID: ${context.userId}`);
209
+ * // Implementation here
210
+ * throw new Error();
211
+ * };
212
+ * fetchWithContext(
213
+ * { userId: "12345" },
214
+ * "get",
215
+ * "/characters/{character_id}/assets/",
216
+ * {
217
+ * pathParams: 12345,
218
+ * auth: true,
219
+ * token: "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9..."
220
+ * }
221
+ * ).then(response => {
222
+ * console.log(response);
223
+ * });
224
+ * ```
195
225
  *
196
- * @returns {Promise<Ret>} A promise that resolves with the result type `Ret`, representing the response data from the ESI endpoint.
226
+ * @see {@link ResolveEndpointParameters}
227
+ * @see {@link InferESIResponseResult}
197
228
  * @see Documentation of [`TESIEnhancedRequestFunctionSignature`](https://github.com/jeffy-g/eve-esi-types/blob/master/docs/v3/esi-enhanced-function-signature.md)
198
229
  */
230
+ /* ctt
199
231
  type TESIEnhancedRequestFunctionSignature<
200
232
  PrependParam extends unknown, ActualOpt extends Record<string, unknown>
201
233
  > = <
202
234
  Mtd extends TESIEntryMethod,
203
235
  REP extends ReplacePathParams<ESIEndpointOf<Mtd>> | ESIEndpointOf<Mtd>,
204
- EPX extends ResolvedEndpoint<REP, Mtd>,
205
- PPM extends InferPathParams<REP, EPX>,
206
- Opt extends IdentifyParameters<Mtd, EPX, ActualOpt, PPM>,
207
- Ret extends InferESIResponseResult<Mtd, EPX>,
208
- HasOpt = HasRequireParams<Mtd, EPX, PPM>
236
+ EPO extends ResolvedEndpoint<Mtd, REP>,
237
+ PPM extends InferPathParams<REP, EPO>,
238
+ Opt extends IdentifyParameters<Mtd, EPO, ActualOpt, PPM>,
239
+ Ret extends InferESIResponseResult<Mtd, EPO>,
240
+ HasOpt = HasRequireParams<Mtd, EPO, PPM>,
209
241
  >(
210
242
  prependParam: PrependParam,
211
243
  method: Mtd, endpoint: REP, ...options: HasOpt extends 1 ? [Opt] : [Opt?]
212
244
  ) => Promise<Ret>;
245
+ /*/
246
+ type TESIEnhancedRequestFunctionSignature<
247
+ PrependParam extends unknown, ActualOpt extends Record<string, unknown>
248
+ > = <
249
+ Mtd extends TESIEntryMethod,
250
+ REP extends ReplacePathParams<ESIEndpointOf<Mtd>> | ESIEndpointOf<Mtd>,
251
+ EPO extends ResolvedEndpoint<Mtd, REP>,
252
+ Params extends ResolveEndpointParameters<Mtd, REP, EPO, ActualOpt>,
253
+ Opt extends Params["finalOptions"],
254
+ >(
255
+ prependParam: PrependParam,
256
+ method: Mtd, endpoint: REP,
257
+ ...options: Params["optionIsRequire"] extends 1 ? [Opt] : [Opt?]
258
+ ) => Promise<Params["result"]>;
259
+ //*/
213
260
 
214
261
  /**
215
- * Represents a function that can make ESI requests for a specific HTTP method.
262
+ * Defines the function signature for making ESI requests for a specific HTTP method.
216
263
  *
217
- * This type is used to define functions that send requests to specific ESI endpoints using a given HTTP method.
264
+ * This utility type provides a strongly-typed function signature for interacting with ESI endpoints
265
+ * using a specific HTTP method. It ensures type safety by inferring the required parameters, options,
266
+ * and response types for the given endpoint.
218
267
  *
219
- * @template Mtd - The HTTP method to use for the request.
220
- * @template ActualOpt - The actual type of the options.
268
+ * @template Mtd - The HTTP method (e.g., "get", "post") to use for the request.
269
+ * @template ActualOpt - A record type representing additional options for the request.
221
270
  *
222
- * @template REP - The real path of the ESI endpoint to send the request to.
223
- * @template EPX - The parameterized path of the ESI endpoint to send the request to.
224
- * @template PPM - Parameters to include in the request if the endpoint is parameterized.
225
- * @template Opt - Options to include in the request. If there is a required parameter, its type will be merged with `ActualOpt`.
226
- * @template Ret - The response type.
271
+ * @param endpoint - The API endpoint, which might include path parameter replacements.
272
+ * @param options - Additional options for the request. If the endpoint has required parameters, this parameter must be provided.
227
273
  *
228
- * @param endpoint - The real path of the ESI endpoint to send the request to.
229
- * @param options - An optional object containing additional options for the request. If the endpoint has required parameters, this parameter must be provided.
274
+ * @returns A `Promise` that resolves to the response type of the endpoint.
230
275
  *
231
- * @returns A Promise object containing the response data, with the type inferred based on the method and endpoint.
232
- *
233
276
  * @remarks
234
- * The `...options: HasOpt extends 1 ? [Opt] : [Opt?]` parameter is defined this way to enforce that if the endpoint has required parameters,
235
- * the `options` parameter must be provided. If there are no required parameters, the `options` parameter is optional.
277
+ * - The `...options: Params["optionIsRequire"] extends 1 ? [Opt] : [Opt?]` parameter ensures that if the endpoint has required parameters,
278
+ * the `options` parameter must be provided. If there are no required parameters, the `options` parameter is optional.
279
+ * - This type leverages `ResolveEndpointParameters` to infer the required options and response type.
280
+ *
281
+ * @example
282
+ * ```ts
283
+ * // Example: Making a request to the "get" method for a specific endpoint
284
+ * type GetRequest = TESIRequestFunctionEachMethod2<"get", ESIRequestOptions>;
285
+ * const fireGetRequest: GetRequest = async (endpoint, ...options) => {
286
+ * // Implementation here
287
+ * throw new Error();
288
+ * };
289
+ * fireGetRequest("/characters/{character_id}/assets/", {
290
+ * pathParams: 12345,
291
+ * auth: true,
292
+ * token: "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9..."
293
+ * }).then(response => {
294
+ * console.log(response);
295
+ * });
296
+ * ```
297
+ *
298
+ * @see {@link ResolveEndpointParameters}
299
+ * @see {@link InferESIResponseResult}
236
300
  */
301
+ /* ctt
237
302
  type TESIRequestFunctionEachMethod2<Mtd extends TESIEntryMethod, ActualOpt extends Record<string, unknown>> = <
238
303
  REP extends ReplacePathParams<ESIEndpointOf<Mtd>> | ESIEndpointOf<Mtd>,
239
- EPX extends ResolvedEndpoint<REP, Mtd>,
240
- PPM extends InferPathParams<REP, EPX>,
241
- Opt extends IdentifyParameters<Mtd, EPX, ActualOpt, PPM>,
242
- Ret extends InferESIResponseResult<Mtd, EPX>,
243
- HasOpt extends HasRequireParams<Mtd, EPX, PPM> = HasRequireParams<Mtd, EPX, PPM>,
304
+ EPO extends ResolvedEndpoint<Mtd, REP>,
305
+ PPM extends InferPathParams<REP, EPO>,
306
+ Opt extends IdentifyParameters<Mtd, EPO, ActualOpt, PPM>,
307
+ Ret extends InferESIResponseResult<Mtd, EPO>,
308
+ HasOpt = HasRequireParams<Mtd, EPO, PPM>,
244
309
  >(endpoint: REP, ...options: HasOpt extends 1 ? [Opt] : [Opt?]) => Promise<Ret>;
310
+ /*/
311
+ type TESIRequestFunctionEachMethod2<Mtd extends TESIEntryMethod, ActualOpt extends Record<string, unknown>> = <
312
+ REP extends ReplacePathParams<ESIEndpointOf<Mtd>> | ESIEndpointOf<Mtd>,
313
+ EPO extends ResolvedEndpoint<Mtd, REP>,
314
+ Params extends ResolveEndpointParameters<Mtd, REP, EPO, ActualOpt>,
315
+ Opt extends Params["finalOptions"],
316
+ >(endpoint: REP, ...options: Params["optionIsRequire"] extends 1 ? [Opt] : [Opt?]) => Promise<Params["result"]>;
317
+ //*/
245
318
 
246
319
  /**
247
320
  * Replaces path parameters in a string with numbers.
248
321
  *
249
- * @template T - The string representing the endpoint path.
322
+ * @template T The string representing the endpoint path.
250
323
  * @type {string}
251
324
  * @example
252
325
  * ```ts
@@ -257,7 +330,7 @@ declare global {
257
330
  */
258
331
  type ReplacePathParams<T extends unknown> = T extends `${infer Start}{${infer Param}}${infer End}`
259
332
  ? `${Start}${number}${ReplacePathParams<End>}` : T;
260
- // type XEPP = ESIEndpointOf<"delete">
333
+
261
334
  // // incomplete
262
335
  // type Example2 = ReplacePathParams<"/characters/1234/fittings/{fitting_id}/">;
263
336
  // // Result: `characters/${number}/fittings/${number}/`
@@ -266,17 +339,17 @@ declare global {
266
339
  /**
267
340
  * Infers the path parameters based on the real endpoint and the resolved endpoint.
268
341
  *
269
- * @template RealEP - The real endpoint path.
270
- * @template EPx - The resolved endpoint path.
271
- * @returns {TPathParamsNever | _IfNeedPathParams<EPx>}
342
+ * @template RealEP The real endpoint path.
343
+ * @template EPO (Endpoint Path Origin) The resolved endpoint path.
344
+ * @returns {TPathParamsNever | _IfNeedPathParams<EPO>}
272
345
  * @see {@link _IfNeedPathParams}
273
346
  * @see {@link TPathParamsNever}
274
347
  * @see Documentation of [`InferPathParams`](https://github.com/jeffy-g/eve-esi-types/blob/master/docs/v3/infer-path-params.md)
275
348
  * @date 2025/3/17
276
349
  */
277
350
  type InferPathParams<
278
- RealEP extends unknown, EPx extends unknown
279
- > = RealEP extends EPx ? _IfNeedPathParams<EPx> : TPathParamsNever;
351
+ RealEP extends PropertyKey, EPO extends PropertyKey
352
+ > = RealEP extends EPO ? _IfNeedPathParams<EPO> : TPathParamsNever;
280
353
 
281
354
  /**
282
355
  * Infers the original endpoint based on the real endpoint and the HTTP method.
@@ -284,9 +357,9 @@ declare global {
284
357
  * This type maps the real endpoint to its corresponding parameterized endpoint
285
358
  * by checking if the real endpoint matches the pattern of any parameterized endpoint.
286
359
  *
287
- * @template RealEP - The real endpoint path.
288
- * @template M - The HTTP method to use for the request.
289
- * @template Endpoints - The possible endpoints for the given method.
360
+ * @template RealEP The real endpoint path.
361
+ * @template M The HTTP method to use for the request.
362
+ * @template Endpoints The possible endpoints for the given method.
290
363
  *
291
364
  * @example
292
365
  * ```ts
@@ -298,7 +371,7 @@ declare global {
298
371
  * @see Documentation of [`InferEndpointOrigin`](https://github.com/jeffy-g/eve-esi-types/blob/master/docs/v3/infer-endpoint-origin.md)
299
372
  */
300
373
  type InferEndpointOrigin<
301
- RealEP extends unknown, M extends TESIEntryMethod,
374
+ M extends TESIEntryMethod, RealEP extends PropertyKey,
302
375
  Endpoints extends ESIEndpointOf<M> = ESIEndpointOf<M>
303
376
  > = {
304
377
  [EP in Endpoints]: RealEP extends ReplacePathParams<EP>
@@ -307,8 +380,8 @@ declare global {
307
380
  /**
308
381
  * Determines the resolved endpoint based on the real endpoint and the method.
309
382
  *
310
- * @template RealEP - The real endpoint path.
311
- * @template M - The HTTP method to use for the request.
383
+ * @template RealEP The real endpoint path.
384
+ * @template M The HTTP method to use for the request.
312
385
  *
313
386
  * @example
314
387
  * ```ts
@@ -319,45 +392,19 @@ declare global {
319
392
  * @see Documentation of [`ResolvedEndpoint`](https://github.com/jeffy-g/eve-esi-types/blob/master/docs/v3/resolved-endpoint.md)
320
393
  */
321
394
  type ResolvedEndpoint<
322
- RealEP extends unknown, M extends TESIEntryMethod,
323
- > = InferEndpointOrigin<RealEP, M> extends never ? RealEP: InferEndpointOrigin<RealEP, M>;
324
-
325
- /**
326
- * Picks the required parameters from an entry type, including additional parameters.
327
- *
328
- * This type excludes the keys "result", "tag", and "cachedSeconds" from the entry type and the additional parameters,
329
- * and returns the remaining keys as the required parameters.
330
- *
331
- * @template M - The HTTP method to use for the request.
332
- * @template EPx - The endpoint path.
333
- * @template AdditionalParams - Additional parameters to include in the check.
334
- * @template Entry - The entry type to pick parameters from.
335
- *
336
- * @example
337
- * ```ts
338
- * type ExampleEntry = { result: string, tag: string, cachedSeconds: number, auth: string };
339
- * type RequiredParams = PickRequireParams<"get", "/example/endpoint", { auth: string }, ExampleEntry>;
340
- * // Result: "auth"
341
- * ```
342
- * @see {@link ESIEndpointOf}
343
- * @see {@link _ESIResponseType}
344
- * @see Documentation of [`PickRequireParams`](https://github.com/jeffy-g/eve-esi-types/blob/master/docs/v3/pick-require-params.md)
345
- */
346
- type PickRequireParams<
347
395
  M extends TESIEntryMethod,
348
- EPx extends ESIEndpointOf<M> | string,
349
- AdditionalParams,
350
- Entry = _ESIResponseType<M, EPx>
351
- > = Exclude<keyof (Entry & AdditionalParams), "result" | "tag" | "cachedSeconds">;
396
+ RealEP extends PropertyKey,
397
+ > = InferEndpointOrigin<M, RealEP> extends never ? RealEP: InferEndpointOrigin<M, RealEP>;
398
+
352
399
  /**
353
400
  * Determines if the given entry has required parameters, including additional options.
354
401
  *
355
402
  * This type checks if an entry has any required parameters by excluding the keys "result", "tag", and "cachedSeconds".
356
403
  * If any keys remain after this exclusion, it means the entry has required parameters.
357
404
  *
358
- * @template M - The HTTP method to use for the request.
359
- * @template EPx - The endpoint path.
360
- * @template AdditionalParams - Additional parameters to include in the check.
405
+ * @template M The HTTP method to use for the request.
406
+ * @template EPx The endpoint path.
407
+ * @template PathParams Path parameters to include in the check.
361
408
  *
362
409
  * @example
363
410
  * ```ts
@@ -365,82 +412,120 @@ declare global {
365
412
  * type HasRequired = HasRequireParams<"get", "/example/endpoint", { auth: string }>; // 1
366
413
  * ```
367
414
  * @see {@link ESIEndpointOf}
368
- * @see {@link PickRequireParams}
369
415
  * @see Documentation of [`HasRequireParams`](https://github.com/jeffy-g/eve-esi-types/blob/master/docs/v3/has-require-params.md)
370
416
  */
417
+ /* ctt
371
418
  type HasRequireParams<
372
419
  M extends TESIEntryMethod,
373
420
  EPx extends ESIEndpointOf<M> | string,
374
421
  AdditionalParams,
375
422
  > = PickRequireParams<M, EPx, AdditionalParams> extends never ? 0 : 1;
423
+ /*/
424
+ type HasRequireParams<
425
+ M extends TESIEntryMethod,
426
+ EPx extends ESIEndpointOf<M> | string,
427
+ PathParams extends Record<string, unknown>,
428
+ RequireKeys = Exclude<keyof (_ESIResponseType<M, EPx> & PathParams), ESIEntryExtraKeys>
429
+ > = [RequireKeys] extends [never] ? 0 : 1;
430
+ //*/
376
431
 
377
432
  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
378
433
  // Version 2 types
379
434
  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
380
435
  /**
381
- * If `EP` (endpoint) is a parameterized path, determines the required number of replacements.
382
- *
383
- * @template EP The string representing the endpoint path.
384
- * @template Opt The type to return if `EP` is not parameterized.
385
- * @returns {number | [number, number] | Opt}
386
- * Returns `number` if there is one parameter, `[number, number]` if there are two parameters, otherwise `Opt`.
387
- * @see Documentation of [`IfParameterizedPath`](https://github.com/jeffy-g/eve-esi-types/blob/master/docs/v2/if-parameterized-path.md)
436
+ * Determines the number of parameters in a parameterized endpoint path.
437
+ *
438
+ * This utility type checks if the given endpoint path contains parameters (e.g., `{param}`) and returns:
439
+ * - `number` if there is one parameter.
440
+ * - `[number, number]` if there are two parameters.
441
+ * - `never` if there are no parameters.
442
+ *
443
+ * @template EP - The string representing the endpoint path.
444
+ * @returns {number | [number, number] | never} The number of parameters in the path.
445
+ *
446
+ * @example
447
+ * ```ts
448
+ * type SingleParam = IfParameterizedPath<"/characters/{character_id}/">;
449
+ * // Result: number
450
+ *
451
+ * type TwoParams = IfParameterizedPath<"/characters/{character_id}/assets/{asset_id}/">;
452
+ * // Result: [number, number]
453
+ *
454
+ * type NoParams = IfParameterizedPath<"/characters/1234/">;
455
+ * // Result: 0
456
+ * ```
457
+ * @see {@link ExtractPathParamKeys}
388
458
  */
389
- type IfParameterizedPath<EP extends unknown, Opt = never> = EP extends `${string}/{${string}}${string}`
459
+ /* ctt
460
+ type IfParameterizedPath<EP extends PropertyKey> = EP extends `${string}/{${string}}${string}`
390
461
  ? PickPathParameters<EP> extends never
391
- ? Opt : InferKeysLen<PickPathParameters<EP>> extends 1
462
+ ? 0 : InferKeysLen<PickPathParameters<EP>> extends 1
392
463
  ? number : [number, number]
393
- : Opt;
464
+ : 0;
465
+ /*/
466
+ export type IfParameterizedPath<EP extends PropertyKey> =
467
+ ExtractPathParamKeys<EP> extends []
468
+ ? 0 : ExtractPathParamKeys<EP> extends [any]
469
+ ? number : ExtractPathParamKeys<EP> extends [any, any]
470
+ ? [number, number]
471
+ : never;
472
+ //*/
394
473
 
395
474
  /**
396
- * Identifies the required parameters for a given entry type, including additional options.
475
+ * Identifies and combines the required request parameters for a given ESI entry.
397
476
  *
398
- * This type combines the required parameters from the entry type and the additional options,
399
- * ensuring that all required parameters are marked as required.
477
+ * Given:
478
+ * - `Opt`: the shape of user-supplied options (e.g., query/body/path params),
479
+ * - `_ESIResponseType<M, EPx>`: the expected response payload type for method `M` and endpoint `EPx`,
480
+ * - `PathParams`: the path parameters for the endpoint,
481
+ *
482
+ * this type:
483
+ * 1. Merges `_ESIResponseType<M, EPx>` with `PathParams` to form `EntryWithParams`.
484
+ * 2. Excludes extra metadata keys (`result`, `tag`, `cachedSeconds`) from `EntryWithParams`, yielding `RequireKeys`.
485
+ * 3. Restricts `Opt` to only the keys in `RequireKeys`.
486
+ * 4. Picks those `RequireKeys` from `EntryWithParams`.
487
+ * 5. Flattens the intersection into a single parameter object via `CombineIntersection`.
488
+ *
489
+ * @template M The HTTP method (e.g., "get", "post") of the request.
490
+ * @template EPx The endpoint path, constrained to `ESIEndpointOf<M>` or `string`.
491
+ * @template Opt A record type of user-supplied request options.
492
+ * @template PathParams A record type representing path parameters for the endpoint.
493
+ * @template EntryWithParams The merged type of response payload and `PathParams`.
494
+ * @template RequireKeys The keys from `EntryWithParams` that represent actual request parameters.
400
495
  *
401
- * @template M - The HTTP method to use for the request.
402
- * @template EPx - The endpoint path.
403
- * @template Opt - The type of the additional options.
404
- * @template Entry - The entry type to identify parameters for.
405
- * @template RequireKeys - The keys of the entry type that are required parameters.
406
- *
407
496
  * @example
408
497
  * ```ts
409
- * type ExampleEntry = { result: string, tag: string, cachedSeconds: number, auth: string };
410
- * type ExampleOpt = { auth: string };
411
- * type IdentifiedParams = IdentifyParameters<"get", "/example/endpoint", ExampleOpt, ExampleEntry>;
412
- * // Result: { auth: string } & { auth: string }
498
+ * // /characters/{character_id}/attributes/
499
+ * type ExampleEntry = { result: GetCharactersCharacterIdAttributesOk; tag: "Skills"; cachedSeconds: 120; auth: true };
500
+ * type ExampleOpt = { auth: true; token: "eyJhbGciOiJSUzI1NiIsI..." };
501
+ * type ExamplePath = { pathParams: number };
502
+ *
503
+ * // Assume _ESIResponseType<"get", "/characters/{character_id}/attributes/"> = ExampleEntry
504
+ * type IdentifiedParams = IdentifyParameters<
505
+ * "get", "/characters/{character_id}/attributes/", ExampleOpt, ExamplePath
506
+ * >;
507
+ * // Resolves to: { auth: true; token: "eyJhbGciOiJSUzI1NiIsI..."; pathParams: number; }
413
508
  * ```
414
- * @see {@link RequireThese}
415
509
  * @see {@link ESIEndpointOf}
416
510
  * @see {@link _ESIResponseType}
417
511
  * @see Documentation of [`IdentifyParameters`](https://github.com/jeffy-g/eve-esi-types/blob/master/docs/v2/identify-parameters.md)
418
512
  */
419
- /* ctt
420
513
  type IdentifyParameters<
421
514
  M extends TESIEntryMethod,
422
515
  EPx extends ESIEndpointOf<M> | string,
423
516
  Opt extends Record<string, unknown>,
424
- PathParams,
517
+ PathParams extends Record<string, unknown>,
425
518
  EntryWithParams = _ESIResponseType<M, EPx> & PathParams,
426
- RequireKeys extends keyof EntryWithParams = Exclude<keyof EntryWithParams, "result" | "tag" | "cachedSeconds">
427
- > = RestrictKeys<Opt, RequireKeys> & Pick<EntryWithParams, RequireKeys>;
428
- /*/
429
- type IdentifyParameters<
430
- M extends TESIEntryMethod,
431
- EPx extends ESIEndpointOf<M> | string,
432
- Opt extends Record<string, unknown>,
433
- PathParams,
434
- EntryWithParams = _ESIResponseType<M, EPx> & PathParams,
435
- RequireKeys extends keyof EntryWithParams = Exclude<keyof EntryWithParams, "result" | "tag" | "cachedSeconds">
436
- > = CombineIntersection< RestrictKeys<Opt, RequireKeys> & Pick<EntryWithParams, RequireKeys> >;
437
- //*/
519
+ RequireKeys extends keyof EntryWithParams = Exclude<keyof EntryWithParams, ESIEntryExtraKeys>
520
+ > = CombineIntersection<
521
+ RestrictKeys<Opt, RequireKeys> & Pick<EntryWithParams, RequireKeys>
522
+ >;
438
523
 
439
524
  /**
440
525
  * Infers the result type of an ESI response based on the method and endpoint.
441
526
  *
442
- * @template M - The HTTP method to use for the request.
443
- * @template EPx - The endpoint path.
527
+ * @template M The HTTP method to use for the request.
528
+ * @template EPx The endpoint path.
444
529
  *
445
530
  * @example
446
531
  * ```ts
@@ -511,25 +596,25 @@ declare global {
511
596
  /**
512
597
  * Represents the entry details for the "get" method.
513
598
  *
514
- * @template K - The endpoint key.
599
+ * @template K The endpoint key.
515
600
  */
516
601
  type TESIResponseGetEntry<K extends TEndPointGet> = TESIResponseOKMap["get"][K];
517
602
  /**
518
603
  * Represents the entry details for the "put" method.
519
604
  *
520
- * @template K - The endpoint key.
605
+ * @template K The endpoint key.
521
606
  */
522
607
  type TESIResponsePutEntry<K extends TEndPointPut> = TESIResponseOKMap["put"][K];
523
608
  /**
524
609
  * Represents the entry details for the "post" method.
525
610
  *
526
- * @template K - The endpoint key.
611
+ * @template K The endpoint key.
527
612
  */
528
613
  type TESIResponsePostEntry<K extends TEndPointPost> = TESIResponseOKMap["post"][K];
529
614
  /**
530
615
  * Represents the entry details for the "delete" method.
531
616
  *
532
- * @template K - The endpoint key.
617
+ * @template K The endpoint key.
533
618
  */
534
619
  type TESIResponseDeleteEntry<K extends TEndPointDelete> = TESIResponseOKMap["delete"][K];
535
620
  }