eve-esi-types 2.3.5 → 3.0.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/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 2.3.5 of the EVE Online ESI response types.
12
+ * @summary This file is auto-generated and defines version 3.0.2 of the EVE Online ESI response types.
13
13
  */
14
14
 
15
15
  import type { TESIResponseOKMap } from "./response-map.d.ts";
@@ -25,47 +25,47 @@ import type { PickPathParameters, InferKeysLen } from "./util.d.ts";
25
25
  * @example
26
26
  * ```ts
27
27
  * // @ ts-expect-error
28
- * export const request: IESIRequestFunction<ESIRequestOptions> = (method, endpoint, pathParams, opt) => {
28
+ * export const request: IESIRequestFunction2<ESIRequestOptions> = (method, endpoint, opt) => {
29
29
  * // Implementation for "get" | "post" | "put" | "delete" request
30
30
  * };
31
31
  * // You can easily implement "get" | "post" | "put" | "delete" requests
32
32
  * // with code like the following:
33
33
  * (["get", "post", "put", "delete"] as (keyof typeof request)[]).forEach((method) => {
34
- * request[method] = function (this: typeof request, endpoint, params, opt) {
35
- * return this(method, endpoint, params, opt);
36
- * } as TESIRequestFunctionEachMethod<typeof method>;
34
+ * request[method] = function (this: typeof request, endpoint, opt) {
35
+ * return this(method, endpoint, opt);
36
+ * } as TESIRequestFunctionEachMethod2<typeof method>;
37
37
  * });
38
38
  * ```
39
39
  */
40
- export interface IESIRequestFunction<ActualOpt>
41
- extends TESIRequestFunctionSignature<ActualOpt>, TESIRequestFunctionMethods<ActualOpt> {
40
+ export interface IESIRequestFunction2<ActualOpt>
41
+ extends TESIRequestFunctionSignature2<ActualOpt>, TESIRequestFunctionMethods2<ActualOpt> {
42
42
  }
43
43
 
44
44
  /**
45
45
  * Represents the methods available for making ESI requests.
46
46
  *
47
47
  * + This interface is used when you already have implementation code such as
48
- * TESIRequestFunctionSignature and you want to implement additional shorthand methods.
48
+ * TESIRequestFunctionSignature2 and you want to implement additional shorthand methods.
49
49
  *
50
50
  * @template ActualOpt - The actual type of the options.
51
51
  *
52
52
  * @example
53
53
  * ```ts
54
- * export const request: TESIRequestFunctionSignature<ESIRequestOptions> = (method, endpoint, pathParams, opt) => {
54
+ * export const request: TESIRequestFunctionSignature2<ESIRequestOptions> = (method, endpoint, opt) => {
55
55
  * // Implementation for "get" | "post" | "put" | "delete" request
56
56
  * };
57
57
  * // You can easily implement "get" | "post" | "put" | "delete" requests
58
58
  * // with code like the following:
59
- * const esiMethods = {} as TESIRequestFunctionMethods<ESIRequestOptions>;
60
- * (["get", "post", "put", "delete"] as (keyof TESIRequestFunctionMethods)[]).forEach((method) => {
61
- * esiMethods[method] = function (endpoint, params, opt) {
62
- * return request(method, endpoint, params, opt);
63
- * } as TESIRequestFunctionEachMethod<typeof method>;
59
+ * const esiMethods = {} as TESIRequestFunctionMethods2<ESIRequestOptions>;
60
+ * (["get", "post", "put", "delete"] as (keyof TESIRequestFunctionMethods2)[]).forEach((method) => {
61
+ * esiMethods[method] = function (endpoint, opt) {
62
+ * return request(method, endpoint, opt);
63
+ * } as TESIRequestFunctionEachMethod2<typeof method>;
64
64
  * });
65
65
  * ```
66
66
  */
67
- export type TESIRequestFunctionMethods<ActualOpt = {}> = {
68
- [method in TESIEntryMethod]: TESIRequestFunctionEachMethod<method, ActualOpt>;
67
+ export type TESIRequestFunctionMethods2<ActualOpt = {}> = {
68
+ [method in TESIEntryMethod]: TESIRequestFunctionEachMethod2<method, ActualOpt>;
69
69
  }
70
70
 
71
71
  /**
@@ -95,6 +95,7 @@ export declare type TESICachedSeconds<
95
95
  // const cacheSecGet: TESICachedSeconds<"get">;
96
96
  // const cache5sec: TESICachedSeconds<"put">;
97
97
  // const cache3600sEndpoint: TESICachedSeconds<"post", 1>;
98
+ export declare type TPathParamsNever = { pathParams?: never };
98
99
 
99
100
  declare global {
100
101
 
@@ -103,63 +104,140 @@ declare global {
103
104
  */
104
105
  type RequireThese<T, K extends keyof T> = T & Required<Pick<T, K>>;
105
106
 
107
+ // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
108
+ // Version 3 types
109
+ // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
106
110
  /**
107
- * If `EP` (endpoint) is a parameterized path, determines the required number of replacements.
111
+ * ### ESI request function with real endpoint signature
108
112
  *
109
- * @template EP The string representing the endpoint path.
110
- * @template Opt The type to return if `EP` is not parameterized.
111
- * @returns {number | [number, number] | Opt}
112
- * Returns `number` if there is one parameter, `[number, number]` if there are two parameters, otherwise `Opt`.
113
- */
114
- type IfParameterizedPath<EP, Opt> = EP extends `${string}/{${string}}${string}`
115
- ? PickPathParameters<EP> extends never
116
- ? Opt : InferKeysLen<PickPathParameters<EP>> extends 1
117
- ? number : [number, number]
118
- : Opt;
119
-
120
- /**
121
- * ### ESI request function all in one signature
122
- *
123
- * TESIRequestFunctionSignature is a type that defines the signature of an ESI request function.
113
+ * TESIRequestFunctionSignature2 is a type that defines the signature of an ESI request function
114
+ * where the endpoint can be a real endpoint or a parameterized endpoint.
124
115
  *
125
116
  * This function sends a request to a specified endpoint and returns a response.
126
117
  *
127
- * @template ActualOpt - The actual type of the option.
128
- * Required parameters inferred by typescript are merged.
118
+ * @template ActualOpt - The actual type of the option.
129
119
  * @template M - The HTTP method to use for the request
130
- * @template EP - The Path of the ESI endpoint to send the request to
131
- * @template P2 - Parameters to include in the request
132
- * @template Opt - Options to include in the request
133
- * If there is a required parameter, its type will be merged with `ActualOpt`
120
+ * @template RealEP - The real path of the ESI endpoint to send the request to
121
+ * @template EP - The parameterized path of the ESI endpoint to send the request to
122
+ * @template PathParams - Parameters to include in the request if the endpoint is parameterized
123
+ * @template Opt - Options to include in the request. If there is a required parameter, its type will be merged with `ActualOpt`
134
124
  * @template R - The response type
125
+ *
126
+ * @param method - The HTTP method to use for the request (e.g., "get", "post").
127
+ * @param endpoint - The real path of the ESI endpoint to send the request to.
128
+ * @param options - An optional object containing additional options for the request.
129
+ *
130
+ * @returns A Promise object containing the response data, with the type inferred based on the method and endpoint.
135
131
  */
136
- type TESIRequestFunctionSignature<ActualOpt> = <
132
+ type TESIRequestFunctionSignature2<ActualOpt> = <
137
133
  M extends TESIEntryMethod,
138
- EP extends keyof TESIResponseOKMap[M],
139
- P2 extends IfParameterizedPath<EP, Opt>,
140
- Opt extends IdentifyParameters<TESIResponseOKMap[M][EP], ActualOpt>,
134
+ // "/characters/123/fittings/456/"
135
+ RealEP extends ReplacePathParams<keyof TESIResponseOKMap[M] & string> | keyof TESIResponseOKMap[M],
136
+ // "/characters/{character_id}/fittings/{fitting_id}/"
137
+ EP extends InferEndpointOrigin<RealEP, keyof TESIResponseOKMap[M]> extends never ? RealEP: InferEndpointOrigin<RealEP, keyof TESIResponseOKMap[M]>,
138
+ // If RealEP points to an endpoint origin (not a replaced endpoint), the path parameter is required
139
+ PathParams extends RealEP extends EP ? IfNeedPathParams<EP>: TPathParamsNever,
140
+ Opt extends IdentifyParameters<TESIResponseOKMap[M][EP], ActualOpt & PathParams>,
141
141
  R extends InferESIResponseResult<M, EP>
142
- >(method: M, endpoint: EP, pathParams?: P2, options?: Opt) => Promise<R>;
142
+ >(method: M, endpoint: RealEP, options?: Opt) => Promise<R>;
143
143
 
144
144
  /**
145
- * Represents a function that makes an ESI request using a specific HTTP method.
145
+ * Represents a function that can make ESI requests for a specific HTTP method.
146
146
  *
147
- * @template M - The HTTP method to use for the request (e.g., "get", "post").
148
- * @template ActualOpt - The actual type of the options to include in the request.
149
- *
150
- * @param endpoint - The path of the ESI endpoint to send the request to.
151
- * @param pathParams - An optional parameter that can be a number, an array of numbers, or other parameters
152
- * depending on whether the path is parameterized.
147
+ * This type is used to define functions that send requests to specific ESI endpoints using a given HTTP method.
148
+ *
149
+ * @template M - The HTTP method to use for the request.
150
+ * @template ActualOpt - The actual type of the options.
151
+ *
152
+ * @template RealEP - The real path of the ESI endpoint to send the request to.
153
+ * @template EP - The parameterized path of the ESI endpoint to send the request to.
154
+ * @template PathParams - Parameters to include in the request if the endpoint is parameterized.
155
+ * @template Opt - Options to include in the request. If there is a required parameter, its type will be merged with `ActualOpt`.
156
+ * @template R - The response type.
157
+ *
158
+ * @param endpoint - The real path of the ESI endpoint to send the request to.
153
159
  * @param options - An optional object containing additional options for the request.
154
- *
160
+ *
155
161
  * @returns A Promise object containing the response data, with the type inferred based on the method and endpoint.
156
162
  */
157
- type TESIRequestFunctionEachMethod<M extends TESIEntryMethod, ActualOpt = {}> = <
158
- EP extends keyof TESIResponseOKMap[M],
159
- P2 extends IfParameterizedPath<EP, Opt>,
160
- Opt extends IdentifyParameters<TESIResponseOKMap[M][EP], ActualOpt>,
163
+ type TESIRequestFunctionEachMethod2<M extends TESIEntryMethod, ActualOpt = {}> = <
164
+ RealEP extends ReplacePathParams<keyof TESIResponseOKMap[M] & string> | keyof TESIResponseOKMap[M],
165
+ EP extends InferEndpointOrigin<RealEP, keyof TESIResponseOKMap[M]> extends never ? RealEP: InferEndpointOrigin<RealEP, keyof TESIResponseOKMap[M]>,
166
+ PathParams extends RealEP extends EP ? IfNeedPathParams<EP>: TPathParamsNever,
167
+ Opt extends IdentifyParameters<TESIResponseOKMap[M][EP], ActualOpt & PathParams>,
161
168
  R extends InferESIResponseResult<M, EP>
162
- >(endpoint: EP, pathParams?: P2, options?: Opt) => Promise<R>;
169
+ >(endpoint: RealEP, options?: Opt) => Promise<R>;
170
+
171
+ /**
172
+ * Replaces path parameters in a string with numbers.
173
+ *
174
+ * @template T - The string representing the endpoint path.
175
+ * @example
176
+ * ```ts
177
+ * type Example = ReplacePathParams<"/characters/{character_id}/fittings/{fitting_id}/">;
178
+ * // Result: `/characters/${number}/fittings/${number}/`
179
+ * ```
180
+ */
181
+ type ReplacePathParams<T extends string> = T extends `${infer Start}{${infer Param}}${infer End}`
182
+ ? `${Start}${number}${ReplacePathParams<End>}` : T;
183
+
184
+ // // type Example = ReplacePathParamsX<"/characters/1234/fittings/{fitting_id}/">;
185
+ // // Result: `characters/${number}/fittings/${number}/`
186
+ // type ReplacePathParamsX<T extends string> =
187
+ // T extends `/${infer Start}/${infer Param}/${infer End}` ? `${Start}/${number}/${ReplacePathParams<End>}`
188
+ // : T;
189
+ /**
190
+ * Determines if the endpoint requires path parameters.
191
+ *
192
+ * @template EP - The string representing the endpoint path.
193
+ * @returns {TPathParamsNever | { pathParams: IfParameterizedPath<EP> }}
194
+ * Returns an object with `pathParams` if the endpoint requires parameters, otherwise returns `TPathParamsNever`.
195
+ * @example
196
+ * ```ts
197
+ * type Example = IfNeedPathParams<"/characters/{character_id}/fittings/{fitting_id}/">;
198
+ * // Result: { pathParams: [number, number] }
199
+ * ```
200
+ */
201
+ type IfNeedPathParams<EP> = IfParameterizedPath<EP> extends never ? TPathParamsNever :
202
+ EP extends ReplacePathParams<EP> ? TPathParamsNever : { pathParams: IfParameterizedPath<EP> };
203
+ /**
204
+ * Infers the original endpoint path from a real endpoint path.
205
+ *
206
+ * @template RealEP - The real endpoint path.
207
+ * @returns {string} The original endpoint path with parameters.
208
+ * @example
209
+ * ```ts
210
+ * type EPOrigin = InferEndpointOrigin<"/characters/123/fittings/456/", TEndPointDelete>;
211
+ * // Result: "/characters/{character_id}/fittings/{fitting_id}/"
212
+ * ```
213
+ */
214
+ type InferEndpointOrigin<RealEP extends unknown, Endpoints> = {
215
+ [EP in Endpoints]: RealEP extends ReplacePathParams<EP>
216
+ ? EP : never;
217
+ }[Endpoints];
218
+ // type InferEndpointOrigin<RealEP extends string> = {
219
+ // [Method in TESIEntryMethod]: {
220
+ // [EP in keyof TESIResponseOKMap[Method]]: RealEP extends ReplacePathParams<EP>
221
+ // ? EP : never;
222
+ // }[keyof TESIResponseOKMap[Method]]
223
+ // }[TESIEntryMethod];
224
+
225
+ // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
226
+ // Version 2 types
227
+ // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
228
+ /**
229
+ * If `EP` (endpoint) is a parameterized path, determines the required number of replacements.
230
+ *
231
+ * @template EP The string representing the endpoint path.
232
+ * @template Opt The type to return if `EP` is not parameterized.
233
+ * @returns {number | [number, number] | Opt}
234
+ * Returns `number` if there is one parameter, `[number, number]` if there are two parameters, otherwise `Opt`.
235
+ */
236
+ type IfParameterizedPath<EP, Opt = never> = EP extends `${string}/{${string}}${string}`
237
+ ? PickPathParameters<EP> extends never
238
+ ? Opt : InferKeysLen<PickPathParameters<EP>> extends 1
239
+ ? number : [number, number]
240
+ : Opt;
163
241
 
164
242
  /**
165
243
  * Identifies the required parameters for a given entry type.
@@ -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 2.3.5 of the EVE Online ESI response types.
12
+ * @summary This file is auto-generated and defines version 3.0.2 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 2.3.5 of the EVE Online ESI response types.
12
+ * @summary This file is auto-generated and defines version 3.0.2 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";
package/v2.d.mts CHANGED
@@ -5,26 +5,16 @@
5
5
  https://opensource.org/licenses/mit-license.php
6
6
  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
7
7
  */
8
- import type { TESIResponseOKMap } from "./v2";
9
8
  import { type ESIRequestOptions } from "./lib/rq-util.mjs";
10
9
  /**
11
10
  * @returns Get The Current ESI request pending count.
12
11
  */
13
12
  export declare const getRequestPending: () => number;
14
13
  /**
15
- * fire ESI request
16
- * @template {TESIEntryMethod} M
17
- * @template {keyof TESIResponseOKMap[M]} EP
18
- * @template {IfParameterizedPath<EP, Opt>} P2
19
- * @template {IdentifyParameters<TESIResponseOKMap[M][EP], ESIRequestOptions>} Opt
20
- * @template {InferESIResponseResult<M, EP>} R
14
+ * fire ESI request ESIRequestOptions
21
15
  *
22
- * @param {M} mthd
23
- * @param {EP} endp - The endpoint to request.
24
- * @param {Opt} [opt] - default is empty object {}. `body` is json string
25
- * @param {P2} [pathParams] - Optional path parameters.
26
- * @returns {Promise<R>} - The response from the endpoint.
27
- * @throws
16
+ * @type {TESIRequestFunctionSignature2<ESIRequestOptions>}
17
+ * @throws {ESIRequestError}
28
18
  * @async
29
19
  */
30
- export declare function fire<M extends TESIEntryMethod, EP extends keyof TESIResponseOKMap[M], P2 extends IfParameterizedPath<EP, Opt>, Opt extends IdentifyParameters<TESIResponseOKMap[M][EP], ESIRequestOptions>, R extends InferESIResponseResult<M, EP>>(mthd: M, endp: EP, pathParams?: P2, opt?: Opt): Promise<R>;
20
+ export declare const fire: TESIRequestFunctionSignature2<ESIRequestOptions>;
package/v2.mjs CHANGED
@@ -1,3 +1,15 @@
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
+ /// <reference types="./v2"/>
9
+ // - - - - - - - - - - - - - - - - - - - -
10
+ // imports
11
+ // - - - - - - - - - - - - - - - - - - - -
12
+ // import type { TESIResponseOKMap, TPathParamsNever } from "./v2";
1
13
  // import type { TESIResponseOKMap } from "eve-esi-types";
2
14
  import { is, curl, replaceCbt, getSDEVersion, initOptions, isDebug, fireRequestsDoesNotRequireAuth, isSuccess, handleESIError, handleSuccessResponse } from "./lib/rq-util.mjs";
3
15
  // - - - - - - - - - - - - - - - - - - - -
@@ -13,6 +25,8 @@ let LOG = isDebug();
13
25
  /**
14
26
  * @typedef {import("./v2").TESIResponseOKMap} TESIResponseOKMap
15
27
  * @typedef {import("./lib/rq-util.mjs").ESIRequestOptions} ESIRequestOptions
28
+ * @typedef {import("./lib/rq-util.mjs").ESIRequestError} ESIRequestError
29
+ * @typedef {import("./lib/rq-util.mjs").Truthy} Truthy
16
30
  */
17
31
  // - - - - - - - - - - - - - - - - - - - -
18
32
  // module vars, functions
@@ -21,6 +35,7 @@ let LOG = isDebug();
21
35
  * Get the number of currently executing ESI requests
22
36
  */
23
37
  let ax = 0;
38
+ /** @type {(m?: Truthy) => number} */
24
39
  const incrementAx = (minus) => minus ? ax-- : ax++;
25
40
  /**
26
41
  * @returns Get The Current ESI request pending count.
@@ -30,33 +45,23 @@ export const getRequestPending = () => ax;
30
45
  // main functions
31
46
  // - - - - - - - - - - - - - - - - - - - -
32
47
  /**
33
- * fire ESI request
34
- * @template {TESIEntryMethod} M
35
- * @template {keyof TESIResponseOKMap[M]} EP
36
- * @template {IfParameterizedPath<EP, Opt>} P2
37
- * @template {IdentifyParameters<TESIResponseOKMap[M][EP], ESIRequestOptions>} Opt
38
- * @template {InferESIResponseResult<M, EP>} R
48
+ * fire ESI request ESIRequestOptions
39
49
  *
40
- * @param {M} mthd
41
- * @param {EP} endp - The endpoint to request.
42
- * @param {Opt} [opt] - default is empty object {}. `body` is json string
43
- * @param {P2} [pathParams] - Optional path parameters.
44
- * @returns {Promise<R>} - The response from the endpoint.
45
- * @throws
50
+ * @type {TESIRequestFunctionSignature2<ESIRequestOptions>}
51
+ * @throws {ESIRequestError}
46
52
  * @async
47
53
  */
48
- export async function fire(mthd, endp, pathParams, opt) {
49
- if (typeof pathParams === "number") {
50
- // @ts-expect-error
51
- pathParams = [pathParams]; // as unknown as P2;
54
+ export const fire = async (mthd, endp, opt) => {
55
+ /** @type {number[]=} */
56
+ let pathParams;
57
+ if (opt && typeof opt.pathParams !== "undefined") {
58
+ pathParams = typeof opt.pathParams === "number" ? [opt.pathParams] : isArray(opt.pathParams) ? opt.pathParams : void 0;
52
59
  }
53
60
  if (isArray(pathParams)) {
54
61
  endp = replaceCbt(endp, pathParams);
55
62
  }
56
63
  // When only options are provided
57
- /** @type {Opt} */
58
- // @ts-ignore
59
- const actualOpt = opt || pathParams || {};
64
+ const actualOpt = opt || /** @type {NonNullable<typeof opt>} */ ({});
60
65
  const { rqopt, qss } = initOptions(mthd, actualOpt);
61
66
  const endpointUrl = curl(endp);
62
67
  const up = new URLSearchParams(qss);
@@ -76,10 +81,10 @@ export async function fire(mthd, endp, pathParams, opt) {
76
81
  catch (e) {
77
82
  throw e;
78
83
  }
79
- }
84
+ };
80
85
  // It should complete correctly.
81
86
  /**
82
- * @param {TESIRequestFunctionSignature<ESIRequestOptions>} fn
87
+ * @param {TESIRequestFunctionSignature2<ESIRequestOptions>} fn
83
88
  */
84
89
  async function getEVEStatus(fn) {
85
90
  const sdeVersion = await getSDEVersion();
package/esi-types-util.md DELETED
@@ -1,127 +0,0 @@
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 Definitions
10
-
11
- ### TESIRequestFunctionSignature
12
-
13
- `TESIRequestFunctionSignature<ActualOpt>` is a type that defines the signature of an ESI request function,
14
- which sends a request to a specified endpoint and returns a response.
15
-
16
- ```ts
17
- type TESIRequestFunctionSignature<ActualOpt> = <
18
- M extends TESIEntryMethod,
19
- EP extends keyof TESIResponseOKMap[M],
20
- P2 extends IfParameterizedPath<EP, Opt>,
21
- Opt extends IdentifyParameters<TESIResponseOKMap[M][EP], ActualOpt>,
22
- R extends InferESIResponseResult<M, EP>
23
- >(method: M, endpoint: EP, pathParams?: P2, options?: Opt) => Promise<R>;
24
- ```
25
-
26
- ### IfParameterizedPath
27
-
28
- `IfParameterizedPath<EP, Opt>` if parameterized path then specify number type, otherwise will be `Opt` type.
29
-
30
- ```ts
31
- type IfParameterizedPath<EP, Opt> = EP extends `${string}/{${string}}${string}`
32
- ? PickPathParameters<EP> extends never
33
- ? Opt : InferKeysLen<PickPathParameters<EP>> extends 1
34
- ? number : [number, number]
35
- : Opt;
36
- ```
37
-
38
- ### IdentifyParameters
39
-
40
- `IdentifyParameters<Entry, Opt>` is a type to identify the required parameters for a given entry type.
41
-
42
- ```ts
43
- type IdentifyParameters<Entry, Opt> = Opt & Pick<Entry, Exclude<keyof Entry, "result">>;
44
- ```
45
-
46
- ### InferESIResponseResult
47
-
48
- `InferESIResponseResult<M extends TESIEntryMethod, EP extends keyof TESIResponseOKMap[M]>` is a type to infer the result type of an ESI response based on the method and endpoint.
49
-
50
- ```ts
51
- type InferESIResponseResult<
52
- M extends TESIEntryMethod,
53
- EP extends keyof TESIResponseOKMap[M]
54
- > = TESIResponseOKMap[M][EP] extends { result: infer U } ? U : never;
55
- ```
56
-
57
- ### TESIEntryMethod
58
-
59
- `TESIEntryMethod` represents the HTTP methods supported by ESI.
60
-
61
- ```ts
62
- type TESIEntryMethod = keyof TESIResponseOKMap;
63
- ```
64
-
65
- ### TEndPointGet
66
-
67
- `TEndPointGet` represents the endpoints for the "get" method.
68
-
69
- ```ts
70
- type TEndPointGet = keyof TESIResponseOKMap["get"];
71
- ```
72
-
73
- ### TEndPointPost
74
-
75
- `TEndPointPost` represents the endpoints for the "post" method.
76
-
77
- ```ts
78
- type TEndPointPost = keyof TESIResponseOKMap["post"];
79
- ```
80
-
81
- ### TEndPointPut
82
-
83
- `TEndPointPut` represents the endpoints for the "put" method.
84
-
85
- ```ts
86
- type TEndPointPut = keyof TESIResponseOKMap["put"];
87
- ```
88
-
89
- ### TEndPointDelete
90
-
91
- `TEndPointDelete` represents the endpoints for the "delete" method.
92
-
93
- ```ts
94
- type TEndPointDelete = keyof TESIResponseOKMap["delete"];
95
- ```
96
-
97
- ### TESIResponseGetEntry
98
-
99
- `TESIResponseGetEntry<K extends TEndPointGet>` represents the entry details for the "get" method.
100
-
101
- ```ts
102
- type TESIResponseGetEntry<K extends TEndPointGet> = TESIResponseOKMap["get"][K];
103
- ```
104
-
105
- ### TESIResponsePutEntry
106
-
107
- `TESIResponsePutEntry<K extends TEndPointPut>` represents the entry details for the "put" method.
108
-
109
- ```ts
110
- type TESIResponsePutEntry<K extends TEndPointPut> = TESIResponseOKMap["put"][K];
111
- ```
112
-
113
- ### TESIResponsePostEntry
114
-
115
- `TESIResponsePostEntry<K extends TEndPointPost>` represents the entry details for the "post" method.
116
-
117
- ```ts
118
- type TESIResponsePostEntry<K extends TEndPointPost> = TESIResponseOKMap["post"][K];
119
- ```
120
-
121
- ### TESIResponseDeleteEntry
122
-
123
- `TESIResponseDeleteEntry<K extends TEndPointDelete>` represents the entry details for the "delete" method.
124
-
125
- ```ts
126
- type TESIResponseDeleteEntry<K extends TEndPointDelete> = TESIResponseOKMap["delete"][K];
127
- ```