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
package/v2/types-index.d.ts
CHANGED
|
@@ -6,10 +6,10 @@
|
|
|
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/types-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
|
import "./get_wars_ok.d.ts";
|
|
15
15
|
import "./get_status_ok.d.ts";
|
package/v2/util.d.ts
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
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 eve-esi-types/v2/util.d.ts
|
|
10
|
+
* @since 2.3.1
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* If `Path` is parameterized, return the parameter name, such as `killmail_id`.
|
|
15
|
+
*
|
|
16
|
+
* @template Path The string representing the endpoint path.
|
|
17
|
+
* @returns {string | never} The parameter name if the path is parameterized, otherwise `never`.
|
|
18
|
+
*/
|
|
19
|
+
export type PickPathParameters<Path extends string> =
|
|
20
|
+
Path extends `${string}/{${infer Param}}/${infer Rest}`
|
|
21
|
+
? Param | PickPathParameters<`/${Rest}`>
|
|
22
|
+
: never;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Convert a union type to an intersection type.
|
|
26
|
+
*
|
|
27
|
+
* @template U The union type to convert.
|
|
28
|
+
* @returns {I} The intersection type.
|
|
29
|
+
*/
|
|
30
|
+
type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Convert a union type to a tuple.
|
|
34
|
+
*
|
|
35
|
+
* @template T The union type to convert.
|
|
36
|
+
* @returns {Array} The tuple representation of the union type.
|
|
37
|
+
*/
|
|
38
|
+
type UnionToTuple<T> = UnionToIntersection<
|
|
39
|
+
T extends any ? () => T : never
|
|
40
|
+
> extends () => infer R ? [...UnionToTuple<Exclude<T, R>>, R] : [];
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* #### Build an array of elements from a flattened tuple of type "1" | "2" | "3" ...
|
|
44
|
+
*
|
|
45
|
+
* + Returns the final length of the array.
|
|
46
|
+
*
|
|
47
|
+
* @template T The union type to be converted to a tuple and measured.
|
|
48
|
+
* @returns {number} The length of the tuple.
|
|
49
|
+
* @date 2025/2/11 18:12:02
|
|
50
|
+
*/
|
|
51
|
+
export type InferKeysLen<T> = UnionToTuple<T>["length"];
|
package/v2.d.mts
CHANGED
|
@@ -6,7 +6,11 @@
|
|
|
6
6
|
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
7
7
|
*/
|
|
8
8
|
import type { TESIResponseOKMap } from "./v2";
|
|
9
|
-
import { type ESIRequestOptions } from "./rq-util.mjs";
|
|
9
|
+
import { type ESIRequestOptions } from "./lib/rq-util.mjs";
|
|
10
|
+
/**
|
|
11
|
+
* @returns Get The Current ESI request pending count.
|
|
12
|
+
*/
|
|
13
|
+
export declare const getRequestPending: () => number;
|
|
10
14
|
/**
|
|
11
15
|
* fire ESI request
|
|
12
16
|
* @template {TESIEntryMethod} M
|
package/v2.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// import type { TESIResponseOKMap } from "eve-esi-types";
|
|
2
|
-
import {
|
|
2
|
+
import { is, curl, replaceCbt, getSDEVersion, initOptions, isDebug, fireRequestsDoesNotRequireAuth, isSuccess, handleESIError, handleSuccessResponse } from "./lib/rq-util.mjs";
|
|
3
3
|
// - - - - - - - - - - - - - - - - - - - -
|
|
4
4
|
// constants, types
|
|
5
5
|
// - - - - - - - - - - - - - - - - - - - -
|
|
@@ -12,7 +12,7 @@ const isArray = Array.isArray;
|
|
|
12
12
|
let LOG = isDebug();
|
|
13
13
|
/**
|
|
14
14
|
* @typedef {import("./v2").TESIResponseOKMap} TESIResponseOKMap
|
|
15
|
-
* @typedef {import("./rq-util.mjs").ESIRequestOptions} ESIRequestOptions
|
|
15
|
+
* @typedef {import("./lib/rq-util.mjs").ESIRequestOptions} ESIRequestOptions
|
|
16
16
|
*/
|
|
17
17
|
// - - - - - - - - - - - - - - - - - - - -
|
|
18
18
|
// module vars, functions
|
|
@@ -22,6 +22,10 @@ let LOG = isDebug();
|
|
|
22
22
|
*/
|
|
23
23
|
let ax = 0;
|
|
24
24
|
const incrementAx = (minus) => minus ? ax-- : ax++;
|
|
25
|
+
/**
|
|
26
|
+
* @returns Get The Current ESI request pending count.
|
|
27
|
+
*/
|
|
28
|
+
export const getRequestPending = () => ax;
|
|
25
29
|
// - - - - - - - - - - - - - - - - - - - -
|
|
26
30
|
// main functions
|
|
27
31
|
// - - - - - - - - - - - - - - - - - - - -
|
|
@@ -64,52 +68,16 @@ export async function fire(mthd, endp, pathParams, opt) {
|
|
|
64
68
|
try {
|
|
65
69
|
const res = await fetch(url, rqopt).finally(() => ax--);
|
|
66
70
|
const { status } = res;
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
throw new ESIErrorLimitReachedError();
|
|
71
|
-
}
|
|
72
|
-
else {
|
|
73
|
-
// console.log(res);
|
|
74
|
-
throw new ESIRequesError(`${res.statusText} (status=${status})`);
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
else {
|
|
78
|
-
// DEVNOTE: - 204 No Content
|
|
79
|
-
if (status === 204) {
|
|
80
|
-
// this result is empty, decided to return status code.
|
|
81
|
-
return /** @type {R} */ ({ status });
|
|
82
|
-
}
|
|
83
|
-
/** @type {R} */
|
|
84
|
-
const data = await res.json();
|
|
85
|
-
if (actualOpt.ignoreError) {
|
|
86
|
-
// meaning `forceJson`?
|
|
87
|
-
return data;
|
|
88
|
-
}
|
|
89
|
-
// - - - - x-pages response.
|
|
90
|
-
// +undefined is NaN
|
|
91
|
-
// @ts-expect-error becouse +null is 0
|
|
92
|
-
const pc = +res.headers.get("x-pages");
|
|
93
|
-
// has remaining pages? NaN > 1 === false !isNaN(pageCount)
|
|
94
|
-
if (pc > 1) {
|
|
95
|
-
LOG && log('found "x-pages" header, pages: %d', pc);
|
|
96
|
-
const remData = await fetchP(endpointUrl, rqopt, up, pc, incrementAx);
|
|
97
|
-
// finally, decide product data.
|
|
98
|
-
if (isArray(data) && isArray(remData)) {
|
|
99
|
-
// DEVNOTE: 2019/7/23 15:01:48 - types
|
|
100
|
-
return /** @type {R} */ (data.concat(remData));
|
|
101
|
-
}
|
|
102
|
-
else {
|
|
103
|
-
// @ts-expect-error TODO: fix type
|
|
104
|
-
remData && Object.assign(data, remData);
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
return data;
|
|
71
|
+
// The parameters are different for successful and error responses.
|
|
72
|
+
if (isSuccess(status)) {
|
|
73
|
+
return handleSuccessResponse(res, endpointUrl, rqopt, up, incrementAx);
|
|
108
74
|
}
|
|
75
|
+
// else if (isError(status)) {}
|
|
76
|
+
// Actually, throw Error
|
|
77
|
+
throw await handleESIError(res, endpointUrl, actualOpt.cancelable);
|
|
109
78
|
}
|
|
110
79
|
catch (e) {
|
|
111
|
-
|
|
112
|
-
throw new ESIRequesError(`message: ${e.message}, endpoint=${endp}`);
|
|
80
|
+
throw e;
|
|
113
81
|
}
|
|
114
82
|
}
|
|
115
83
|
// It should complete correctly.
|
|
@@ -125,7 +93,9 @@ async function getEVEStatus(fn) {
|
|
|
125
93
|
// type following and run
|
|
126
94
|
// node v2.mjs
|
|
127
95
|
// or yarn test
|
|
128
|
-
|
|
96
|
+
if (!is("x")) {
|
|
97
|
+
getEVEStatus(fire).then(eveStatus => log(eveStatus));
|
|
98
|
+
}
|
|
129
99
|
// {
|
|
130
100
|
// "players": 16503,
|
|
131
101
|
// "server_version": "2794925",
|