eve-esi-types 3.1.4 → 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/package.json +1 -1
- package/v2/esi-tagged-types.d.ts +1 -1
- package/v2/index.d.ts +24 -11
- 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/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";
|
|
@@ -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,
|
|
@@ -227,6 +230,7 @@ declare global {
|
|
|
227
230
|
* type RequiredA = RequireThese<Original, 'a'>;
|
|
228
231
|
* // Result: { a: number; b?: string; c: boolean }
|
|
229
232
|
* ```
|
|
233
|
+
* @see Documentation of [`RequireThese`](../docs/v2/require-these.md)
|
|
230
234
|
*/
|
|
231
235
|
type RequireThese<T, K extends keyof T> = {
|
|
232
236
|
[P in keyof T as P extends K ? P : never]-?: T[P];
|
|
@@ -303,6 +307,7 @@ declare global {
|
|
|
303
307
|
* otherwise optional.
|
|
304
308
|
*
|
|
305
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)
|
|
306
311
|
*/
|
|
307
312
|
type TESIEnhancedRequestFunctionSignature<
|
|
308
313
|
PrependParam extends unknown, ActualOpt extends Record<string, unknown>
|
|
@@ -361,6 +366,7 @@ declare global {
|
|
|
361
366
|
* type Example = ReplacePathParams<"/characters/{character_id}/fittings/{fitting_id}/">;
|
|
362
367
|
* // Result: `/characters/${number}/fittings/${number}/`
|
|
363
368
|
* ```
|
|
369
|
+
* @see Documentation of [`ReplacePathParams`](../docs/v3/replace-path-params.md)
|
|
364
370
|
*/
|
|
365
371
|
type ReplacePathParams<T extends unknown> = T extends `${infer Start}{${infer Param}}${infer End}`
|
|
366
372
|
? `${Start}${number}${ReplacePathParams<End>}` : T;
|
|
@@ -378,7 +384,8 @@ declare global {
|
|
|
378
384
|
* @returns {TPathParamsNever | _IfNeedPathParams<EPx>}
|
|
379
385
|
* @see {@link _IfNeedPathParams}
|
|
380
386
|
* @see {@link TPathParamsNever}
|
|
381
|
-
* @
|
|
387
|
+
* @see Documentation of [`InferPathParams`](../docs/v3/infer-path-params.md)
|
|
388
|
+
* @date 2025/3/17
|
|
382
389
|
*/
|
|
383
390
|
type InferPathParams<
|
|
384
391
|
RealEP extends unknown, EPx extends unknown
|
|
@@ -401,6 +408,7 @@ declare global {
|
|
|
401
408
|
* ```
|
|
402
409
|
* @see {@link ESIEndpointOf}
|
|
403
410
|
* @see {@link ReplacePathParams}
|
|
411
|
+
* @see Documentation of [`InferEndpointOrigin`](../docs/v3/infer-endpoint-origin.md)
|
|
404
412
|
*/
|
|
405
413
|
type InferEndpointOrigin<
|
|
406
414
|
RealEP extends unknown, M extends TESIEntryMethod,
|
|
@@ -420,9 +428,8 @@ declare global {
|
|
|
420
428
|
* type Resolved = ResolvedEndpoint<"/characters/123/fittings/456/", "delete">;
|
|
421
429
|
* // Result: "/characters/{character_id}/fittings/{fitting_id}/"
|
|
422
430
|
* ```
|
|
423
|
-
* DONE: 2025/3/17 4:12:09 Ok, works
|
|
424
|
-
*
|
|
425
431
|
* @see {@link InferEndpointOrigin}
|
|
432
|
+
* @see Documentation of [`ResolvedEndpoint`](../docs/v3/resolved-endpoint.md)
|
|
426
433
|
*/
|
|
427
434
|
type ResolvedEndpoint<
|
|
428
435
|
RealEP extends unknown, M extends TESIEntryMethod,
|
|
@@ -447,6 +454,7 @@ declare global {
|
|
|
447
454
|
* ```
|
|
448
455
|
* @see {@link ESIEndpointOf}
|
|
449
456
|
* @see {@link _ESIResponseType}
|
|
457
|
+
* @see Documentation of [`PickRequireParams`](../docs/v3/pick-require-params.md)
|
|
450
458
|
*/
|
|
451
459
|
type PickRequireParams<
|
|
452
460
|
M extends TESIEntryMethod,
|
|
@@ -471,6 +479,7 @@ declare global {
|
|
|
471
479
|
* ```
|
|
472
480
|
* @see {@link ESIEndpointOf}
|
|
473
481
|
* @see {@link PickRequireParams}
|
|
482
|
+
* @see Documentation of [`HasRequireParams`](../docs/v3/has-require-params.md)
|
|
474
483
|
*/
|
|
475
484
|
type HasRequireParams<
|
|
476
485
|
M extends TESIEntryMethod,
|
|
@@ -488,6 +497,7 @@ declare global {
|
|
|
488
497
|
* @template Opt The type to return if `EP` is not parameterized.
|
|
489
498
|
* @returns {number | [number, number] | Opt}
|
|
490
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)
|
|
491
501
|
*/
|
|
492
502
|
type IfParameterizedPath<EP extends unknown, Opt = never> = EP extends `${string}/{${string}}${string}`
|
|
493
503
|
? PickPathParameters<EP> extends never
|
|
@@ -517,6 +527,7 @@ declare global {
|
|
|
517
527
|
* @see {@link RequireThese}
|
|
518
528
|
* @see {@link ESIEndpointOf}
|
|
519
529
|
* @see {@link _ESIResponseType}
|
|
530
|
+
* @see Documentation of [`IdentifyParameters`](../docs/v2/identify-parameters.md)
|
|
520
531
|
*/
|
|
521
532
|
//* ctt
|
|
522
533
|
type IdentifyParameters<
|
|
@@ -555,6 +566,7 @@ declare global {
|
|
|
555
566
|
* ```
|
|
556
567
|
* @see {@link ESIEndpointOf}
|
|
557
568
|
* @see {@link _ESIResponseType}
|
|
569
|
+
* @see Documentation of [`InferESIResponseResult`](../docs/v2/infer-esi-response-result.md)
|
|
558
570
|
*/
|
|
559
571
|
type InferESIResponseResult<
|
|
560
572
|
M extends TESIEntryMethod,
|
|
@@ -578,7 +590,8 @@ declare global {
|
|
|
578
590
|
type TESIEntryMethod = keyof TESIResponseOKMap;
|
|
579
591
|
|
|
580
592
|
/**
|
|
581
|
-
*
|
|
593
|
+
* Represents endpoints using `TESIEntryMethod`.
|
|
594
|
+
* @date 2025/3/16
|
|
582
595
|
*/
|
|
583
596
|
type ESIEndpointOf<M extends TESIEntryMethod> = keyof TESIResponseOKMap[M];
|
|
584
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
|