eve-esi-types 3.1.3 → 3.1.6
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 +1 -1
- package/docs/v2/identify-parameters.md +74 -0
- package/docs/v2/if-parameterized-path.md +70 -0
- package/docs/v2/infer-esi-response-result.md +44 -0
- package/docs/v2/require-these.md +57 -0
- package/docs/v3/esi-enhanced-function-signature.md +67 -0
- package/docs/v3/has-require-params.md +50 -0
- package/docs/v3/infer-endpoint-origin.md +57 -0
- package/docs/v3/infer-path-params.md +41 -0
- package/docs/v3/pick-require-params.md +56 -0
- package/docs/v3/replace-path-params.md +60 -0
- package/docs/v3/resolved-endpoint.md +44 -0
- package/lib/rq-util.d.mts +3 -14
- package/lib/rq-util.mjs +28 -42
- package/package.json +1 -1
- package/v2/esi-tagged-types.d.ts +1 -1
- package/v2/index.d.ts +86 -26
- package/v2/response-map.d.ts +1 -1
- package/v2/types-index.d.ts +1 -1
- /package/docs/{esi-types-util3.md → v3/esi-types-util3.md} +0 -0
package/README.md
CHANGED
|
@@ -100,6 +100,6 @@ const ret = await esiRequest.universe.get("/universe/structures/", { query: { fi
|
|
|
100
100
|
|
|
101
101
|
## References
|
|
102
102
|
|
|
103
|
-
- [`ESI Types Utility Definitions`](./docs/esi-types-util3.md)
|
|
103
|
+
- [`ESI Types Utility Definitions`](./docs/v3/esi-types-util3.md)
|
|
104
104
|
|
|
105
105
|
- [`ESI Tagged Types Utility Definitions`](./docs/esi-tagged-types.md)
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# Explanation of the `IdentifyParameters` Type
|
|
2
|
+
|
|
3
|
+
`IdentifyParameters` is an advanced TypeScript utility type designed to pinpoint the required parameters for an API endpoint by combining the key properties from the entry type and any additional options. This type ensures that all required parameters are explicitly marked as required, facilitating strong type-checking for API operations.
|
|
4
|
+
|
|
5
|
+
## Type Definition
|
|
6
|
+
|
|
7
|
+
```typescript
|
|
8
|
+
type IdentifyParameters<
|
|
9
|
+
M extends TESIEntryMethod,
|
|
10
|
+
EPx extends ESIEndpointOf<M> | string,
|
|
11
|
+
Opt extends Record<string, unknown>,
|
|
12
|
+
AdditionalParams,
|
|
13
|
+
Entry = _ESIResponseType<M, EPx> & AdditionalParams,
|
|
14
|
+
RequireKeys = Exclude<keyof (Entry & AdditionalParams), "result" | "tag" | "cachedSeconds">
|
|
15
|
+
// @ts-expect-error
|
|
16
|
+
> = RestrictKeys<Opt, RequireKeys> & Pick<Entry, RequireKeys> & AdditionalParams;
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Template Parameters
|
|
20
|
+
|
|
21
|
+
- **`M extends TESIEntryMethod`**
|
|
22
|
+
Specifies the HTTP method (e.g., `"get"`, `"post"`, `"delete"`, etc.) used for the API request. This allows the type system to select the appropriate endpoint and response types.
|
|
23
|
+
|
|
24
|
+
- **`EPx extends ESIEndpointOf<M> | string`**
|
|
25
|
+
Denotes the endpoint path. It can be a specific parameterized endpoint corresponding to the method or a generic endpoint represented as a string.
|
|
26
|
+
|
|
27
|
+
- **`Opt extends Record<string, unknown>`**
|
|
28
|
+
Represents the additional options provided by the user. These options are expected to be an object whose keys are strings.
|
|
29
|
+
|
|
30
|
+
- **`AdditionalParams`**
|
|
31
|
+
These are extra parameters that, when merged with the entry type, give a more comprehensive view of the API parameters.
|
|
32
|
+
|
|
33
|
+
- **`Entry = _ESIResponseType<M, EPx> & AdditionalParams`**
|
|
34
|
+
This type combines the inferred response type for the given HTTP method and endpoint with the additional parameters. It serves as the base type from which the required keys are extracted.
|
|
35
|
+
|
|
36
|
+
- **`RequireKeys = Exclude<keyof (Entry & AdditionalParams), "result" | "tag" | "cachedSeconds">`**
|
|
37
|
+
This calculates the keys that are considered required by excluding common metadata keys (`"result"`, `"tag"`, and `"cachedSeconds"`) from the combined type.
|
|
38
|
+
|
|
39
|
+
## How It Works
|
|
40
|
+
|
|
41
|
+
1. **Merging Types**
|
|
42
|
+
The type first merges the API response type (`_ESIResponseType<M, EPx>`) with any additional parameters passed as `AdditionalParams` to form the composite type `Entry`.
|
|
43
|
+
|
|
44
|
+
2. **Identifying Required Keys**
|
|
45
|
+
It then computes `RequireKeys` by taking the keys of the merged type and excluding the metadata keys (`"result"`, `"tag"`, `"cachedSeconds"`). These remaining keys are treated as required parameters.
|
|
46
|
+
|
|
47
|
+
3. **Restricting Additional Options**
|
|
48
|
+
The helper type `RestrictKeys<Opt, RequireKeys>` ensures that the additional options in `Opt` are limited only to the keys identified as required. This adds an extra layer of type-safety.
|
|
49
|
+
|
|
50
|
+
4. **Final Combination**
|
|
51
|
+
Finally, the type returns the intersection:
|
|
52
|
+
- `RestrictKeys<Opt, RequireKeys>` restricts `Opt` to only the required keys.
|
|
53
|
+
- `Pick<Entry, RequireKeys>` extracts the corresponding values from the merged entry type.
|
|
54
|
+
- `AdditionalParams` is intersected in the end, ensuring that any extra provided parameters are also included.
|
|
55
|
+
|
|
56
|
+
This results in a final type that accurately represents only the required parameters for an API endpoint.
|
|
57
|
+
|
|
58
|
+
## Practical Example
|
|
59
|
+
|
|
60
|
+
```typescript
|
|
61
|
+
type ExampleEntry = { result: string, tag: string, cachedSeconds: number, auth: string };
|
|
62
|
+
type ExampleOpt = { auth: string };
|
|
63
|
+
type IdentifiedParams = IdentifyParameters<"get", "/example/endpoint", ExampleOpt, ExampleEntry>;
|
|
64
|
+
// Result: { auth: string } & { auth: string }
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
In this example:
|
|
68
|
+
- `ExampleEntry` includes metadata keys along with the essential key `auth`.
|
|
69
|
+
- `ExampleOpt` specifies that `auth` is required.
|
|
70
|
+
- `IdentifyParameters` processes these inputs and produces a type that enforces the `auth` parameter as required, ensuring accurate and reliable type-checking.
|
|
71
|
+
|
|
72
|
+
---
|
|
73
|
+
|
|
74
|
+
`IdentifyParameters` thus plays a crucial role in extracting and enforcing the required parameters from API definitions, merging inherent parameters with additional options into a concise, strongly-typed structure.
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
# Explanation of the `IfParameterizedPath` Type
|
|
2
|
+
|
|
3
|
+
`IfParameterizedPath` is a conditional TypeScript utility type that checks whether a given endpoint path (`EP`) is parameterized—i.e., contains a parameterized segment enclosed in `{}`—and, if so, determines the required type for its numeric replacements. Depending on the number of parameters detected, it returns different types:
|
|
4
|
+
- Returns `number` if exactly one parameter is detected.
|
|
5
|
+
- Returns `[number, number]` if two parameters are detected.
|
|
6
|
+
- Otherwise, it returns the fallback type `Opt` (which defaults to `never`).
|
|
7
|
+
|
|
8
|
+
## Type Definition
|
|
9
|
+
|
|
10
|
+
```typescript
|
|
11
|
+
type IfParameterizedPath<EP extends unknown, Opt = never> = EP extends `${string}/{${string}}${string}`
|
|
12
|
+
? PickPathParameters<EP> extends never
|
|
13
|
+
? Opt : InferKeysLen<PickPathParameters<EP>> extends 1
|
|
14
|
+
? number : [number, number]
|
|
15
|
+
: Opt;
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Template Parameters
|
|
19
|
+
|
|
20
|
+
- **`EP extends unknown`**
|
|
21
|
+
The endpoint path as a string literal. This path may contain dynamic segments (e.g., `"/users/{user_id}/posts/{post_id}"`) that need to be replaced with numerical values.
|
|
22
|
+
|
|
23
|
+
- **`Opt`**
|
|
24
|
+
The fallback type to return if `EP` is not parameterized. By default, this is set to `never`.
|
|
25
|
+
|
|
26
|
+
## How It Works
|
|
27
|
+
|
|
28
|
+
1. **Pattern Matching**
|
|
29
|
+
The type checks if `EP` matches the pattern:
|
|
30
|
+
```typescript
|
|
31
|
+
EP extends `${string}/{${string}}${string}`
|
|
32
|
+
```
|
|
33
|
+
This verifies that `EP` includes at least one parameter wrapped in curly braces.
|
|
34
|
+
|
|
35
|
+
2. **Extracting Parameters**
|
|
36
|
+
If `EP` is parameterized, `PickPathParameters<EP>` is used to extract the dynamic segments:
|
|
37
|
+
- If `PickPathParameters<EP>` evaluates to `never` (indicating no valid parameters were found), the type returns `Opt`.
|
|
38
|
+
- Otherwise, it proceeds to the next step.
|
|
39
|
+
|
|
40
|
+
3. **Determining the Number of Parameters**
|
|
41
|
+
The type uses `InferKeysLen<PickPathParameters<EP>>` to count the number of extracted parameters:
|
|
42
|
+
- If exactly one parameter is found, it returns `number`—indicating a single numeric replacement.
|
|
43
|
+
- Otherwise (implicitly for two parameters as per the provided description), it returns `[number, number]`.
|
|
44
|
+
|
|
45
|
+
4. **Fallback for Non-Parameterized Paths**
|
|
46
|
+
If `EP` does not match the parameterized pattern, the type simply returns `Opt`.
|
|
47
|
+
|
|
48
|
+
## Practical Example
|
|
49
|
+
|
|
50
|
+
For an endpoint with one parameter:
|
|
51
|
+
```typescript
|
|
52
|
+
type SingleParam = IfParameterizedPath<"/users/{user_id}/profile">;
|
|
53
|
+
// Evaluates to: number
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
For an endpoint with two parameters:
|
|
57
|
+
```typescript
|
|
58
|
+
type TwoParams = IfParameterizedPath<"/users/{user_id}/posts/{post_id}">;
|
|
59
|
+
// Evaluates to: [number, number]
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
And for a non-parameterized endpoint:
|
|
63
|
+
```typescript
|
|
64
|
+
type NotParam = IfParameterizedPath<"/about">;
|
|
65
|
+
// Evaluates to: never (using the default for Opt)
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
---
|
|
69
|
+
|
|
70
|
+
`IfParameterizedPath` provides a precise mechanism for type-level validation of endpoint structures by determining the necessary numerical replacements for dynamic segments, ensuring robust type-checking for API endpoint definitions.
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# Explanation of the `InferESIResponseResult` Type
|
|
2
|
+
|
|
3
|
+
`InferESIResponseResult` is a utility TypeScript type designed to extract the type of the `result` property from an ESI response based on a given HTTP method and endpoint. It relies on the underlying `_ESIResponseType`, which represents the full response type for the specified method and endpoint. If this inferred response type includes a `result` key, the type captures and returns its type; otherwise, it defaults to `never`.
|
|
4
|
+
|
|
5
|
+
## Type Definition
|
|
6
|
+
|
|
7
|
+
```typescript
|
|
8
|
+
type InferESIResponseResult<
|
|
9
|
+
M extends TESIEntryMethod,
|
|
10
|
+
EPx extends ESIEndpointOf<M> | string
|
|
11
|
+
> = _ESIResponseType<M, EPx> extends { result: infer U } ? U : never;
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## Template Parameters
|
|
15
|
+
|
|
16
|
+
- **`M extends TESIEntryMethod`**
|
|
17
|
+
The HTTP method (e.g., `"get"`, `"post"`, `"delete"`, etc.) used for the request. This helps determine the proper response type from the API endpoints.
|
|
18
|
+
|
|
19
|
+
- **`EPx extends ESIEndpointOf<M> | string`**
|
|
20
|
+
The endpoint path, which can either be one of the predefined parameterized endpoints associated with the HTTP method `M` or a generic string representing an endpoint.
|
|
21
|
+
|
|
22
|
+
## How It Works
|
|
23
|
+
|
|
24
|
+
1. **Inferring the Response Type:**
|
|
25
|
+
The type first evaluates `_ESIResponseType<M, EPx>`, which returns the anticipated response type for the given HTTP method and endpoint.
|
|
26
|
+
|
|
27
|
+
2. **Extracting the `result` Property:**
|
|
28
|
+
It then uses a conditional type with the `infer` keyword:
|
|
29
|
+
```typescript
|
|
30
|
+
_ESIResponseType<M, EPx> extends { result: infer U } ? U : never;
|
|
31
|
+
```
|
|
32
|
+
- If the response type has a `result` property, `U` is inferred as the type of that property.
|
|
33
|
+
- If there is no `result` property, the type evaluates to `never`.
|
|
34
|
+
|
|
35
|
+
## Practical Example
|
|
36
|
+
|
|
37
|
+
```typescript
|
|
38
|
+
type Result = InferESIResponseResult<"get", "/characters/{character_id}/">;
|
|
39
|
+
// The type 'Result' represents the type of the 'result' field in the response for the GET request to the specified endpoint.
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
`InferESIResponseResult` enhances type safety by allowing developers to directly access the portion of the API response that contains the primary data of interest. This makes it easier to work with and validate the structure of responses in a strongly-typed manner.
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# Explanation of the `RequireThese` Type
|
|
2
|
+
|
|
3
|
+
The `RequireThese` type is a utility type that takes an existing type `T` and a subset of its keys `K`, and marks those keys as **required**. The rest of the properties in `T` remain unchanged. This is especially useful when you want to enforce that certain properties are provided while leaving other properties optional or in their original state.
|
|
4
|
+
|
|
5
|
+
## Type Definition
|
|
6
|
+
|
|
7
|
+
```typescript
|
|
8
|
+
type RequireThese<T, K extends keyof T> = {
|
|
9
|
+
[P in keyof T as P extends K ? P : never]-?: T[P];
|
|
10
|
+
} & {
|
|
11
|
+
[P in keyof T as P extends K ? never : P]: T[P];
|
|
12
|
+
};
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## How It Works
|
|
16
|
+
|
|
17
|
+
1. **Selecting Required Keys**
|
|
18
|
+
The first mapped type:
|
|
19
|
+
```typescript
|
|
20
|
+
{
|
|
21
|
+
[P in keyof T as P extends K ? P : never]-?: T[P];
|
|
22
|
+
}
|
|
23
|
+
```
|
|
24
|
+
- Iterates over each property key `P` in `T`.
|
|
25
|
+
- Uses a conditional type `P extends K ? P : never` to filter in only the keys that are specified in `K`.
|
|
26
|
+
- The `-?` operator removes the optional modifier, ensuring that these properties are marked as required.
|
|
27
|
+
|
|
28
|
+
2. **Preserving Other Keys**
|
|
29
|
+
The second mapped type:
|
|
30
|
+
```typescript
|
|
31
|
+
{
|
|
32
|
+
[P in keyof T as P extends K ? never : P]: T[P];
|
|
33
|
+
}
|
|
34
|
+
```
|
|
35
|
+
- Iterates over each property key `P` in `T`.
|
|
36
|
+
- Uses a conditional type to exclude the keys in `K` (by returning `never` for them), effectively preserving only the properties not in `K` in their original form.
|
|
37
|
+
|
|
38
|
+
3. **Combining the Results**
|
|
39
|
+
The intersection (`&`) of the two mapped types results in a new type that:
|
|
40
|
+
- Contains all keys in `K` as required.
|
|
41
|
+
- Contains all keys not in `K` with their original modifiers (optional or required).
|
|
42
|
+
|
|
43
|
+
## Practical Example
|
|
44
|
+
|
|
45
|
+
```typescript
|
|
46
|
+
type Original = { a?: number; b?: string; c: boolean };
|
|
47
|
+
type RequiredA = RequireThese<Original, 'a'>;
|
|
48
|
+
// Evaluates to: { a: number; b?: string; c: boolean }
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
In this example:
|
|
52
|
+
- The property `a` is transformed from an optional property to a required property.
|
|
53
|
+
- The properties `b` and `c` retain their original statuses, with `b` remaining optional and `c` remaining required.
|
|
54
|
+
|
|
55
|
+
---
|
|
56
|
+
|
|
57
|
+
`RequireThese` provides a concise way to enforce the presence of selected properties within a type, making it an effective tool for enhancing type safety in TypeScript.
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
# Explanation of the `TESIEnhancedRequestFunctionSignature` Type
|
|
2
|
+
|
|
3
|
+
`TESIEnhancedRequestFunctionSignature` is a highly generic function signature type for performing enhanced ESI requests.
|
|
4
|
+
It extends a base request function signature by injecting a prepended parameter at the beginning of the function call,
|
|
5
|
+
thereby providing extra context or enabling pre-processing prior to executing the request.
|
|
6
|
+
|
|
7
|
+
This signature adapts to the specifics of the chosen HTTP method, endpoint configuration, inferred path parameters,
|
|
8
|
+
and additional request options—making it ideal for advanced API interactions where both flexibility and strict type-safety are required.
|
|
9
|
+
|
|
10
|
+
## Generic Parameters
|
|
11
|
+
|
|
12
|
+
- **`PrependParam`**: The type of the additional parameter that is injected at the beginning of the function call.
|
|
13
|
+
- **`ActualOpt`**: An object representing the default options (typically extending `ESIRequestOptions`) used for the request.
|
|
14
|
+
|
|
15
|
+
## Function Generic Parameters
|
|
16
|
+
|
|
17
|
+
- **`Mtd`**: The ESI request method type (e.g., GET, POST, DELETE) as defined in `TESIEntryMethod`.
|
|
18
|
+
- **`REP`**: The endpoint type, which can be either a version with replaced path parameters (via `ReplacePathParams`) or the raw endpoint type from `ESIEndpointOf<Mtd>`.
|
|
19
|
+
- **`EPX`**: The resolved endpoint type, derived from `REP` and `Mtd`.
|
|
20
|
+
- **`PPM`**: The type representing the inferred path parameters extracted from `REP` and `EPX`.
|
|
21
|
+
- **`Opt`**: The type for additional request options, as deduced from the HTTP method (`Mtd`), endpoint (`EPX`), the default options (`ActualOpt`), and the inferred path parameters (`PPM`).
|
|
22
|
+
- **`Ret`**: The type of the response result from the ESI request, as inferred from the method and the endpoint.
|
|
23
|
+
- **`HasOpt`**: An internal flag, computed via `HasRequireParams<Mtd, EPX, PPM>`, used to determine whether the request options (`Opt`) are required (evaluating to `1`) or optional (evaluating to `0`).
|
|
24
|
+
|
|
25
|
+
## Parameters
|
|
26
|
+
|
|
27
|
+
- **`prependParam: PrependParam`**
|
|
28
|
+
A prepended parameter that supplies additional context or configuration necessary for the request.
|
|
29
|
+
|
|
30
|
+
- **`method: Mtd`**
|
|
31
|
+
The HTTP method for the request.
|
|
32
|
+
|
|
33
|
+
- **`endpoint: REP`**
|
|
34
|
+
The API endpoint, which may include path parameter replacements (as provided by `ReplacePathParams`).
|
|
35
|
+
|
|
36
|
+
- **`...options: HasOpt extends 1 ? [Opt] : [Opt?]`**
|
|
37
|
+
A rest parameter representing additional options for the request. This is required if `HasOpt` is `1` (indicating that some options are mandatory), otherwise it is optional.
|
|
38
|
+
|
|
39
|
+
## Return Value
|
|
40
|
+
|
|
41
|
+
- Returns a `Promise<Ret>` that resolves with the response from the ESI endpoint, where `Ret` reflects the inferred result type.
|
|
42
|
+
|
|
43
|
+
## Type Definition
|
|
44
|
+
|
|
45
|
+
```typescript
|
|
46
|
+
type TESIEnhancedRequestFunctionSignature<
|
|
47
|
+
PrependParam extends unknown, ActualOpt extends Record<string, unknown>
|
|
48
|
+
> = <
|
|
49
|
+
Mtd extends TESIEntryMethod,
|
|
50
|
+
REP extends ReplacePathParams<ESIEndpointOf<Mtd>> | ESIEndpointOf<Mtd>,
|
|
51
|
+
EPX extends ResolvedEndpoint<REP, Mtd>,
|
|
52
|
+
PPM extends InferPathParams<REP, EPX>,
|
|
53
|
+
Opt extends IdentifyParameters<Mtd, EPX, ActualOpt, PPM>,
|
|
54
|
+
Ret extends InferESIResponseResult<Mtd, EPX>,
|
|
55
|
+
HasOpt = HasRequireParams<Mtd, EPX, PPM>
|
|
56
|
+
>(
|
|
57
|
+
prependParam: PrependParam,
|
|
58
|
+
method: Mtd,
|
|
59
|
+
endpoint: REP,
|
|
60
|
+
...options: HasOpt extends 1 ? [Opt] : [Opt?]
|
|
61
|
+
) => Promise<Ret>;
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
---
|
|
65
|
+
|
|
66
|
+
`TESIEnhancedRequestFunctionSignature` combines dynamic type inference with advanced parameter and return type handling to support complex API interactions in a type-safe manner.
|
|
67
|
+
It ensures that extra configuration is accounted for at the start of the function call, aligning the signature with the specific needs of the API endpoint and HTTP method being used.
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# Explanation of the `HasRequireParams` Type
|
|
2
|
+
|
|
3
|
+
`HasRequireParams` is a conditional TypeScript utility type designed to determine whether an API entry has any required parameters, including additional options. It does so by leveraging the `PickRequireParams` type to extract the keys from an entry type that are considered required once common metadata keys (`"result"`, `"tag"`, and `"cachedSeconds"`) have been excluded. If there remain any keys after this exclusion, it means the entry has required parameters, and the type evaluates to `1`; otherwise, it evaluates to `0`.
|
|
4
|
+
|
|
5
|
+
## Type Definition
|
|
6
|
+
|
|
7
|
+
```typescript
|
|
8
|
+
type HasRequireParams<
|
|
9
|
+
M extends TESIEntryMethod,
|
|
10
|
+
EPx extends ESIEndpointOf<M> | string,
|
|
11
|
+
AdditionalParams,
|
|
12
|
+
> = PickRequireParams<M, EPx, AdditionalParams> extends never ? 0 : 1;
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Template Parameters
|
|
16
|
+
|
|
17
|
+
- **`M extends TESIEntryMethod`**
|
|
18
|
+
Represents the HTTP method (like `"get"`, `"post"`, `"delete"`, etc.) for the request. This helps identify the correct set of endpoints and types associated with that method.
|
|
19
|
+
|
|
20
|
+
- **`EPx extends ESIEndpointOf<M> | string`**
|
|
21
|
+
Denotes the endpoint path. It can be a specific parameterized endpoint from a predefined set (based on the HTTP method) or a generic string.
|
|
22
|
+
|
|
23
|
+
- **`AdditionalParams`**
|
|
24
|
+
Contains any extra parameters that should be considered during the evaluation. These are merged with the entry type to form a complete set of properties before excluding the metadata keys.
|
|
25
|
+
|
|
26
|
+
## How It Works
|
|
27
|
+
|
|
28
|
+
1. **Extracting Required Parameters**
|
|
29
|
+
The type starts by merging the entry type with `AdditionalParams` and then uses `PickRequireParams` to exclude common metadata keys (`"result"`, `"tag"`, and `"cachedSeconds"`). This extraction isolates the parameters that are truly required for the API call.
|
|
30
|
+
|
|
31
|
+
2. **Conditional Evaluation**
|
|
32
|
+
- If the resulting type from `PickRequireParams` is `never` (meaning there are no keys left), then `HasRequireParams` evaluates to `0`.
|
|
33
|
+
- Otherwise, if there exists at least one required parameter, it evaluates to `1`.
|
|
34
|
+
|
|
35
|
+
## Practical Example
|
|
36
|
+
|
|
37
|
+
```typescript
|
|
38
|
+
type ExampleEntry = { result: string, tag: string, cachedSeconds: number, auth: string };
|
|
39
|
+
type HasRequired = HasRequireParams<"get", "/example/endpoint", { auth: string }>;
|
|
40
|
+
// Evaluates to: 1
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
In this example:
|
|
44
|
+
- The `ExampleEntry` type includes metadata keys as well as an essential key `auth`.
|
|
45
|
+
- After merging with `AdditionalParams` (which also includes `{ auth: string }`) and excluding the metadata keys, `auth` remains.
|
|
46
|
+
- Since there is a required parameter (`auth`), `HasRequireParams` evaluates to `1`.
|
|
47
|
+
|
|
48
|
+
---
|
|
49
|
+
|
|
50
|
+
`HasRequireParams` provides a straightforward mechanism to check if any required parameters exist for a given API entry, assisting in enhancing type safety and clarity in API definitions.
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# Explanation of the `InferEndpointOrigin` Type
|
|
2
|
+
|
|
3
|
+
`InferEndpointOrigin` is a utility TypeScript type that deduces the original parameterized endpoint from a real endpoint string and a specified HTTP method. It does so by mapping over all possible parameterized endpoints associated with the given HTTP method, and selecting the one whose transformed version (via `ReplacePathParams`) matches the real endpoint. This technique enables you to recover the canonical endpoint structure from a concrete URL.
|
|
4
|
+
|
|
5
|
+
## Type Definition
|
|
6
|
+
|
|
7
|
+
```typescript
|
|
8
|
+
type InferEndpointOrigin<
|
|
9
|
+
RealEP extends unknown, M extends TESIEntryMethod,
|
|
10
|
+
Endpoints extends ESIEndpointOf<M> = ESIEndpointOf<M>
|
|
11
|
+
> = {
|
|
12
|
+
[EP in Endpoints]: RealEP extends ReplacePathParams<EP>
|
|
13
|
+
? EP : never;
|
|
14
|
+
}[Endpoints];
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Template Parameters
|
|
18
|
+
|
|
19
|
+
- **`RealEP extends unknown`**
|
|
20
|
+
The real endpoint path, e.g., `"/characters/123/fittings/456/"`, representing the concrete URL accessed in a request.
|
|
21
|
+
|
|
22
|
+
- **`M extends TESIEntryMethod`**
|
|
23
|
+
The HTTP method (such as `"get"`, `"post"`, `"delete"`, etc.) used to determine which endpoints are applicable.
|
|
24
|
+
|
|
25
|
+
- **`Endpoints extends ESIEndpointOf<M> = ESIEndpointOf<M>`**
|
|
26
|
+
The union of all possible parameterized endpoints for the given HTTP method. These endpoints generally include dynamic segments in their definition, like `"/characters/{character_id}/fittings/{fitting_id}/"`.
|
|
27
|
+
|
|
28
|
+
## How It Works
|
|
29
|
+
|
|
30
|
+
1. **Mapping Over Endpoints**
|
|
31
|
+
The type creates a mapped type where it iterates over each possible endpoint (`EP`) in the `Endpoints` union:
|
|
32
|
+
```typescript
|
|
33
|
+
RealEP extends ReplacePathParams<EP> ? EP : never;
|
|
34
|
+
```
|
|
35
|
+
- **Condition:** It checks if the real endpoint `RealEP` is assignable to the version of `EP` produced by `ReplacePathParams` (i.e., with its dynamic segments replaced by `${number}`).
|
|
36
|
+
- **Outcome:**
|
|
37
|
+
- If the condition holds true, it retains `EP`—indicating that this is the matching original endpoint.
|
|
38
|
+
- Otherwise, it assigns `never` for that endpoint.
|
|
39
|
+
|
|
40
|
+
2. **Indexing the Mapped Type**
|
|
41
|
+
After processing all endpoints, the type uses an index lookup `[Endpoints]` to extract the union of all endpoints that passed the conditional check (i.e., where the condition did not yield `never`). In typical usage, this results in a single matching endpoint.
|
|
42
|
+
|
|
43
|
+
## Practical Example
|
|
44
|
+
|
|
45
|
+
```ts
|
|
46
|
+
type Original = InferEndpointOrigin<"/characters/123/fittings/456/", "delete">;
|
|
47
|
+
// Evaluates to: "/characters/{character_id}/fittings/{fitting_id}/"
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
In this example:
|
|
51
|
+
- The real endpoint `"/characters/123/fittings/456/"` is compared against each parameterized endpoint available for the `"delete"` method.
|
|
52
|
+
- When the condition `RealEP extends ReplacePathParams<EP>` is satisfied, it indicates that the endpoint structure matches. Accordingly, the original parameterized endpoint (`EP`) is selected.
|
|
53
|
+
- The final resulting type is the parameterized endpoint, `"/characters/{character_id}/fittings/{fitting_id}/"`.
|
|
54
|
+
|
|
55
|
+
---
|
|
56
|
+
|
|
57
|
+
`InferEndpointOrigin` thus serves as a robust mechanism to align concrete URLs with their original endpoint definitions, ensuring accurate type-checking for API route definitions.
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# Explanation of the `InferPathParams` Type
|
|
2
|
+
|
|
3
|
+
`InferPathParams` is a conditional utility TypeScript type that infers path parameters by comparing the real endpoint path (`RealEP`) with the resolved endpoint path (`EPx`). It determines the appropriate type for the path parameters based on whether the real endpoint extends the resolved endpoint.
|
|
4
|
+
|
|
5
|
+
## Type Definition
|
|
6
|
+
|
|
7
|
+
```typescript
|
|
8
|
+
type InferPathParams<
|
|
9
|
+
RealEP extends unknown, EPx extends unknown
|
|
10
|
+
> = RealEP extends EPx ? _IfNeedPathParams<EPx> : TPathParamsNever;
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Template Parameters
|
|
14
|
+
|
|
15
|
+
- **`RealEP extends unknown`**
|
|
16
|
+
Represents the real endpoint path, which is the original route definition provided in your API.
|
|
17
|
+
|
|
18
|
+
- **`EPx extends unknown`**
|
|
19
|
+
Represents the resolved endpoint path, which may be a transformed or standardized version of the real endpoint.
|
|
20
|
+
|
|
21
|
+
## How It Works
|
|
22
|
+
|
|
23
|
+
1. **Conditional Check**
|
|
24
|
+
The type first evaluates whether `RealEP` extends `EPx`:
|
|
25
|
+
- If **true**, it indicates that the real endpoint is compatible with the resolved endpoint.
|
|
26
|
+
|
|
27
|
+
2. **Path Parameter Inference**
|
|
28
|
+
- When the condition is met, the type returns `_IfNeedPathParams<EPx>`, a helper type that likely infers and extracts the necessary path parameters embedded within `EPx`.
|
|
29
|
+
- Otherwise, it returns `TPathParamsNever`, a type signaling that no valid path parameters could be inferred or that they are not needed.
|
|
30
|
+
|
|
31
|
+
## Practical Example
|
|
32
|
+
|
|
33
|
+
Consider a scenario where you have:
|
|
34
|
+
- A real endpoint like `"/characters/{character_id}"`.
|
|
35
|
+
- A resolved endpoint that might incorporate specific formatting or type annotations.
|
|
36
|
+
|
|
37
|
+
Using `InferPathParams`, if the real endpoint correctly extends the resolved endpoint, `_IfNeedPathParams` will process `EPx` to extract dynamic segments (such as converting `{character_id}` to an interpolated type). If not, it falls back to `TPathParamsNever`.
|
|
38
|
+
|
|
39
|
+
---
|
|
40
|
+
|
|
41
|
+
This type is instrumental in achieving type safety in API route definitions. By conditionally inferring path parameters, it ensures that only valid and necessary parameters are extracted, promoting robust type-checking and eliminating unnecessary types.
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# Explanation of the `PickRequireParams` Type
|
|
2
|
+
|
|
3
|
+
`PickRequireParams` is an advanced TypeScript utility type designed to extract the required keys from an entry type after merging it with additional parameters. It achieves this by excluding specific keys—namely, `"result"`, `"tag"`, and `"cachedSeconds"`—which are considered metadata or non-essential for defining required parameters. This type proves extremely useful when determining which parameters are needed for a particular API operation.
|
|
4
|
+
|
|
5
|
+
## Type Definition
|
|
6
|
+
|
|
7
|
+
```typescript
|
|
8
|
+
type PickRequireParams<
|
|
9
|
+
M extends TESIEntryMethod,
|
|
10
|
+
EPx extends ESIEndpointOf<M> | string,
|
|
11
|
+
AdditionalParams,
|
|
12
|
+
Entry = _ESIResponseType<M, EPx>
|
|
13
|
+
> = Exclude<keyof (Entry & AdditionalParams), "result" | "tag" | "cachedSeconds">;
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Template Parameters
|
|
17
|
+
|
|
18
|
+
- **`M extends TESIEntryMethod`**
|
|
19
|
+
Denotes the HTTP method (such as `"get"`, `"post"`, etc.) used for the request. This helps narrow down the endpoint and response types applicable for the method.
|
|
20
|
+
|
|
21
|
+
- **`EPx extends ESIEndpointOf<M> | string`**
|
|
22
|
+
Represents the endpoint path. It can either be a specific parameterized endpoint from a predefined collection (for the given HTTP method) or a generic string.
|
|
23
|
+
|
|
24
|
+
- **`AdditionalParams`**
|
|
25
|
+
Contains any extra parameters that need to be considered. These are merged with the entry type to facilitate a comprehensive parameter extraction.
|
|
26
|
+
|
|
27
|
+
- **`Entry = _ESIResponseType<M, EPx>`**
|
|
28
|
+
By default, this infers the response type corresponding to the HTTP method and endpoint provided. The resulting type is combined with `AdditionalParams` to determine the full set of keys available before excluding the non-required ones.
|
|
29
|
+
|
|
30
|
+
## How It Works
|
|
31
|
+
|
|
32
|
+
1. **Merging Types**
|
|
33
|
+
The type starts by merging `Entry` with `AdditionalParams` using an intersection (`Entry & AdditionalParams`). This combined type gathers all properties from both sources.
|
|
34
|
+
|
|
35
|
+
2. **Extracting Keys**
|
|
36
|
+
Using `keyof` on the merged type yields a union of all property keys present in either `Entry` or `AdditionalParams`.
|
|
37
|
+
|
|
38
|
+
3. **Excluding Unwanted Keys**
|
|
39
|
+
The `Exclude` utility then removes the keys `"result"`, `"tag"`, and `"cachedSeconds"` from the union. These keys are typically reserved for metadata or caching information and are not required as input parameters.
|
|
40
|
+
|
|
41
|
+
## Practical Example
|
|
42
|
+
|
|
43
|
+
```typescript
|
|
44
|
+
type ExampleEntry = { result: string, tag: string, cachedSeconds: number, auth: string };
|
|
45
|
+
type RequiredParams = PickRequireParams<"get", "/example/endpoint", { auth: string }, ExampleEntry>;
|
|
46
|
+
// Result: "auth"
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
In this example:
|
|
50
|
+
- The `ExampleEntry` type contains metadata keys (`result`, `tag`, `cachedSeconds`) and an essential key `auth`.
|
|
51
|
+
- After merging with `AdditionalParams` (which provides `{ auth: string }`), the `PickRequireParams` type excludes the metadata keys.
|
|
52
|
+
- The final resulting type, `RequiredParams`, is `"auth"`, representing the required parameter.
|
|
53
|
+
|
|
54
|
+
---
|
|
55
|
+
|
|
56
|
+
`PickRequireParams` provides a powerful approach to isolating the essential parameters needed for API operations, ensuring that extraneous metadata does not interfere with type-safety and clarity in your API definitions.
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# Explanation of the `ReplacePathParams` Type
|
|
2
|
+
|
|
3
|
+
`ReplacePathParams` is a recursive TypeScript type designed to replace dynamic segments—specifically,
|
|
4
|
+
the path parameters enclosed in curly braces—in a string literal with a standardized template literal interpolation of `${number}`.
|
|
5
|
+
This is especially useful when defining API endpoints where parameters in the URL are expected to be numeric.
|
|
6
|
+
|
|
7
|
+
## Type Definition
|
|
8
|
+
|
|
9
|
+
```typescript
|
|
10
|
+
type ReplacePathParams<T extends unknown> = T extends `${infer Start}{${infer Param}}${infer End}`
|
|
11
|
+
? `${Start}${number}${ReplacePathParams<End>}`
|
|
12
|
+
: T;
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
### Parameters
|
|
16
|
+
|
|
17
|
+
+ T extends unknown Although T is declared with the type unknown, it is intended to be a string literal representing the endpoint path.
|
|
18
|
+
The type processes the string to find dynamic segments that need to be replaced.
|
|
19
|
+
|
|
20
|
+
### How It Works
|
|
21
|
+
|
|
22
|
+
1. Pattern Matching The type checks if the input string T matches the pattern:
|
|
23
|
+
|
|
24
|
+
`${infer Start}{${infer Param}}${infer End}`
|
|
25
|
+
|
|
26
|
+
+ `Start`: Captures the substring leading up to the first occurrence of a path parameter.
|
|
27
|
+
|
|
28
|
+
+ `{${infer Param}}`: Matches a section of the string enclosed in curly braces. The content inside the braces, which is the path parameter's name, is stored temporarily in Param.
|
|
29
|
+
|
|
30
|
+
+ `End`: Captures the remaining part of the string following the matched dynamic segment.
|
|
31
|
+
|
|
32
|
+
2. **Recursive Replacement** If the pattern is matched:
|
|
33
|
+
|
|
34
|
+
+ The matching segment `{${infer Param}}` is replaced with `${number}`.
|
|
35
|
+
|
|
36
|
+
+ The type then recursively applies itself to the remainder of the string (`End`) by calling `ReplacePathParams<End>`,
|
|
37
|
+
ensuring that all occurrences of path parameters are replaced.
|
|
38
|
+
|
|
39
|
+
3. Base Case If `T` does not contain any substring that fits the pattern (i.e., no occurrence of a dynamic segment in curly braces),
|
|
40
|
+
the type simply evaluates to `T` without modification. This serves as the termination condition for the recursion.
|
|
41
|
+
|
|
42
|
+
### Practical Example
|
|
43
|
+
|
|
44
|
+
```ts
|
|
45
|
+
type Example = ReplacePathParams<"/characters/{character_id}/fittings/{fitting_id}/">;
|
|
46
|
+
// Evaluates to: "/characters/${number}/fittings/${number}/"
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
In this example:
|
|
50
|
+
|
|
51
|
+
1. The first dynamic segment `{character_id}` is replaced with `${number}`.
|
|
52
|
+
|
|
53
|
+
1. The type then recursively processes the remaining string, encountering and replacing {fitting_id} with `${number}`.
|
|
54
|
+
|
|
55
|
+
1. The final resulting type is `"/characters/${number}/fittings/${number}/"`.
|
|
56
|
+
|
|
57
|
+
---
|
|
58
|
+
|
|
59
|
+
The `ReplacePathParams` type is a powerful tool for transforming endpoint strings into a more standardized format.
|
|
60
|
+
This is especially beneficial when type-checking API route definitions or dynamically generating strongly-typed URL strings based on certain conditions.
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# Explanation of the `ResolvedEndpoint` Type
|
|
2
|
+
|
|
3
|
+
`ResolvedEndpoint` is a utility TypeScript type that determines the final, "resolved" endpoint based on a given real endpoint and the specific HTTP method. It leverages the `InferEndpointOrigin` type to deduce the original parameterized endpoint from the real endpoint. If no matching parameterized endpoint is found (i.e., the inference results in `never`), it defaults back to the real endpoint.
|
|
4
|
+
|
|
5
|
+
## Type Definition
|
|
6
|
+
|
|
7
|
+
```typescript
|
|
8
|
+
type ResolvedEndpoint<
|
|
9
|
+
RealEP extends unknown, M extends TESIEntryMethod,
|
|
10
|
+
> = InferEndpointOrigin<RealEP, M> extends never ? RealEP : InferEndpointOrigin<RealEP, M>;
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Template Parameters
|
|
14
|
+
|
|
15
|
+
- **`RealEP extends unknown`**
|
|
16
|
+
The real endpoint path, representing the actual URL used in a request (for example, `"/characters/123/fittings/456/"`).
|
|
17
|
+
|
|
18
|
+
- **`M extends TESIEntryMethod`**
|
|
19
|
+
The HTTP method (such as `"get"`, `"post"`, `"delete"`, etc.) used for the request. This is used to narrow down which set of parameterized endpoints should be considered.
|
|
20
|
+
|
|
21
|
+
## How It Works
|
|
22
|
+
|
|
23
|
+
1. **Endpoint Inference**
|
|
24
|
+
The type starts by invoking `InferEndpointOrigin<RealEP, M>`, which attempts to map the real endpoint to its original parameterized form (e.g., converting `"/characters/123/fittings/456/"` to `"/characters/{character_id}/fittings/{fitting_id}/"`).
|
|
25
|
+
|
|
26
|
+
2. **Conditional Resolution**
|
|
27
|
+
- If `InferEndpointOrigin<RealEP, M>` results in `never`, it means no matching parameterized endpoint could be inferred from the given real endpoint. In such cases, the type falls back and returns `RealEP` as is.
|
|
28
|
+
- If the inference is successful, the resolved parameterized endpoint is returned.
|
|
29
|
+
|
|
30
|
+
## Practical Example
|
|
31
|
+
|
|
32
|
+
```ts
|
|
33
|
+
type Resolved = ResolvedEndpoint<"/characters/123/fittings/456/", "delete">;
|
|
34
|
+
// Evaluates to: "/characters/{character_id}/fittings/{fitting_id}/"
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
In this example:
|
|
38
|
+
- The real endpoint `"/characters/123/fittings/456/"` along with the HTTP method `"delete"` is provided.
|
|
39
|
+
- `InferEndpointOrigin` successfully maps it to its original form (`"/characters/{character_id}/fittings/{fitting_id}/"`), so that becomes the resolved endpoint.
|
|
40
|
+
- If the mapping had failed (i.e., if no parameterized endpoint matched), the type would have defaulted to returning the original real endpoint.
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
`ResolvedEndpoint` thus ensures that you get a consistent and properly parameterized endpoint format, which is crucial for maintaining type safety and clarity in API route definitions.
|
package/lib/rq-util.d.mts
CHANGED
|
@@ -181,22 +181,11 @@ export declare function getLogger(): {
|
|
|
181
181
|
clog: (...args: any[]) => void;
|
|
182
182
|
rlog: (...args: any[]) => void;
|
|
183
183
|
};
|
|
184
|
-
|
|
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
|
-
}
|
|
188
|
-
/**
|
|
189
|
-
* Need typescript v5.5 later
|
|
190
|
-
* @import * as ESI from "../v2";
|
|
191
|
-
* @typedef {ESI.TESIResponseOKMap} TESIResponseOKMap
|
|
192
|
-
* @typedef {ESI.TPathParamsNever} TPathParamsNever
|
|
193
|
-
* @typedef {ESI.IESIRequestFunction2<ESIRequestOptions>} IESIRequestFunction2
|
|
194
|
-
* @typedef {ESI.TESIRequestFunctionMethods2<ESIRequestOptions>} TESIRequestFunctionMethods2
|
|
195
|
-
*/
|
|
184
|
+
type TPrependParams = TESIRequestFunctionSignature2<ESIRequestOptions> | TESIRequestFunctionMethods2<ESIRequestOptions>;
|
|
196
185
|
/**
|
|
197
186
|
* #### Fire a request that does not require authentication.
|
|
198
187
|
*
|
|
199
|
-
* @param {
|
|
188
|
+
* @param {TPrependParams} fn
|
|
200
189
|
* @returns {Promise<void>}
|
|
201
190
|
*/
|
|
202
|
-
export declare function fireRequestsDoesNotRequireAuth(fn:
|
|
191
|
+
export declare function fireRequestsDoesNotRequireAuth(fn: TPrependParams): Promise<void>;
|
package/lib/rq-util.mjs
CHANGED
|
@@ -320,55 +320,37 @@ export function getLogger() {
|
|
|
320
320
|
const rlog = consoleUtil.getLogger("- - -> Run ESI request".cyan);
|
|
321
321
|
return { clog, rlog };
|
|
322
322
|
}
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
type IncompleteEP = ResolvedEndpoint<"/characters/1234/fittings/{fitting_id}/", "delete">;
|
|
332
|
-
|
|
333
|
-
// Result: "/characters/{character_id}/fittings/{fitting_id}/"
|
|
334
|
-
type EPOriginOK = InferEndpointOrigin<"/characters/123/fittings/456/", "delete">;
|
|
335
|
-
// result: never
|
|
336
|
-
type EPOriginNever = InferEndpointOrigin<"/characters/123/fittings/{fitting_id}/", "delete">;
|
|
337
|
-
// result: never
|
|
338
|
-
type EPOriginNever2 = InferEndpointOrigin<"/characters/{character_id}/fittings/456/", "delete">;
|
|
339
|
-
/*/
|
|
340
|
-
//*/
|
|
323
|
+
/**
|
|
324
|
+
* Need typescript v5.5 later
|
|
325
|
+
* @import * as ESI from "../v2";
|
|
326
|
+
* @typedef {ESI.TESIRequestFunctionMethods2<ESIRequestOptions>} TESIRequestFunctionMethods2
|
|
327
|
+
*/
|
|
328
|
+
/**
|
|
329
|
+
* @typedef {TESIRequestFunctionSignature2<ESIRequestOptions> | TESIRequestFunctionMethods2} TPrependParams
|
|
330
|
+
*/
|
|
341
331
|
/**
|
|
342
332
|
* #### Fire a request that does not require authentication.
|
|
343
333
|
*
|
|
344
|
-
* @type {
|
|
334
|
+
* @type {TESIEnhancedRequestFunctionSignature<TPrependParams, ESIRequestOptions>}
|
|
345
335
|
*/
|
|
346
|
-
// @ts-expect -error
|
|
347
336
|
const fireWithoutAuth = (fn, method, endpoint, ...opt) => {
|
|
348
|
-
const arg = opt.length ? opt[0] : void 0;
|
|
349
337
|
if (typeof fn === "function") {
|
|
350
|
-
|
|
338
|
+
const arg = opt.length ? opt[0] : void 0;
|
|
351
339
|
return fn(method, endpoint, /** @type {Parameters<typeof fn>[2]} */ (arg));
|
|
352
340
|
}
|
|
353
341
|
// @ts-expect-error TODO: ts(2345) The argument type does not match the type of the specified parameter
|
|
354
|
-
return fn[method](endpoint,
|
|
342
|
+
return fn[method](endpoint, ...opt);
|
|
355
343
|
};
|
|
356
|
-
|
|
357
|
-
* Need typescript v5.5 later
|
|
358
|
-
* @import * as ESI from "../v2";
|
|
359
|
-
* @typedef {ESI.TESIResponseOKMap} TESIResponseOKMap
|
|
360
|
-
* @typedef {ESI.TPathParamsNever} TPathParamsNever
|
|
361
|
-
* @typedef {ESI.IESIRequestFunction2<ESIRequestOptions>} IESIRequestFunction2
|
|
362
|
-
* @typedef {ESI.TESIRequestFunctionMethods2<ESIRequestOptions>} TESIRequestFunctionMethods2
|
|
363
|
-
*/
|
|
344
|
+
const token = `token.token.token`;
|
|
364
345
|
/**
|
|
365
346
|
* #### Fire a request that does not require authentication.
|
|
366
347
|
*
|
|
367
|
-
* @param {
|
|
348
|
+
* @param {TPrependParams} fn
|
|
368
349
|
* @returns {Promise<void>}
|
|
369
350
|
*/
|
|
370
351
|
export async function fireRequestsDoesNotRequireAuth(fn) {
|
|
371
352
|
const { clog, rlog } = getLogger();
|
|
353
|
+
const ID_SomeEVECharacter = 90000;
|
|
372
354
|
const ID_CCP_Zoetrope = 2112625428;
|
|
373
355
|
try {
|
|
374
356
|
// - - - - - - - - - - - -
|
|
@@ -393,12 +375,15 @@ export async function fireRequestsDoesNotRequireAuth(fn) {
|
|
|
393
375
|
if (is("withError")) {
|
|
394
376
|
await fireWithoutAuth(fn, "get", "/characters/{character_id}/assets/", {
|
|
395
377
|
auth: true,
|
|
396
|
-
pathParams:
|
|
378
|
+
pathParams: ID_SomeEVECharacter,
|
|
379
|
+
token
|
|
380
|
+
}).then(assets => {
|
|
381
|
+
log(assets.slice(0, 5));
|
|
397
382
|
});
|
|
398
383
|
await fireWithoutAuth(fn, "delete", `/characters/${1234}/fittings/${56789}/`, {
|
|
399
384
|
auth: true,
|
|
400
385
|
// pathParams: [1234, 56789], // ✅ At this point, the expected semantic error is successfully triggered as intended.
|
|
401
|
-
}).catch(
|
|
386
|
+
}).catch(log);
|
|
402
387
|
}
|
|
403
388
|
}
|
|
404
389
|
// - - - - - - - - - - - -
|
|
@@ -430,20 +415,21 @@ export async function fireRequestsDoesNotRequireAuth(fn) {
|
|
|
430
415
|
// The following is code to observe the behavior of completion by generics.
|
|
431
416
|
// Authentication is required, so an error will occur.
|
|
432
417
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
433
|
-
let willFailed = await fireWithoutAuth(fn, "get", `/characters/${
|
|
418
|
+
let willFailed = await fireWithoutAuth(fn, "get", `/characters/${ID_SomeEVECharacter}/ship/`, {
|
|
434
419
|
auth: true,
|
|
435
|
-
token
|
|
420
|
+
token //: "token.token.token"
|
|
436
421
|
});
|
|
437
|
-
log(`get:/characters/${
|
|
422
|
+
log(`get:/characters/${ID_SomeEVECharacter}/ship/, returns:`, willFailed);
|
|
438
423
|
// in this case, "categories" and "search" is required
|
|
439
424
|
await fireWithoutAuth(fn, "get", "/characters/{character_id}/search/", {
|
|
440
|
-
pathParams:
|
|
425
|
+
pathParams: ID_SomeEVECharacter,
|
|
441
426
|
query: {
|
|
442
|
-
categories: ["
|
|
443
|
-
search: "
|
|
427
|
+
categories: ["inventory_type"],
|
|
428
|
+
search: "plex"
|
|
444
429
|
},
|
|
445
|
-
auth: true
|
|
446
|
-
|
|
430
|
+
auth: true,
|
|
431
|
+
token
|
|
432
|
+
}).then(log);
|
|
447
433
|
// // TODO: want TypeScript semantics to throw an error because there is a required query parameter, but it's not possible
|
|
448
434
|
// // Or rather, I don't know how to do it.
|
|
449
435
|
// await fireWithoutAuth(fn, "get", "/characters/{character_id}/search/", {
|
package/package.json
CHANGED
package/v2/esi-tagged-types.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/esi-tagged-types.d.ts
|
|
12
|
-
* @summary This file is auto-generated and defines version 3.1.
|
|
12
|
+
* @summary This file is auto-generated and defines version 3.1.6 of the EVE Online ESI response types.
|
|
13
13
|
*/
|
|
14
14
|
import { TESIResponseOKMap } from "./index.d.ts";
|
|
15
15
|
export * from "./index.d.ts";
|
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.
|
|
12
|
+
* @summary This file is auto-generated and defines version 3.1.6 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";
|
|
@@ -36,7 +36,7 @@ import type { PickPathParameters, InferKeysLen } from "./util.d.ts";
|
|
|
36
36
|
* });
|
|
37
37
|
* ```
|
|
38
38
|
*/
|
|
39
|
-
export interface IESIRequestFunction2<ActualOpt
|
|
39
|
+
export interface IESIRequestFunction2<ActualOpt extends Record<string, unknown>>
|
|
40
40
|
extends TESIRequestFunctionSignature2<ActualOpt>, TESIRequestFunctionMethods2<ActualOpt> {
|
|
41
41
|
}
|
|
42
42
|
|
|
@@ -63,7 +63,7 @@ export interface IESIRequestFunction2<ActualOpt>
|
|
|
63
63
|
* });
|
|
64
64
|
* ```
|
|
65
65
|
*/
|
|
66
|
-
export type TESIRequestFunctionMethods2<ActualOpt
|
|
66
|
+
export type TESIRequestFunctionMethods2<ActualOpt extends Record<string, unknown>> = {
|
|
67
67
|
[method in TESIEntryMethod]: TESIRequestFunctionEachMethod2<method, ActualOpt>;
|
|
68
68
|
}
|
|
69
69
|
|
|
@@ -91,10 +91,13 @@ export declare type TESICachedSeconds<
|
|
|
91
91
|
: never
|
|
92
92
|
}[ESIEndpointOf<M>];
|
|
93
93
|
}[Method];
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Indicates that no path parameters are allowed.
|
|
97
|
+
*
|
|
98
|
+
* This type serves as a compile-time signal for endpoints that do not support dynamic URL segments.
|
|
99
|
+
* By using this type, it is clear that no path parameters should be provided.
|
|
100
|
+
*/
|
|
98
101
|
export declare type TPathParamsNever = { /* pathParams?: never */ };
|
|
99
102
|
|
|
100
103
|
// local types
|
|
@@ -143,7 +146,7 @@ export type _IfNeedPathParams<EP extends unknown> = IfParameterizedPath<EP> exte
|
|
|
143
146
|
*
|
|
144
147
|
* @template M - The HTTP method (e.g., "get", "post").
|
|
145
148
|
* @template EP - The endpoint path.
|
|
146
|
-
* @deprecated 2025/3/17
|
|
149
|
+
* @deprecated 2025/3/17
|
|
147
150
|
*/
|
|
148
151
|
export type __InferESIResponseResult<
|
|
149
152
|
M extends TESIEntryMethod,
|
|
@@ -155,7 +158,7 @@ export type __InferESIResponseResult<
|
|
|
155
158
|
* @template Entry - The entry type to identify parameters for.
|
|
156
159
|
* @template Opt - The type of the parameters.
|
|
157
160
|
* @type {Opt & Pick<Entry, Exclude<keyof Entry, "result">>}
|
|
158
|
-
* @deprecated 2025/3/17
|
|
161
|
+
* @deprecated 2025/3/17
|
|
159
162
|
*/
|
|
160
163
|
export type __IdentifyParameters<
|
|
161
164
|
Entry, Opt,
|
|
@@ -177,7 +180,7 @@ type ESIEntryKeys = "auth" | "query" | "body" | "pathParams";
|
|
|
177
180
|
*
|
|
178
181
|
* @template T - The original type to be constrained.
|
|
179
182
|
* @template T2 - The type to merge with the constrained type.
|
|
180
|
-
* @template
|
|
183
|
+
* @template RequireKeys - The keys to retain in the resulting type.
|
|
181
184
|
* @template Extras - Automatically derived keys to exclude from the resulting type.
|
|
182
185
|
*
|
|
183
186
|
* @example
|
|
@@ -190,11 +193,10 @@ type ESIEntryKeys = "auth" | "query" | "body" | "pathParams";
|
|
|
190
193
|
*/
|
|
191
194
|
//* ctt
|
|
192
195
|
type RestrictKeys<
|
|
193
|
-
T,
|
|
194
|
-
Extras = Exclude<ESIEntryKeys,
|
|
196
|
+
T, RequireKeys extends keyof T,
|
|
197
|
+
Extras = Exclude<ESIEntryKeys, RequireKeys>
|
|
195
198
|
> = {
|
|
196
|
-
[P in keyof T]: P extends
|
|
197
|
-
P extends Extras ? never : T[P];
|
|
199
|
+
[P in keyof T]: P extends Extras ? never : T[P];
|
|
198
200
|
};
|
|
199
201
|
// type RequireEntry = {
|
|
200
202
|
// auth?: true;
|
|
@@ -228,9 +230,12 @@ declare global {
|
|
|
228
230
|
* type RequiredA = RequireThese<Original, 'a'>;
|
|
229
231
|
* // Result: { a: number; b?: string; c: boolean }
|
|
230
232
|
* ```
|
|
233
|
+
* @see Documentation of [`RequireThese`](../docs/v2/require-these.md)
|
|
231
234
|
*/
|
|
232
235
|
type RequireThese<T, K extends keyof T> = {
|
|
233
|
-
[P in keyof T
|
|
236
|
+
[P in keyof T as P extends K ? P : never]-?: T[P];
|
|
237
|
+
} & {
|
|
238
|
+
[P in keyof T as P extends K ? never : P]: T[P];
|
|
234
239
|
};
|
|
235
240
|
|
|
236
241
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
@@ -262,7 +267,7 @@ declare global {
|
|
|
262
267
|
* The `...options: HasOpt extends 1 ? [Opt] : [Opt?]` parameter is defined this way to enforce that if the endpoint has required parameters,
|
|
263
268
|
* the `options` parameter must be provided. If there are no required parameters, the `options` parameter is optional.
|
|
264
269
|
*/
|
|
265
|
-
type TESIRequestFunctionSignature2<ActualOpt
|
|
270
|
+
type TESIRequestFunctionSignature2<ActualOpt extends Record<string, unknown>> = <
|
|
266
271
|
Mtd extends TESIEntryMethod,
|
|
267
272
|
REP extends ReplacePathParams<ESIEndpointOf<Mtd>> | ESIEndpointOf<Mtd>,
|
|
268
273
|
EPX extends ResolvedEndpoint<REP, Mtd>,
|
|
@@ -272,6 +277,53 @@ declare global {
|
|
|
272
277
|
HasOpt = HasRequireParams<Mtd, EPX, PPM>,
|
|
273
278
|
>(method: Mtd, endpoint: REP, ...options: HasOpt extends 1 ? [Opt] : [Opt?]) => Promise<Ret>;
|
|
274
279
|
|
|
280
|
+
/**
|
|
281
|
+
* A function signature type for making enhanced ESI requests.
|
|
282
|
+
*
|
|
283
|
+
* This type extends the base ESI request function signature by injecting a prepended parameter to allow for extra
|
|
284
|
+
* context or pre-processing before performing the request. It provides a highly generic interface that adapts to the
|
|
285
|
+
* chosen endpoint method, endpoint configuration, and additional options, making it ideal for advanced API interactions.
|
|
286
|
+
*
|
|
287
|
+
* Generic Parameters:
|
|
288
|
+
* @template PrependParam - The type of the additional parameter that is injected at the beginning of the function call.
|
|
289
|
+
* @template ActualOpt - An object representing the default options (typically extending ESIRequestOptions) used for the request.
|
|
290
|
+
*
|
|
291
|
+
* Function Generic Parameters:
|
|
292
|
+
* @template Mtd - The ESI request method type (e.g., GET, POST) as defined in TESIEntryMethod.
|
|
293
|
+
* @template REP - The endpoint type, which can be either a version with replaced path parameters (via ReplacePathParams)
|
|
294
|
+
* or the raw ESIEndpointOf<Mtd> type.
|
|
295
|
+
* @template EPX - The resolved endpoint type derived from REP and Mtd.
|
|
296
|
+
* @template PPM - The type representing the inferred path parameters extracted from REP and EPX.
|
|
297
|
+
* @template Opt - The type for additional request options, identified based on the method (Mtd), endpoint (EPX), the
|
|
298
|
+
* default options (ActualOpt), and inferred path parameters (PPM).
|
|
299
|
+
* @template Ret - The type of the response result from the ESI request, inferred from the method and endpoint.
|
|
300
|
+
* @template HasOpt - An internal flag used to determine whether request options (Opt) are required (1) or optional.
|
|
301
|
+
*
|
|
302
|
+
* Parameters:
|
|
303
|
+
* @param {PrependParam} prependParam - A prepended parameter providing additional context or configuration for the request.
|
|
304
|
+
* @param {Mtd} method - The ESI request method.
|
|
305
|
+
* @param {REP} endpoint - The API endpoint, which might include path parameter replacements.
|
|
306
|
+
* @param {...(HasOpt extends 1 ? [Opt] : [Opt?])} options - Additional options for the request; required if HasOpt is 1,
|
|
307
|
+
* otherwise optional.
|
|
308
|
+
*
|
|
309
|
+
* @returns {Promise<Ret>} A promise that resolves with the result type `Ret`, representing the response data from the ESI endpoint.
|
|
310
|
+
* @see Documentation of [`TESIEnhancedRequestFunctionSignature`](../docs/v3/esi-enhanced-function-signature.md)
|
|
311
|
+
*/
|
|
312
|
+
type TESIEnhancedRequestFunctionSignature<
|
|
313
|
+
PrependParam extends unknown, ActualOpt extends Record<string, unknown>
|
|
314
|
+
> = <
|
|
315
|
+
Mtd extends TESIEntryMethod,
|
|
316
|
+
REP extends ReplacePathParams<ESIEndpointOf<Mtd>> | ESIEndpointOf<Mtd>,
|
|
317
|
+
EPX extends ResolvedEndpoint<REP, Mtd>,
|
|
318
|
+
PPM extends InferPathParams<REP, EPX>,
|
|
319
|
+
Opt extends IdentifyParameters<Mtd, EPX, ActualOpt, PPM>,
|
|
320
|
+
Ret extends InferESIResponseResult<Mtd, EPX>,
|
|
321
|
+
HasOpt = HasRequireParams<Mtd, EPX, PPM>
|
|
322
|
+
>(
|
|
323
|
+
prependParam: PrependParam,
|
|
324
|
+
method: Mtd, endpoint: REP, ...options: HasOpt extends 1 ? [Opt] : [Opt?]
|
|
325
|
+
) => Promise<Ret>;
|
|
326
|
+
|
|
275
327
|
/**
|
|
276
328
|
* Represents a function that can make ESI requests for a specific HTTP method.
|
|
277
329
|
*
|
|
@@ -295,7 +347,7 @@ declare global {
|
|
|
295
347
|
* The `...options: HasOpt extends 1 ? [Opt] : [Opt?]` parameter is defined this way to enforce that if the endpoint has required parameters,
|
|
296
348
|
* the `options` parameter must be provided. If there are no required parameters, the `options` parameter is optional.
|
|
297
349
|
*/
|
|
298
|
-
type TESIRequestFunctionEachMethod2<Mtd extends TESIEntryMethod, ActualOpt
|
|
350
|
+
type TESIRequestFunctionEachMethod2<Mtd extends TESIEntryMethod, ActualOpt extends Record<string, unknown>> = <
|
|
299
351
|
REP extends ReplacePathParams<ESIEndpointOf<Mtd>> | ESIEndpointOf<Mtd>,
|
|
300
352
|
EPX extends ResolvedEndpoint<REP, Mtd>,
|
|
301
353
|
PPM extends InferPathParams<REP, EPX>,
|
|
@@ -314,6 +366,7 @@ declare global {
|
|
|
314
366
|
* type Example = ReplacePathParams<"/characters/{character_id}/fittings/{fitting_id}/">;
|
|
315
367
|
* // Result: `/characters/${number}/fittings/${number}/`
|
|
316
368
|
* ```
|
|
369
|
+
* @see Documentation of [`ReplacePathParams`](../docs/v3/replace-path-params.md)
|
|
317
370
|
*/
|
|
318
371
|
type ReplacePathParams<T extends unknown> = T extends `${infer Start}{${infer Param}}${infer End}`
|
|
319
372
|
? `${Start}${number}${ReplacePathParams<End>}` : T;
|
|
@@ -331,7 +384,8 @@ declare global {
|
|
|
331
384
|
* @returns {TPathParamsNever | _IfNeedPathParams<EPx>}
|
|
332
385
|
* @see {@link _IfNeedPathParams}
|
|
333
386
|
* @see {@link TPathParamsNever}
|
|
334
|
-
* @
|
|
387
|
+
* @see Documentation of [`InferPathParams`](../docs/v3/infer-path-params.md)
|
|
388
|
+
* @date 2025/3/17
|
|
335
389
|
*/
|
|
336
390
|
type InferPathParams<
|
|
337
391
|
RealEP extends unknown, EPx extends unknown
|
|
@@ -354,6 +408,7 @@ declare global {
|
|
|
354
408
|
* ```
|
|
355
409
|
* @see {@link ESIEndpointOf}
|
|
356
410
|
* @see {@link ReplacePathParams}
|
|
411
|
+
* @see Documentation of [`InferEndpointOrigin`](../docs/v3/infer-endpoint-origin.md)
|
|
357
412
|
*/
|
|
358
413
|
type InferEndpointOrigin<
|
|
359
414
|
RealEP extends unknown, M extends TESIEntryMethod,
|
|
@@ -373,9 +428,8 @@ declare global {
|
|
|
373
428
|
* type Resolved = ResolvedEndpoint<"/characters/123/fittings/456/", "delete">;
|
|
374
429
|
* // Result: "/characters/{character_id}/fittings/{fitting_id}/"
|
|
375
430
|
* ```
|
|
376
|
-
* DONE: 2025/3/17 4:12:09 Ok, works
|
|
377
|
-
*
|
|
378
431
|
* @see {@link InferEndpointOrigin}
|
|
432
|
+
* @see Documentation of [`ResolvedEndpoint`](../docs/v3/resolved-endpoint.md)
|
|
379
433
|
*/
|
|
380
434
|
type ResolvedEndpoint<
|
|
381
435
|
RealEP extends unknown, M extends TESIEntryMethod,
|
|
@@ -400,6 +454,7 @@ declare global {
|
|
|
400
454
|
* ```
|
|
401
455
|
* @see {@link ESIEndpointOf}
|
|
402
456
|
* @see {@link _ESIResponseType}
|
|
457
|
+
* @see Documentation of [`PickRequireParams`](../docs/v3/pick-require-params.md)
|
|
403
458
|
*/
|
|
404
459
|
type PickRequireParams<
|
|
405
460
|
M extends TESIEntryMethod,
|
|
@@ -424,6 +479,7 @@ declare global {
|
|
|
424
479
|
* ```
|
|
425
480
|
* @see {@link ESIEndpointOf}
|
|
426
481
|
* @see {@link PickRequireParams}
|
|
482
|
+
* @see Documentation of [`HasRequireParams`](../docs/v3/has-require-params.md)
|
|
427
483
|
*/
|
|
428
484
|
type HasRequireParams<
|
|
429
485
|
M extends TESIEntryMethod,
|
|
@@ -441,6 +497,7 @@ declare global {
|
|
|
441
497
|
* @template Opt The type to return if `EP` is not parameterized.
|
|
442
498
|
* @returns {number | [number, number] | Opt}
|
|
443
499
|
* Returns `number` if there is one parameter, `[number, number]` if there are two parameters, otherwise `Opt`.
|
|
500
|
+
* @see Documentation of [`IfParameterizedPath`](../docs/v2/if-parameterized-path.md)
|
|
444
501
|
*/
|
|
445
502
|
type IfParameterizedPath<EP extends unknown, Opt = never> = EP extends `${string}/{${string}}${string}`
|
|
446
503
|
? PickPathParameters<EP> extends never
|
|
@@ -458,7 +515,7 @@ declare global {
|
|
|
458
515
|
* @template EPx - The endpoint path.
|
|
459
516
|
* @template Opt - The type of the additional options.
|
|
460
517
|
* @template Entry - The entry type to identify parameters for.
|
|
461
|
-
* @template
|
|
518
|
+
* @template RequireKeys - The keys of the entry type that are required parameters.
|
|
462
519
|
*
|
|
463
520
|
* @example
|
|
464
521
|
* ```ts
|
|
@@ -470,6 +527,7 @@ declare global {
|
|
|
470
527
|
* @see {@link RequireThese}
|
|
471
528
|
* @see {@link ESIEndpointOf}
|
|
472
529
|
* @see {@link _ESIResponseType}
|
|
530
|
+
* @see Documentation of [`IdentifyParameters`](../docs/v2/identify-parameters.md)
|
|
473
531
|
*/
|
|
474
532
|
//* ctt
|
|
475
533
|
type IdentifyParameters<
|
|
@@ -477,10 +535,10 @@ declare global {
|
|
|
477
535
|
EPx extends ESIEndpointOf<M> | string,
|
|
478
536
|
Opt extends Record<string, unknown>,
|
|
479
537
|
AdditionalParams,
|
|
480
|
-
Entry = _ESIResponseType<M, EPx
|
|
481
|
-
|
|
482
|
-
// @ts-expect-
|
|
483
|
-
> = RestrictKeys<Opt,
|
|
538
|
+
Entry = _ESIResponseType<M, EPx> & AdditionalParams,
|
|
539
|
+
RequireKeys = Exclude<keyof (Entry & AdditionalParams), "result" | "tag" | "cachedSeconds">
|
|
540
|
+
// @ts-expect-error
|
|
541
|
+
> = RestrictKeys<Opt, RequireKeys> & Pick<Entry, RequireKeys> & AdditionalParams;
|
|
484
542
|
/*/
|
|
485
543
|
// DEVNOTE: 2025/3/24
|
|
486
544
|
// The definition is simple and highly maintainable, but it is not possible to reference the `pathParams` property when implementing `TESIRequestFunctionSignature2` etc.
|
|
@@ -508,6 +566,7 @@ declare global {
|
|
|
508
566
|
* ```
|
|
509
567
|
* @see {@link ESIEndpointOf}
|
|
510
568
|
* @see {@link _ESIResponseType}
|
|
569
|
+
* @see Documentation of [`InferESIResponseResult`](../docs/v2/infer-esi-response-result.md)
|
|
511
570
|
*/
|
|
512
571
|
type InferESIResponseResult<
|
|
513
572
|
M extends TESIEntryMethod,
|
|
@@ -531,7 +590,8 @@ declare global {
|
|
|
531
590
|
type TESIEntryMethod = keyof TESIResponseOKMap;
|
|
532
591
|
|
|
533
592
|
/**
|
|
534
|
-
*
|
|
593
|
+
* Represents endpoints using `TESIEntryMethod`.
|
|
594
|
+
* @date 2025/3/16
|
|
535
595
|
*/
|
|
536
596
|
type ESIEndpointOf<M extends TESIEntryMethod> = keyof TESIResponseOKMap[M];
|
|
537
597
|
/**
|
package/v2/response-map.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/response-map.d.ts
|
|
12
|
-
* @summary This file is auto-generated and defines version 3.1.
|
|
12
|
+
* @summary This file is auto-generated and defines version 3.1.6 of the EVE Online ESI response types.
|
|
13
13
|
*/
|
|
14
14
|
import "./types-index.d.ts";
|
|
15
15
|
|
package/v2/types-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/types-index.d.ts
|
|
12
|
-
* @summary This file is auto-generated and defines version 3.1.
|
|
12
|
+
* @summary This file is auto-generated and defines version 3.1.6 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";
|
|
File without changes
|