eve-esi-types 3.1.6 → 3.1.7

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eve-esi-types",
3
- "version": "3.1.6",
3
+ "version": "3.1.7",
4
4
  "description": "Extracted the main type of ESI. use for ESI request response types (version 2 only)",
5
5
  "main": "v2/index.d.ts",
6
6
  "scripts": {
@@ -15,7 +15,6 @@
15
15
  "v2",
16
16
  "lib",
17
17
  "web",
18
- "docs",
19
18
  "*.d.mts",
20
19
  "*.mjs",
21
20
  "LICENSE",
@@ -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.6 of the EVE Online ESI response types.
12
+ * @summary This file is auto-generated and defines version 3.1.7 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.6 of the EVE Online ESI response types.
12
+ * @summary This file is auto-generated and defines version 3.1.7 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";
@@ -230,7 +230,7 @@ declare global {
230
230
  * type RequiredA = RequireThese<Original, 'a'>;
231
231
  * // Result: { a: number; b?: string; c: boolean }
232
232
  * ```
233
- * @see Documentation of [`RequireThese`](../docs/v2/require-these.md)
233
+ * @see Documentation of [`RequireThese`](https://github.com/jeffy-g/eve-esi-types/blob/master/docs/v2/require-these.md)
234
234
  */
235
235
  type RequireThese<T, K extends keyof T> = {
236
236
  [P in keyof T as P extends K ? P : never]-?: T[P];
@@ -307,7 +307,7 @@ declare global {
307
307
  * otherwise optional.
308
308
  *
309
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)
310
+ * @see Documentation of [`TESIEnhancedRequestFunctionSignature`](https://github.com/jeffy-g/eve-esi-types/blob/master/docs/v3/esi-enhanced-function-signature.md)
311
311
  */
312
312
  type TESIEnhancedRequestFunctionSignature<
313
313
  PrependParam extends unknown, ActualOpt extends Record<string, unknown>
@@ -366,7 +366,7 @@ declare global {
366
366
  * type Example = ReplacePathParams<"/characters/{character_id}/fittings/{fitting_id}/">;
367
367
  * // Result: `/characters/${number}/fittings/${number}/`
368
368
  * ```
369
- * @see Documentation of [`ReplacePathParams`](../docs/v3/replace-path-params.md)
369
+ * @see Documentation of [`ReplacePathParams`](https://github.com/jeffy-g/eve-esi-types/blob/master/docs/v3/replace-path-params.md)
370
370
  */
371
371
  type ReplacePathParams<T extends unknown> = T extends `${infer Start}{${infer Param}}${infer End}`
372
372
  ? `${Start}${number}${ReplacePathParams<End>}` : T;
@@ -384,7 +384,7 @@ declare global {
384
384
  * @returns {TPathParamsNever | _IfNeedPathParams<EPx>}
385
385
  * @see {@link _IfNeedPathParams}
386
386
  * @see {@link TPathParamsNever}
387
- * @see Documentation of [`InferPathParams`](../docs/v3/infer-path-params.md)
387
+ * @see Documentation of [`InferPathParams`](https://github.com/jeffy-g/eve-esi-types/blob/master/docs/v3/infer-path-params.md)
388
388
  * @date 2025/3/17
389
389
  */
390
390
  type InferPathParams<
@@ -408,7 +408,7 @@ declare global {
408
408
  * ```
409
409
  * @see {@link ESIEndpointOf}
410
410
  * @see {@link ReplacePathParams}
411
- * @see Documentation of [`InferEndpointOrigin`](../docs/v3/infer-endpoint-origin.md)
411
+ * @see Documentation of [`InferEndpointOrigin`](https://github.com/jeffy-g/eve-esi-types/blob/master/docs/v3/infer-endpoint-origin.md)
412
412
  */
413
413
  type InferEndpointOrigin<
414
414
  RealEP extends unknown, M extends TESIEntryMethod,
@@ -429,7 +429,7 @@ declare global {
429
429
  * // Result: "/characters/{character_id}/fittings/{fitting_id}/"
430
430
  * ```
431
431
  * @see {@link InferEndpointOrigin}
432
- * @see Documentation of [`ResolvedEndpoint`](../docs/v3/resolved-endpoint.md)
432
+ * @see Documentation of [`ResolvedEndpoint`](https://github.com/jeffy-g/eve-esi-types/blob/master/docs/v3/resolved-endpoint.md)
433
433
  */
434
434
  type ResolvedEndpoint<
435
435
  RealEP extends unknown, M extends TESIEntryMethod,
@@ -454,7 +454,7 @@ declare global {
454
454
  * ```
455
455
  * @see {@link ESIEndpointOf}
456
456
  * @see {@link _ESIResponseType}
457
- * @see Documentation of [`PickRequireParams`](../docs/v3/pick-require-params.md)
457
+ * @see Documentation of [`PickRequireParams`](https://github.com/jeffy-g/eve-esi-types/blob/master/docs/v3/pick-require-params.md)
458
458
  */
459
459
  type PickRequireParams<
460
460
  M extends TESIEntryMethod,
@@ -479,7 +479,7 @@ declare global {
479
479
  * ```
480
480
  * @see {@link ESIEndpointOf}
481
481
  * @see {@link PickRequireParams}
482
- * @see Documentation of [`HasRequireParams`](../docs/v3/has-require-params.md)
482
+ * @see Documentation of [`HasRequireParams`](https://github.com/jeffy-g/eve-esi-types/blob/master/docs/v3/has-require-params.md)
483
483
  */
484
484
  type HasRequireParams<
485
485
  M extends TESIEntryMethod,
@@ -497,7 +497,7 @@ declare global {
497
497
  * @template Opt The type to return if `EP` is not parameterized.
498
498
  * @returns {number | [number, number] | Opt}
499
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)
500
+ * @see Documentation of [`IfParameterizedPath`](https://github.com/jeffy-g/eve-esi-types/blob/master/docs/v2/if-parameterized-path.md)
501
501
  */
502
502
  type IfParameterizedPath<EP extends unknown, Opt = never> = EP extends `${string}/{${string}}${string}`
503
503
  ? PickPathParameters<EP> extends never
@@ -527,7 +527,7 @@ declare global {
527
527
  * @see {@link RequireThese}
528
528
  * @see {@link ESIEndpointOf}
529
529
  * @see {@link _ESIResponseType}
530
- * @see Documentation of [`IdentifyParameters`](../docs/v2/identify-parameters.md)
530
+ * @see Documentation of [`IdentifyParameters`](https://github.com/jeffy-g/eve-esi-types/blob/master/docs/v2/identify-parameters.md)
531
531
  */
532
532
  //* ctt
533
533
  type IdentifyParameters<
@@ -566,7 +566,7 @@ declare global {
566
566
  * ```
567
567
  * @see {@link ESIEndpointOf}
568
568
  * @see {@link _ESIResponseType}
569
- * @see Documentation of [`InferESIResponseResult`](../docs/v2/infer-esi-response-result.md)
569
+ * @see Documentation of [`InferESIResponseResult`](https://github.com/jeffy-g/eve-esi-types/blob/master/docs/v2/infer-esi-response-result.md)
570
570
  */
571
571
  type InferESIResponseResult<
572
572
  M extends TESIEntryMethod,
@@ -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.6 of the EVE Online ESI response types.
12
+ * @summary This file is auto-generated and defines version 3.1.7 of the EVE Online ESI response types.
13
13
  */
14
14
  import "./types-index.d.ts";
15
15
 
@@ -1025,16 +1025,16 @@ export type TESIResponseOKMap = {
1025
1025
  post: {
1026
1026
  "/fleets/{fleet_id}/members/": {
1027
1027
  result: NoContentResponse;
1028
+ tag: "Fleets";
1028
1029
  /** `esi-fleets.write_fleet.v1` */
1029
1030
  auth: true;
1030
- tag: "Fleets";
1031
1031
  body: PostFleetsFleetIdMembersInvitation;
1032
1032
  },
1033
1033
  "/ui/autopilot/waypoint/": {
1034
1034
  result: NoContentResponse;
1035
+ tag: "User Interface";
1035
1036
  /** `esi-ui.write_waypoint.v1` */
1036
1037
  auth: true;
1037
- tag: "User Interface";
1038
1038
  query: {
1039
1039
  add_to_beginning: boolean;
1040
1040
  clear_other_waypoints: boolean;
@@ -1043,36 +1043,36 @@ export type TESIResponseOKMap = {
1043
1043
  },
1044
1044
  "/ui/openwindow/contract/": {
1045
1045
  result: NoContentResponse;
1046
+ tag: "User Interface";
1046
1047
  /** `esi-ui.open_window.v1` */
1047
1048
  auth: true;
1048
- tag: "User Interface";
1049
1049
  query: {
1050
1050
  contract_id: number;
1051
1051
  }
1052
1052
  },
1053
1053
  "/ui/openwindow/information/": {
1054
1054
  result: NoContentResponse;
1055
+ tag: "User Interface";
1055
1056
  /** `esi-ui.open_window.v1` */
1056
1057
  auth: true;
1057
- tag: "User Interface";
1058
1058
  query: {
1059
1059
  target_id: number;
1060
1060
  }
1061
1061
  },
1062
1062
  "/ui/openwindow/marketdetails/": {
1063
1063
  result: NoContentResponse;
1064
+ tag: "User Interface";
1064
1065
  /** `esi-ui.open_window.v1` */
1065
1066
  auth: true;
1066
- tag: "User Interface";
1067
1067
  query: {
1068
1068
  type_id: number;
1069
1069
  }
1070
1070
  },
1071
1071
  "/ui/openwindow/newmail/": {
1072
1072
  result: NoContentResponse;
1073
+ tag: "User Interface";
1073
1074
  /** `esi-ui.open_window.v1` */
1074
1075
  auth: true;
1075
- tag: "User Interface";
1076
1076
  body: PostUiOpenwindowNewmailNewMail;
1077
1077
  },
1078
1078
  "/characters/affiliation/": {
@@ -1175,17 +1175,17 @@ export type TESIResponseOKMap = {
1175
1175
  put: {
1176
1176
  "/characters/{character_id}/calendar/{event_id}/": {
1177
1177
  result: NoContentResponse;
1178
- /** `esi-calendar.respond_calendar_events.v1` */
1179
- auth: true;
1180
1178
  tag: "Calendar";
1181
1179
  cachedSeconds: 5;
1180
+ /** `esi-calendar.respond_calendar_events.v1` */
1181
+ auth: true;
1182
1182
  body: PutCharactersCharacterIdCalendarEventIdResponse;
1183
1183
  },
1184
1184
  "/characters/{character_id}/contacts/": {
1185
1185
  result: NoContentResponse;
1186
+ tag: "Contacts";
1186
1187
  /** `esi-characters.write_contacts.v1` */
1187
1188
  auth: true;
1188
- tag: "Contacts";
1189
1189
  body: PutCharactersCharacterIdContactsContactIds;
1190
1190
  query: {
1191
1191
  label_ids?: PutCharactersCharacterIdContactsLabelIds;
@@ -1195,85 +1195,85 @@ export type TESIResponseOKMap = {
1195
1195
  },
1196
1196
  "/characters/{character_id}/mail/{mail_id}/": {
1197
1197
  result: NoContentResponse;
1198
+ tag: "Mail";
1198
1199
  /** `esi-mail.organize_mail.v1` */
1199
1200
  auth: true;
1200
- tag: "Mail";
1201
1201
  body: PutCharactersCharacterIdMailMailIdContents;
1202
1202
  },
1203
1203
  "/fleets/{fleet_id}/": {
1204
1204
  result: NoContentResponse;
1205
+ tag: "Fleets";
1205
1206
  /** `esi-fleets.write_fleet.v1` */
1206
1207
  auth: true;
1207
- tag: "Fleets";
1208
1208
  body: PutFleetsFleetIdNewSettings;
1209
1209
  },
1210
1210
  "/fleets/{fleet_id}/members/{member_id}/": {
1211
1211
  result: NoContentResponse;
1212
+ tag: "Fleets";
1212
1213
  /** `esi-fleets.write_fleet.v1` */
1213
1214
  auth: true;
1214
- tag: "Fleets";
1215
1215
  body: PutFleetsFleetIdMembersMemberIdMovement;
1216
1216
  },
1217
1217
  "/fleets/{fleet_id}/squads/{squad_id}/": {
1218
1218
  result: NoContentResponse;
1219
+ tag: "Fleets";
1219
1220
  /** `esi-fleets.write_fleet.v1` */
1220
1221
  auth: true;
1221
- tag: "Fleets";
1222
1222
  body: PutFleetsFleetIdSquadsSquadIdNaming;
1223
1223
  },
1224
1224
  "/fleets/{fleet_id}/wings/{wing_id}/": {
1225
1225
  result: NoContentResponse;
1226
+ tag: "Fleets";
1226
1227
  /** `esi-fleets.write_fleet.v1` */
1227
1228
  auth: true;
1228
- tag: "Fleets";
1229
1229
  body: PutFleetsFleetIdWingsWingIdNaming;
1230
1230
  }
1231
1231
  },
1232
1232
  delete: {
1233
1233
  "/characters/{character_id}/contacts/": {
1234
1234
  result: NoContentResponse;
1235
+ tag: "Contacts";
1235
1236
  /** `esi-characters.write_contacts.v1` */
1236
1237
  auth: true;
1237
- tag: "Contacts";
1238
1238
  query: {
1239
1239
  contact_ids: DeleteCharactersCharacterIdContactsContactIds;
1240
1240
  }
1241
1241
  },
1242
1242
  "/characters/{character_id}/fittings/{fitting_id}/": {
1243
1243
  result: NoContentResponse;
1244
+ tag: "Fittings";
1244
1245
  /** `esi-fittings.write_fittings.v1` */
1245
1246
  auth: true;
1246
- tag: "Fittings";
1247
1247
  },
1248
1248
  "/characters/{character_id}/mail/labels/{label_id}/": {
1249
1249
  result: NoContentResponse;
1250
+ tag: "Mail";
1250
1251
  /** `esi-mail.organize_mail.v1` */
1251
1252
  auth: true;
1252
- tag: "Mail";
1253
1253
  },
1254
1254
  "/characters/{character_id}/mail/{mail_id}/": {
1255
1255
  result: NoContentResponse;
1256
+ tag: "Mail";
1256
1257
  /** `esi-mail.organize_mail.v1` */
1257
1258
  auth: true;
1258
- tag: "Mail";
1259
1259
  },
1260
1260
  "/fleets/{fleet_id}/members/{member_id}/": {
1261
1261
  result: NoContentResponse;
1262
+ tag: "Fleets";
1262
1263
  /** `esi-fleets.write_fleet.v1` */
1263
1264
  auth: true;
1264
- tag: "Fleets";
1265
1265
  },
1266
1266
  "/fleets/{fleet_id}/squads/{squad_id}/": {
1267
1267
  result: NoContentResponse;
1268
+ tag: "Fleets";
1268
1269
  /** `esi-fleets.write_fleet.v1` */
1269
1270
  auth: true;
1270
- tag: "Fleets";
1271
1271
  },
1272
1272
  "/fleets/{fleet_id}/wings/{wing_id}/": {
1273
1273
  result: NoContentResponse;
1274
+ tag: "Fleets";
1274
1275
  /** `esi-fleets.write_fleet.v1` */
1275
1276
  auth: true;
1276
- tag: "Fleets";
1277
1277
  }
1278
1278
  }
1279
1279
  };
@@ -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.6 of the EVE Online ESI response types.
12
+ * @summary This file is auto-generated and defines version 3.1.7 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";
@@ -1,120 +0,0 @@
1
- # ESI Tagged Types
2
-
3
- This document provides an overview of the types defined in the `eve-esi-types/v2/esi-tagged-types.d.ts` file. These types are used to handle EVE Online ESI responses.
4
-
5
- ## LCamelCase
6
-
7
- Converts a string to lower camel case.
8
-
9
- ```typescript
10
- type LCamelCase<S extends string> = S extends `${infer P1} ${infer P2}`
11
- ? `${Lowercase<P1>}${Capitalize<P2>}` : Lowercase<S>;
12
- ```
13
-
14
- ### Example
15
-
16
- ```typescript
17
- // returns "assets"
18
- LCamelCase<"Assets">
19
-
20
- // returns "factionWarfare"
21
- LCamelCase<"Faction Warfare">
22
- ```
23
-
24
- ## InferSomethingBy
25
-
26
- Infers something by a brand.
27
-
28
- ```typescript
29
- type InferSomethingByBrand<N = number> = N & { __enum: "InferSomethingBy" };
30
- type InferSomethingByMethod = InferSomethingByBrand<0>;
31
- type InferSomethingByTags = InferSomethingByBrand<1>;
32
- type InferSomethingBy<Tag, AsType extends InferSomethingByBrand = InferSomethingByMethod> = {
33
- [M in TESIEntryMethod]: TESIResponseOKMap[M] extends Record<`/${string}/`, { tag: infer ActualTag }>
34
- ? AsType extends InferSomethingByTags
35
- ? ActualTag : ActualTag extends Tag
36
- ? M
37
- : never
38
- : never;
39
- }[TESIEntryMethod];
40
- ```
41
-
42
- ## ESITags
43
-
44
- Maps HTTP methods to their corresponding tags.
45
-
46
- ```typescript
47
- type ESITags = InferSomethingBy<never, InferSomethingByTags>;
48
- ```
49
-
50
- ## InferMethod
51
-
52
- Infers the HTTP method based on the provided tag.
53
-
54
- ```typescript
55
- type InferMethod<Tag> = InferSomethingBy<Tag>;
56
- ```
57
-
58
- ## TaggedEndpointRequestFunction2
59
-
60
- Creates a function type for making requests to tagged endpoints.
61
-
62
- ```typescript
63
- type TaggedEndpointRequestFunction2<
64
- M extends TESIEntryMethod, Tag extends ESITags,
65
- ActualOpt extends Record<string, unknown> = {},
66
- EndPoints extends SelectEndpointByTag<Tag, M> = SelectEndpointByTag<Tag, M>,
67
- > = <
68
- REP extends ReplacePathParams<EndPoints> | EndPoints,
69
- EPX extends _InferEndpointOrigin<REP, EndPoints> extends never ? REP: _InferEndpointOrigin<REP, EndPoints>,
70
- PPM extends InferPathParams<REP, EPX>,
71
- Opt extends IdentifyParameters<M, EPX, ActualOpt & PPM>,
72
- Ret extends InferESIResponseResult<M, EPX>,
73
- HasOpt = HasRequireParams<M, EPX, PPM>,
74
- >(endpoint: REP, ...options: HasOpt extends 1 ? [Opt] : [Opt?]) => Promise<Ret>;
75
- ```
76
-
77
- ## ESITaggedEndpointRequest2
78
-
79
- Maps tags to their corresponding endpoint request functions.
80
-
81
- ```typescript
82
- type ESITaggedEndpointRequest2<Tag extends ESITags, ActualOpt extends Record<string, unknown> = {}> = {
83
- [tag in Tag]: {
84
- [method in InferMethod<Tag>]: TaggedEndpointRequestFunction2<method, tag, ActualOpt>;
85
- };
86
- }[Tag];
87
- ```
88
-
89
- ## SelectEndpointByTag
90
-
91
- Selects an endpoint by tag and method.
92
-
93
- ```typescript
94
- type SelectEndpointByTag<
95
- Tag extends ESITags, M extends TESIEntryMethod
96
- > = {
97
- [EP in keyof TESIResponseOKMap[M]]: TESIResponseOKMap[M][EP] extends { tag: infer ActualTag }
98
- ? ActualTag extends Tag
99
- ? EP : never
100
- : never;
101
- }[keyof TESIResponseOKMap[M]];
102
- ```
103
-
104
- ## TaggedESIRequestMap2
105
-
106
- Maps lower camel case tags to their corresponding endpoint request functions.
107
-
108
- ```typescript
109
- type TaggedESIRequestMap2<ActualOpt extends Record<string, unknown> = {}> = {
110
- [tag in ESITags as LCamelCase<tag>]: ESITaggedEndpointRequest2<tag, ActualOpt>;
111
- };
112
- ```
113
-
114
- ## TaggedESIRequestMapPartial2
115
-
116
- Creates a partial map of lower camel case tags to their corresponding endpoint request functions.
117
-
118
- ```typescript
119
- type TaggedESIRequestMapPartial2<Props extends LCamelCase<ESITags>> = RequireThese<Partial<TaggedESIRequestMap2>, Props>;
120
- ```
@@ -1,74 +0,0 @@
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.
@@ -1,70 +0,0 @@
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.
@@ -1,44 +0,0 @@
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.