eve-esi-types 2.2.6 → 2.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +25 -0
- package/esi-types-util.md +5 -1
- package/lib/esi-error-types.d.ts +104 -0
- package/lib/request-api.d.mts +27 -0
- package/lib/request-api.mjs +79 -0
- package/{rq-util.d.mts → lib/rq-util.d.mts} +58 -8
- package/{rq-util.mjs → lib/rq-util.mjs} +125 -15
- package/lib/tagged-request-api.d.mts +35 -0
- package/lib/tagged-request-api.mjs +74 -0
- package/minimal-rq.d.mts +1 -29
- package/minimal-rq.mjs +8 -52
- package/package.json +4 -2
- package/tagged-rq.d.mts +1 -0
- package/tagged-rq.mjs +23 -0
- package/tsconfig.json +3 -2
- package/v2/esi-tagged-types.d.ts +153 -0
- package/v2/get_characters_character_id_skillqueue_ok.d.ts +1 -1
- package/v2/index.d.ts +24 -18
- package/v2/response-map.d.ts +207 -7
- package/v2/types-index.d.ts +2 -2
- package/v2/util.d.ts +51 -0
- package/v2.d.mts +5 -1
- package/v2.mjs +16 -46
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
3
|
+
// Copyright (C) 2025 jeffy-g <hirotom1107@gmail.com>
|
|
4
|
+
// Released under the MIT license
|
|
5
|
+
// https://opensource.org/licenses/mit-license.php
|
|
6
|
+
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
7
|
+
*/
|
|
8
|
+
/// <reference types="../v2/esi-tagged-types"/>
|
|
9
|
+
/**
|
|
10
|
+
* @file eve-esi-types/lib/tagged-request-api.mts
|
|
11
|
+
*/
|
|
12
|
+
import { request } from "./request-api.mjs";
|
|
13
|
+
/**
|
|
14
|
+
* @typedef {`${string}${"" | `,${string}`}`} TMethodList
|
|
15
|
+
*/
|
|
16
|
+
/** @satisfies {`${XESI.ESITags}:${TMethodList}`[]} */
|
|
17
|
+
const ESITagsWithMethodList = [
|
|
18
|
+
"Alliance:get", "Assets:get,post",
|
|
19
|
+
"Calendar:get,put", "Character:get,post",
|
|
20
|
+
"Clones:get", "Contacts:get,post,put,delete",
|
|
21
|
+
"Contracts:get", "Corporation:get",
|
|
22
|
+
"Dogma:get", "Faction Warfare:get",
|
|
23
|
+
"Fittings:get,post,delete", "Fleets:get,post,put,delete",
|
|
24
|
+
"Incursions:get", "Industry:get",
|
|
25
|
+
"Insurance:get", "Killmails:get",
|
|
26
|
+
"Location:get", "Loyalty:get",
|
|
27
|
+
"Mail:get,post,put,delete", "Market:get",
|
|
28
|
+
"Opportunities:get", "Planetary Interaction:get",
|
|
29
|
+
"Routes:get", "Search:get",
|
|
30
|
+
"Skills:get", "Sovereignty:get",
|
|
31
|
+
"Status:get", "Universe:get,post",
|
|
32
|
+
"User Interface:post", "Wallet:get",
|
|
33
|
+
"Wars:get"
|
|
34
|
+
];
|
|
35
|
+
/**
|
|
36
|
+
* `esi-tagged-types` and `injectESIRequestBody` allow for more intuitive use of ESI requests based on the "tags" defined in the EVE Swagger JSON.
|
|
37
|
+
*
|
|
38
|
+
* + The `ESI request API object` constructed by `injectESIRequestBody` lists narrowed endpoints by accessing the camel-cased "tags" members.
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* import * as taggedApi from "eve-esi-types/lib/tagged-request-api.mjs";
|
|
42
|
+
*
|
|
43
|
+
* const esiRequest = taggedApi.injectESIRequestBody(...);
|
|
44
|
+
* const ret = await esiRequest.universe.get("/universe/structures/", { query: { filter: "market" }});
|
|
45
|
+
*
|
|
46
|
+
* @template {Record<string, unknown>} Opt
|
|
47
|
+
* @param {TESIRequestFunctionSignature<{}>} requestBody
|
|
48
|
+
* @returns {XESI.TaggedESIRequestMap}
|
|
49
|
+
* @since 2.3
|
|
50
|
+
*/
|
|
51
|
+
export function injectESIRequestBody(requestBody) {
|
|
52
|
+
const rq = /** @type {XESI.TaggedESIRequestMap<Opt>} */ ({});
|
|
53
|
+
for (const tagEntry of ESITagsWithMethodList) {
|
|
54
|
+
const [tag, methodList] = /** @type {[tag: XESI.ESITags, methods: TMethodList]} */ (tagEntry.split(":"));
|
|
55
|
+
const methods = /** @type {TESIEntryMethod[]} */ (methodList.split(","));
|
|
56
|
+
const entry = /** @type {XESI.ESITaggedEndpointRequest<typeof tag, Opt>} */ ({});
|
|
57
|
+
for (const method of methods) {
|
|
58
|
+
// @ts-expect-error
|
|
59
|
+
entry[method] = /** @satisfies {XESI.TaggedEndpointRequestFunction<typeof method, typeof tag>} */ ((e, params, opt) => requestBody(method, e, params, opt));
|
|
60
|
+
}
|
|
61
|
+
const camelCased = /** @type {XESI.LCamelCase<XESI.ESITags>} */ (tag[0].toLowerCase() + tag.slice(1).replace(/\s(.)/g, "$1"));
|
|
62
|
+
rq[camelCased] = entry;
|
|
63
|
+
}
|
|
64
|
+
return rq;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* @import { ESIRequestOptions } from "./rq-util.mjs";
|
|
68
|
+
*/
|
|
69
|
+
/**
|
|
70
|
+
* Injects the minimal implementation of ESI requests into `XESI.TaggedESIRequestMap`.
|
|
71
|
+
* @since 2.3
|
|
72
|
+
* @type {XESI.TaggedESIRequestMap<ESIRequestOptions>}
|
|
73
|
+
*/
|
|
74
|
+
export const esi = injectESIRequestBody(request);
|
package/minimal-rq.d.mts
CHANGED
|
@@ -1,29 +1 @@
|
|
|
1
|
-
|
|
2
|
-
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
3
|
-
// Copyright (C) 2025 jeffy-g <hirotom1107@gmail.com>
|
|
4
|
-
// Released under the MIT license
|
|
5
|
-
// https://opensource.org/licenses/mit-license.php
|
|
6
|
-
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
7
|
-
*/
|
|
8
|
-
import * as util from "./rq-util.mjs";
|
|
9
|
-
import type { IESIRequestFunction } from "./v2";
|
|
10
|
-
/**
|
|
11
|
-
* @typedef {import("./v2").TESIResponseOKMap} TESIResponseOKMap
|
|
12
|
-
* @typedef {import("./rq-util.mjs").ESIRequestOptions} ESIRequestOptions
|
|
13
|
-
* @typedef {import("./v2").IESIRequestFunction<util.ESIRequestOptions>} IESIRequestFunction
|
|
14
|
-
* @typedef {import("./v2").TESIRequestFunctionMethods<util.ESIRequestOptions>} TESIRequestFunctionMethods
|
|
15
|
-
*/
|
|
16
|
-
/** #### Sample of `TESIRequestFunctionSignature`
|
|
17
|
-
*
|
|
18
|
-
* + This is a minimal implementation using `TESIRequestFunctionSignature`.
|
|
19
|
-
* If the response contains "page", only the first page can be retrieved.
|
|
20
|
-
*
|
|
21
|
-
* @type {IESIRequestFunction}
|
|
22
|
-
* @param method - The HTTP method to use for the request
|
|
23
|
-
* @param endpoint - The Path of the ESI endpoint to send the request to
|
|
24
|
-
* @param pathParams - An object of parameters to include in the request
|
|
25
|
-
* @param options - An object of options to include in the request
|
|
26
|
-
* @returns A Promise object containing the response data
|
|
27
|
-
* @throws {ESIRequesError}
|
|
28
|
-
*/
|
|
29
|
-
export declare const request: IESIRequestFunction<util.ESIRequestOptions>;
|
|
1
|
+
export {};
|
package/minimal-rq.mjs
CHANGED
|
@@ -9,74 +9,28 @@
|
|
|
9
9
|
// - - - - - - - - - - - - - - - - - - - -
|
|
10
10
|
// imports
|
|
11
11
|
// - - - - - - - - - - - - - - - - - - - -
|
|
12
|
-
import * as util from "./rq-util.mjs";
|
|
12
|
+
import * as util from "./lib/rq-util.mjs";
|
|
13
|
+
import { request } from "./lib/request-api.mjs";
|
|
13
14
|
// - - - - - - - - - - - - - - - - - - - -
|
|
14
15
|
// constants, types
|
|
15
16
|
// - - - - - - - - - - - - - - - - - - - -
|
|
16
17
|
// shorthands
|
|
17
18
|
const log = console.log;
|
|
18
|
-
const DEBUG = util.isDebug();
|
|
19
19
|
/**
|
|
20
|
-
* @typedef {import("./v2").TESIResponseOKMap} TESIResponseOKMap
|
|
21
|
-
* @typedef {import("./rq-util.mjs").ESIRequestOptions} ESIRequestOptions
|
|
22
20
|
* @typedef {import("./v2").IESIRequestFunction<util.ESIRequestOptions>} IESIRequestFunction
|
|
23
21
|
* @typedef {import("./v2").TESIRequestFunctionMethods<util.ESIRequestOptions>} TESIRequestFunctionMethods
|
|
24
22
|
*/
|
|
25
23
|
// - - - - - - - - - - - - - - - - - - - -
|
|
26
24
|
// main functions
|
|
27
25
|
// - - - - - - - - - - - - - - - - - - - -
|
|
28
|
-
/** #### Sample of `TESIRequestFunctionSignature`
|
|
29
|
-
*
|
|
30
|
-
* + This is a minimal implementation using `TESIRequestFunctionSignature`.
|
|
31
|
-
* If the response contains "page", only the first page can be retrieved.
|
|
32
|
-
*
|
|
33
|
-
* @type {IESIRequestFunction}
|
|
34
|
-
* @param method - The HTTP method to use for the request
|
|
35
|
-
* @param endpoint - The Path of the ESI endpoint to send the request to
|
|
36
|
-
* @param pathParams - An object of parameters to include in the request
|
|
37
|
-
* @param options - An object of options to include in the request
|
|
38
|
-
* @returns A Promise object containing the response data
|
|
39
|
-
* @throws {ESIRequesError}
|
|
40
|
-
*/
|
|
41
|
-
// @ts-expect-error
|
|
42
|
-
export const request = (method, endpoint, pathParams, opt) => {
|
|
43
|
-
if (typeof pathParams === "number") {
|
|
44
|
-
// @ts-expect-error
|
|
45
|
-
pathParams = [pathParams];
|
|
46
|
-
}
|
|
47
|
-
if (Array.isArray(pathParams)) {
|
|
48
|
-
// @ts-expect-error actualy endp is string
|
|
49
|
-
endpoint = util.replaceCbt(endpoint, pathParams);
|
|
50
|
-
}
|
|
51
|
-
// When only options are provided
|
|
52
|
-
const actualOpt = /** @type {NonNullable<typeof opt>} */ (opt || pathParams || {});
|
|
53
|
-
const { rqopt, qss } = util.initOptions(method, actualOpt);
|
|
54
|
-
// @ts-expect-error actualy endp is string
|
|
55
|
-
const endpointUrl = util.curl(endpoint);
|
|
56
|
-
const up = new URLSearchParams(qss);
|
|
57
|
-
const url = `${endpointUrl}${up.size ? `?${up}` : ""}`;
|
|
58
|
-
DEBUG && log(url);
|
|
59
|
-
return fetch(url, rqopt).then(res => res.json()).catch(reason => {
|
|
60
|
-
throw new util.ESIRequesError(reason.message ? reason.message : reason);
|
|
61
|
-
});
|
|
62
|
-
};
|
|
63
|
-
//
|
|
64
|
-
// implements rest methods of `request` (IESIRequestFunction)
|
|
65
|
-
//
|
|
66
|
-
/** @type {TESIEntryMethod[]} */ (["get", "post", "put", "delete"]).forEach((method) => {
|
|
67
|
-
request[method] = /** @type {TESIRequestFunctionEachMethod<typeof method>} */ (function (endpoint, params, opt) {
|
|
68
|
-
return this(method, endpoint, params, opt);
|
|
69
|
-
});
|
|
70
|
-
});
|
|
71
26
|
//
|
|
72
27
|
// Delegates implementation to `request` (TESIRequestFunctionMethods)
|
|
73
28
|
//
|
|
74
29
|
const esiMethods = /** @type {TESIRequestFunctionMethods} */ ({});
|
|
75
|
-
["get", "post", "put", "delete"].forEach((method) => {
|
|
76
|
-
esiMethods[method] = function (endpoint, params, opt) {
|
|
77
|
-
// @ts-ignore
|
|
30
|
+
/** @type {TESIEntryMethod[]} */ (["get", "post", "put", "delete"]).forEach((method) => {
|
|
31
|
+
esiMethods[method] = /** @type {TESIRequestFunctionEachMethod<typeof method>} */ (function (endpoint, params, opt) {
|
|
78
32
|
return request(method, endpoint, params, opt);
|
|
79
|
-
};
|
|
33
|
+
});
|
|
80
34
|
});
|
|
81
35
|
// It should complete correctly.
|
|
82
36
|
/**
|
|
@@ -126,7 +80,9 @@ async function getEVEStatus(fn) {
|
|
|
126
80
|
}
|
|
127
81
|
// type following and run
|
|
128
82
|
// node minimal-rq.mjs -debug
|
|
129
|
-
|
|
83
|
+
if (!util.is("x")) {
|
|
84
|
+
getEVEStatus(request).then(eveStatus => log(eveStatus));
|
|
85
|
+
}
|
|
130
86
|
// {
|
|
131
87
|
// "players": 16503,
|
|
132
88
|
// "server_version": "2794925",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eve-esi-types",
|
|
3
|
-
"version": "2.2
|
|
3
|
+
"version": "2.3.2",
|
|
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": {
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
},
|
|
14
14
|
"files": [
|
|
15
15
|
"v2",
|
|
16
|
+
"lib",
|
|
16
17
|
"*.d.mts",
|
|
17
18
|
"*.mjs",
|
|
18
19
|
"LICENSE",
|
|
@@ -36,6 +37,7 @@
|
|
|
36
37
|
},
|
|
37
38
|
"homepage": "https://github.com/jeffy-g/eve-esi-types#readme",
|
|
38
39
|
"devDependencies": {
|
|
39
|
-
"colors.ts": "^1.0.20"
|
|
40
|
+
"colors.ts": "^1.0.20",
|
|
41
|
+
"typescript": "latest"
|
|
40
42
|
}
|
|
41
43
|
}
|
package/tagged-rq.d.mts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/tagged-rq.mjs
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
3
|
+
// Copyright (C) 2025 jeffy-g <hirotom1107@gmail.com>
|
|
4
|
+
// Released under the MIT license
|
|
5
|
+
// https://opensource.org/licenses/mit-license.php
|
|
6
|
+
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* @file tagged-rq.mts
|
|
10
|
+
* @command node tagged-rq.mjs -x
|
|
11
|
+
*/
|
|
12
|
+
import { esi as esiRq } from "./lib/tagged-request-api.mjs";
|
|
13
|
+
// console.log(esiRq);
|
|
14
|
+
// Furthermore, the endpoint selected is narrowed down by "tags" and "method".
|
|
15
|
+
esiRq.character.get("/characters/{character_id}/", 2112625428).then(console.log);
|
|
16
|
+
esiRq.universe.get("/universe/structures/", { query: { filter: "market" } }).then(console.log);
|
|
17
|
+
esiRq.universe.post("/universe/ids/", {
|
|
18
|
+
body: ["the forge", "plex"]
|
|
19
|
+
}).then(console.log);
|
|
20
|
+
esiRq.fittings.delete("/characters/{character_id}/fittings/{fitting_id}/", [1234, 56789]);
|
|
21
|
+
esiRq.assets.get("/characters/{character_id}/assets/", 1234, {
|
|
22
|
+
auth: true
|
|
23
|
+
}).then(console.log).catch(console.log);
|
package/tsconfig.json
CHANGED
|
@@ -8,7 +8,6 @@
|
|
|
8
8
|
"outDir": ".",
|
|
9
9
|
"target": "esnext",
|
|
10
10
|
"module": "esnext",
|
|
11
|
-
// "declaration": true,
|
|
12
11
|
"diagnostics": true,
|
|
13
12
|
"newLine": "LF",
|
|
14
13
|
"strict": true,
|
|
@@ -18,7 +17,9 @@
|
|
|
18
17
|
]
|
|
19
18
|
},
|
|
20
19
|
"include": [
|
|
21
|
-
"./scripts
|
|
20
|
+
"./scripts/**/*.mts",
|
|
21
|
+
"./scripts/**/*.d.ts",
|
|
22
|
+
"./v2/*.d.ts"
|
|
22
23
|
],
|
|
23
24
|
"exclude": [
|
|
24
25
|
"./scripts/auth-*",
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
3
|
+
// Copyright (C) 2025 jeffy-g <hirotom1107@gmail.com>
|
|
4
|
+
// Released under the MIT license
|
|
5
|
+
// https://opensource.org/licenses/mit-license.php
|
|
6
|
+
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* THIS DTS IS AUTO GENERATED, DO NOT EDIT
|
|
10
|
+
*
|
|
11
|
+
* @file eve-esi-types/v2/esi-tagged-types.d.ts
|
|
12
|
+
* @summary This file is auto-generated and defines version 2.3.2 of the EVE Online ESI response types.
|
|
13
|
+
*/
|
|
14
|
+
import { TESIResponseOKMap } from "./index.d.ts";
|
|
15
|
+
export * from "./index.d.ts";
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Converts a string to lower camel case.
|
|
19
|
+
*
|
|
20
|
+
* @template S - The string to convert.
|
|
21
|
+
* @example
|
|
22
|
+
* // returns "assets"
|
|
23
|
+
* LCamelCase<"Assets">
|
|
24
|
+
* @example
|
|
25
|
+
* // returns "factionWarfare"
|
|
26
|
+
* LCamelCase<"Faction Warfare">
|
|
27
|
+
* @date 2025/2/27
|
|
28
|
+
*/
|
|
29
|
+
export declare type LCamelCase<S extends string> = S extends `${infer P1} ${infer P2}`
|
|
30
|
+
? `${Lowercase<P1>}${Capitalize<P2>}` : Lowercase<S>;
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
declare const enum EInferSomethingBy {
|
|
34
|
+
METHOD,
|
|
35
|
+
TAGs
|
|
36
|
+
}
|
|
37
|
+
declare type InferSomethingBy<Tag, AsType extends EInferSomethingBy = EInferSomethingBy.METHOD> = {
|
|
38
|
+
[M in TESIEntryMethod]: TESIResponseOKMap[M] extends Record<`/${string}/`, { tag: infer ActualTag }>
|
|
39
|
+
? AsType extends EInferSomethingBy.TAGs
|
|
40
|
+
? ActualTag : ActualTag extends Tag
|
|
41
|
+
? M
|
|
42
|
+
: never
|
|
43
|
+
: never;
|
|
44
|
+
}[TESIEntryMethod];
|
|
45
|
+
// - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
46
|
+
// Utility Type `ESITags`
|
|
47
|
+
// - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
48
|
+
/**
|
|
49
|
+
* Maps HTTP methods to their corresponding tags.
|
|
50
|
+
* @template M - The HTTP method.
|
|
51
|
+
* @date 2025/2/28
|
|
52
|
+
*/
|
|
53
|
+
export declare type ESITags = InferSomethingBy<never, EInferSomethingBy.TAGs>
|
|
54
|
+
|
|
55
|
+
// - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
56
|
+
// Utility Type `InferMethod`
|
|
57
|
+
// - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
58
|
+
/**
|
|
59
|
+
* Infers the HTTP method based on the provided tag.
|
|
60
|
+
*
|
|
61
|
+
* @template Tag - The tag to infer the method for.
|
|
62
|
+
* @date 2025/2/28
|
|
63
|
+
*/
|
|
64
|
+
export declare type InferMethod<Tag> = InferSomethingBy<Tag>
|
|
65
|
+
// type XAssets = InferMethod<"Assets">;
|
|
66
|
+
// type XContacts = InferMethod<"Contacts">;
|
|
67
|
+
// type XPlanetary = InferMethod<"Planetary Interaction">;
|
|
68
|
+
|
|
69
|
+
// - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
70
|
+
// Utility Type `TaggedEndpointRequestFunction`
|
|
71
|
+
// - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
72
|
+
/**
|
|
73
|
+
* Creates a function type for making requests to tagged endpoints.
|
|
74
|
+
*
|
|
75
|
+
* @template M - The HTTP method.
|
|
76
|
+
* @template Tag - The tag associated with the endpoint.
|
|
77
|
+
* @template ActualOpt - The actual options for the request.
|
|
78
|
+
* @template EP - The endpoint path.
|
|
79
|
+
* @template P2 - The path parameters.
|
|
80
|
+
* @template Opt - The request options.
|
|
81
|
+
* @template R - The response type.
|
|
82
|
+
*
|
|
83
|
+
* @param endpoint - The endpoint path.
|
|
84
|
+
* @param pathParams - The path parameters.
|
|
85
|
+
* @param options - The request options.
|
|
86
|
+
* @returns A promise that resolves to the response.
|
|
87
|
+
* @date 2025/2/28
|
|
88
|
+
*/
|
|
89
|
+
export declare type TaggedEndpointRequestFunction<M extends TESIEntryMethod, Tag extends ESITags, ActualOpt = {}> = <
|
|
90
|
+
EP extends SelectEndpointByTag<Tag, M>,
|
|
91
|
+
P2 extends IfParameterizedPath<EP, Opt>,
|
|
92
|
+
Opt extends IdentifyParameters<TESIResponseOKMap[M][EP], ActualOpt>,
|
|
93
|
+
R extends InferESIResponseResult<M, EP>
|
|
94
|
+
>(endpoint: EP, pathParams?: P2, options?: Opt) => Promise<R>;
|
|
95
|
+
|
|
96
|
+
// - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
97
|
+
// Utility Type `ESITaggedEndpointRequest`
|
|
98
|
+
// - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
99
|
+
/**
|
|
100
|
+
* Maps tags to their corresponding endpoint request functions.
|
|
101
|
+
*
|
|
102
|
+
* @template Tag - The tag to map.
|
|
103
|
+
* @date 2025/2/28
|
|
104
|
+
*/
|
|
105
|
+
export declare type ESITaggedEndpointRequest<Tag extends ESITags, ActualOpt = {}> = {
|
|
106
|
+
[tag in Tag]: {
|
|
107
|
+
[method in InferMethod<Tag>]: TaggedEndpointRequestFunction<method, tag, ActualOpt>;
|
|
108
|
+
};
|
|
109
|
+
}[Tag];
|
|
110
|
+
|
|
111
|
+
// - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
112
|
+
// Utility Type `SelectEndpointByTag`
|
|
113
|
+
// - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
114
|
+
/**
|
|
115
|
+
* Selects an endpoint by tag and method.
|
|
116
|
+
*
|
|
117
|
+
* @template Tag - The tag associated with the endpoint.
|
|
118
|
+
* @template M - The HTTP method.
|
|
119
|
+
* @template EP - The endpoint path.
|
|
120
|
+
* @date 2025/2/28
|
|
121
|
+
*/
|
|
122
|
+
export declare type SelectEndpointByTag<
|
|
123
|
+
Tag extends ESITags, M extends TESIEntryMethod
|
|
124
|
+
> = {
|
|
125
|
+
[EP in keyof TESIResponseOKMap[M]]: TESIResponseOKMap[M][EP] extends { tag: infer ActualTag }
|
|
126
|
+
? ActualTag extends Tag
|
|
127
|
+
? EP : never
|
|
128
|
+
: never;
|
|
129
|
+
}[keyof TESIResponseOKMap[M]];
|
|
130
|
+
// type XAssetsEndpointGet = SelectEndpointByTag<"Assets", "get">;
|
|
131
|
+
// type XAssetsEndpointPost = SelectEndpointByTag<"Assets", "post">;
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Maps lower camel case tags to their corresponding endpoint request functions.
|
|
135
|
+
* @date 2025/2/28
|
|
136
|
+
*/
|
|
137
|
+
export declare type TaggedESIRequestMap<ActualOpt = {}> = {
|
|
138
|
+
[tag in ESITags as LCamelCase<tag>]: ESITaggedEndpointRequest<tag, ActualOpt>;
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Creates a partial map of lower camel case tags to their corresponding endpoint request functions.
|
|
143
|
+
* ```ts
|
|
144
|
+
* // implements "factionWarfare", "wallet"
|
|
145
|
+
* const esiRq: XTaggedESIRequestMapPartial<"factionWarfare" | "wallet">;
|
|
146
|
+
* ```
|
|
147
|
+
*
|
|
148
|
+
* @template Props - The properties to require in the partial map.
|
|
149
|
+
* @date 2025/2/28
|
|
150
|
+
*/
|
|
151
|
+
export declare type TaggedESIRequestMapPartial<Props extends LCamelCase<ESITags>> = RequireThese<Partial<TaggedESIRequestMap>, Props>;
|
|
152
|
+
|
|
153
|
+
export as namespace XESI;
|
package/v2/index.d.ts
CHANGED
|
@@ -6,19 +6,16 @@
|
|
|
6
6
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
7
7
|
*/
|
|
8
8
|
/**
|
|
9
|
-
* THIS
|
|
9
|
+
* THIS DTS IS AUTO GENERATED, DO NOT EDIT
|
|
10
10
|
*
|
|
11
11
|
* @file eve-esi-types/v2/index.d.ts
|
|
12
|
-
* @summary This file is auto-generated and defines version 2.2
|
|
12
|
+
* @summary This file is auto-generated and defines version 2.3.2 of the EVE Online ESI response types.
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
15
|
import type { TESIResponseOKMap } from "./response-map.d.ts";
|
|
16
16
|
export type { TESIResponseOKMap } from "./response-map.d.ts";
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
* mark a specific property as `required`
|
|
20
|
-
*/
|
|
21
|
-
type RequireThese<T, K extends keyof T> = T & Required<Pick<T, K>>;
|
|
18
|
+
import type { PickPathParameters, InferKeysLen } from "./util.d.ts";
|
|
22
19
|
|
|
23
20
|
/**
|
|
24
21
|
* Represents a function that can make ESI requests with various HTTP methods.
|
|
@@ -73,6 +70,25 @@ export type TESIRequestFunctionMethods<ActualOpt = {}> = {
|
|
|
73
70
|
|
|
74
71
|
declare global {
|
|
75
72
|
|
|
73
|
+
/**
|
|
74
|
+
* mark a specific property as `required`
|
|
75
|
+
*/
|
|
76
|
+
type RequireThese<T, K extends keyof T> = T & Required<Pick<T, K>>;
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* If `EP` (endpoint) is a parameterized path, determines the required number of replacements.
|
|
80
|
+
*
|
|
81
|
+
* @template EP The string representing the endpoint path.
|
|
82
|
+
* @template Opt The type to return if `EP` is not parameterized.
|
|
83
|
+
* @returns {number | [number, number] | Opt}
|
|
84
|
+
* Returns `number` if there is one parameter, `[number, number]` if there are two parameters, otherwise `Opt`.
|
|
85
|
+
*/
|
|
86
|
+
type IfParameterizedPath<EP, Opt> = EP extends `${string}/{${string}}${string}`
|
|
87
|
+
? PickPathParameters<EP> extends never
|
|
88
|
+
? Opt : InferKeysLen<PickPathParameters<EP>> extends 1
|
|
89
|
+
? number : [number, number]
|
|
90
|
+
: Opt;
|
|
91
|
+
|
|
76
92
|
/**
|
|
77
93
|
* ### ESI request function all in one signature
|
|
78
94
|
*
|
|
@@ -117,15 +133,6 @@ declare global {
|
|
|
117
133
|
R extends InferESIResponseResult<M, EP>
|
|
118
134
|
>(endpoint: EP, pathParams?: P2, options?: Opt) => Promise<R>;
|
|
119
135
|
|
|
120
|
-
// /**
|
|
121
|
-
// * is parameterized path
|
|
122
|
-
// */
|
|
123
|
-
// type IsParameterizedPath<EP, A, B> = EP extends `${string}/{${string}}/${string | ""}` ? A: B;
|
|
124
|
-
/**
|
|
125
|
-
* if parameterized path then specify number type, otherwise will be `Opt` type.
|
|
126
|
-
*/
|
|
127
|
-
type IfParameterizedPath<EP, Opt> = EP extends `${string}/{${string}}/${string | ""}` ? number | number[]: Opt;
|
|
128
|
-
|
|
129
136
|
/**
|
|
130
137
|
* Identifies the required parameters for a given entry type.
|
|
131
138
|
*
|
|
@@ -136,7 +143,7 @@ declare global {
|
|
|
136
143
|
//* ctt
|
|
137
144
|
type IdentifyParameters<
|
|
138
145
|
Entry, Opt,
|
|
139
|
-
Keys = Exclude<keyof Entry, "result">
|
|
146
|
+
Keys = Exclude<keyof Entry, "result" | "tag">
|
|
140
147
|
> = RequireThese<Opt, Keys> & Pick<Entry, Keys>;
|
|
141
148
|
/*/
|
|
142
149
|
type IdentifyParameters<
|
|
@@ -158,9 +165,8 @@ declare global {
|
|
|
158
165
|
|
|
159
166
|
/**
|
|
160
167
|
* Represents a response with no content (HTTP status 204).
|
|
161
|
-
* Although no data is returned, it indicates successful completion by returning a status of 204.
|
|
162
168
|
*/
|
|
163
|
-
type NoContentResponse = { status: 204 };
|
|
169
|
+
type NoContentResponse = { /* status: 204 */ };
|
|
164
170
|
|
|
165
171
|
/**
|
|
166
172
|
* Represents the HTTP methods supported by ESI.
|