eve-esi-types 3.0.3 → 3.0.4
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/lib/request-api.mjs +3 -3
- package/lib/rq-util.mjs +16 -15
- package/minimal-rq.mjs +7 -5
- package/package.json +1 -1
- package/v2/esi-tagged-types.d.ts +6 -3
- package/v2/index.d.ts +11 -3
- package/v2/response-map.d.ts +1 -1
- package/v2/types-index.d.ts +1 -1
package/lib/request-api.mjs
CHANGED
|
@@ -69,8 +69,8 @@ export const request2 = /** @type {IESIRequestFunction2} */ (async (method, endp
|
|
|
69
69
|
// implements rest methods of `request` (IESIRequestFunction2)
|
|
70
70
|
//
|
|
71
71
|
/** @type {TESIEntryMethod[]} */ (["get", "post", "put", "delete"]).forEach((method) => {
|
|
72
|
-
request2[method] = /** @type {TESIRequestFunctionEachMethod2<typeof method>} */ (
|
|
73
|
-
// @ts-expect-error TODO:
|
|
74
|
-
return
|
|
72
|
+
request2[method] = /** @type {TESIRequestFunctionEachMethod2<typeof method, util.ESIRequestOptions>} */ ((endpoint, opt) => {
|
|
73
|
+
// @ts-expect-error TODO: ts(2345)
|
|
74
|
+
return request2(method, endpoint, opt);
|
|
75
75
|
});
|
|
76
76
|
});
|
package/lib/rq-util.mjs
CHANGED
|
@@ -325,7 +325,8 @@ export function getLogger() {
|
|
|
325
325
|
*
|
|
326
326
|
* @type {import("./rq-util.d.mts").TFireWithoutAuth}
|
|
327
327
|
*/
|
|
328
|
-
|
|
328
|
+
// @ts-expect-error
|
|
329
|
+
const fireWithoutAuth = (fn, method, endpoint, opt) => {
|
|
329
330
|
if (typeof fn === "function") {
|
|
330
331
|
// @ts-expect-error TODO: ts(2345) The argument type does not match the type of the specified parameter
|
|
331
332
|
return fn(method, endpoint, opt);
|
|
@@ -367,10 +368,10 @@ export async function fireRequestsDoesNotRequireAuth(fn) {
|
|
|
367
368
|
await fireWithoutAuth(fn, "get", `/corporations/${affiliation[0].corporation_id}/`).then(log);
|
|
368
369
|
rlog("get:/incursions/".green);
|
|
369
370
|
await fireWithoutAuth(fn, "get", "/incursions/").then(log);
|
|
370
|
-
fireWithoutAuth(fn, "delete", `/characters/${1234}/fittings/${56789}/`, {
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
}).catch(console.log);
|
|
371
|
+
// fireWithoutAuth(fn, "delete", `/characters/${1234}/fittings/${56789}/`, {
|
|
372
|
+
// // pathParams: [1234, 56789],
|
|
373
|
+
// auth: true
|
|
374
|
+
// }).catch(console.log);
|
|
374
375
|
}
|
|
375
376
|
// - - - - - - - - - - - -
|
|
376
377
|
// Miscellaneous
|
|
@@ -405,6 +406,7 @@ export async function fireRequestsDoesNotRequireAuth(fn) {
|
|
|
405
406
|
auth: true,
|
|
406
407
|
token: "token.token.token"
|
|
407
408
|
});
|
|
409
|
+
log(`get:/characters/${ID_CCP_Zoetrope}/ship/, returns=${willFailed}`);
|
|
408
410
|
// in this case, "categories" and "search" is required
|
|
409
411
|
await fireWithoutAuth(fn, "get", "/characters/{character_id}/search/", {
|
|
410
412
|
pathParams: ID_CCP_Zoetrope,
|
|
@@ -414,16 +416,15 @@ export async function fireRequestsDoesNotRequireAuth(fn) {
|
|
|
414
416
|
},
|
|
415
417
|
auth: true
|
|
416
418
|
});
|
|
417
|
-
// TODO: want TypeScript semantics to throw an error because there is a required query parameter, but it's not possible
|
|
418
|
-
// Or rather, I don't know how to do it.
|
|
419
|
-
await fireWithoutAuth(fn, "get", "/characters/{character_id}/search/", {
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
});
|
|
426
|
-
log(willFailed);
|
|
419
|
+
// // TODO: want TypeScript semantics to throw an error because there is a required query parameter, but it's not possible
|
|
420
|
+
// // Or rather, I don't know how to do it.
|
|
421
|
+
// await fireWithoutAuth(fn, "get", "/characters/{character_id}/search/", {
|
|
422
|
+
// auth: true,
|
|
423
|
+
// pathParams: 1234,
|
|
424
|
+
// query: {
|
|
425
|
+
// categories: ["alliance"], search: "test!!"
|
|
426
|
+
// }
|
|
427
|
+
// });
|
|
427
428
|
}
|
|
428
429
|
catch (e) {
|
|
429
430
|
console.error("Failed to request -", e);
|
package/minimal-rq.mjs
CHANGED
|
@@ -27,9 +27,9 @@ const log = util.getUniversalLogger("[request-mini]: ");
|
|
|
27
27
|
// Delegates implementation to `request` (TESIRequestFunctionMethods2)
|
|
28
28
|
//
|
|
29
29
|
const esiMethods = /** @type {TESIRequestFunctionMethods2} */ ({});
|
|
30
|
-
/** @
|
|
31
|
-
esiMethods[method] = /** @type {TESIRequestFunctionEachMethod2<typeof method>} */ (
|
|
32
|
-
// @ts-expect-error
|
|
30
|
+
/** @satisfies {TESIEntryMethod[]} */ (["get", "post", "put", "delete"]).forEach((method) => {
|
|
31
|
+
esiMethods[method] = /** @type {TESIRequestFunctionEachMethod2<typeof method, util.ESIRequestOptions>} */ ((endpoint, opt) => {
|
|
32
|
+
// @ts-expect-error ts(2345)
|
|
33
33
|
return request2(method, endpoint, opt);
|
|
34
34
|
});
|
|
35
35
|
});
|
|
@@ -39,18 +39,20 @@ const esiMethods = /** @type {TESIRequestFunctionMethods2} */ ({});
|
|
|
39
39
|
*/
|
|
40
40
|
async function getEVEStatus2(fn) {
|
|
41
41
|
await util.getSDEVersion().then(sdeVersion => log(`sdeVersion: ${sdeVersion}`.blue));
|
|
42
|
+
const { clog, rlog } = util.getLogger();
|
|
43
|
+
rlog("- - - - - - - > run as IESIRequestFunction2<ESIRequestOptions>".red, fn);
|
|
42
44
|
await util.fireRequestsDoesNotRequireAuth(fn);
|
|
43
45
|
CaseIESIRequestFunctionMethods: {
|
|
46
|
+
rlog("- - - - - - - > run as TESIRequestFunctionMethods2<ESIRequestOptions>".red, esiMethods);
|
|
44
47
|
await util.fireRequestsDoesNotRequireAuth(esiMethods);
|
|
45
48
|
}
|
|
46
|
-
const { clog, rlog } = util.getLogger();
|
|
47
49
|
CaseIESIRequestFunction2: {
|
|
48
50
|
const ID_CCP_Zoetrope = 2112625428;
|
|
49
51
|
// - - - - - - - - - - - -
|
|
50
52
|
// Character
|
|
51
53
|
// - - - - - - - - - - - -
|
|
52
54
|
// Here, I borrow data from "CCP Zoetrope".
|
|
53
|
-
rlog("- - - - - - - > run as IESIRequestFunction2<ESIRequestOptions>".red);
|
|
55
|
+
rlog("- - - - - - - > run as IESIRequestFunction2::TESIRequestFunctionMethods2<ESIRequestOptions>".red, fn);
|
|
54
56
|
clog();
|
|
55
57
|
await fn.get("/characters/{character_id}/", { pathParams: ID_CCP_Zoetrope }).then(log);
|
|
56
58
|
clog('(portrait)');
|
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.0.
|
|
12
|
+
* @summary This file is auto-generated and defines version 3.0.4 of the EVE Online ESI response types.
|
|
13
13
|
*/
|
|
14
14
|
import { TESIResponseOKMap, TPathParamsNever } from "./index.d.ts";
|
|
15
15
|
export * from "./index.d.ts";
|
|
@@ -82,9 +82,12 @@ export declare type InferMethod<Tag> = InferSomethingBy<Tag>
|
|
|
82
82
|
*
|
|
83
83
|
* @param endpoint - The endpoint path.
|
|
84
84
|
* @param pathParams - The path parameters.
|
|
85
|
-
* @param options -
|
|
85
|
+
* @param options - An optional object containing additional options for the request. If the endpoint has required parameters, this parameter must be provided.
|
|
86
86
|
* @returns A promise that resolves to the response.
|
|
87
|
-
*
|
|
87
|
+
*
|
|
88
|
+
* @remarks
|
|
89
|
+
* The `...options: HasOpt extends 1 ? [Opt] : [Opt?]` parameter is defined this way to enforce that if the endpoint has required parameters,
|
|
90
|
+
* the `options` parameter must be provided. If there are no required parameters, the `options` parameter is optional.
|
|
88
91
|
*/
|
|
89
92
|
export declare type TaggedEndpointRequestFunction2<M extends TESIEntryMethod, Tag extends ESITags, ActualOpt = {}> = <
|
|
90
93
|
RealEP extends ReplacePathParams<keyof TESIResponseOKMap[M] & string> | keyof TESIResponseOKMap[M],
|
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.0.
|
|
12
|
+
* @summary This file is auto-generated and defines version 3.0.4 of the EVE Online ESI response types.
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
15
|
import type { TESIResponseOKMap } from "./response-map.d.ts";
|
|
@@ -125,9 +125,13 @@ declare global {
|
|
|
125
125
|
*
|
|
126
126
|
* @param method - The HTTP method to use for the request (e.g., "get", "post").
|
|
127
127
|
* @param endpoint - The real path of the ESI endpoint to send the request to.
|
|
128
|
-
* @param options - An optional object containing additional options for the request.
|
|
128
|
+
* @param options - An optional object containing additional options for the request. If the endpoint has required parameters, this parameter must be provided.
|
|
129
129
|
*
|
|
130
130
|
* @returns A Promise object containing the response data, with the type inferred based on the method and endpoint.
|
|
131
|
+
*
|
|
132
|
+
* @remarks
|
|
133
|
+
* The `...options: HasOpt extends 1 ? [Opt] : [Opt?]` parameter is defined this way to enforce that if the endpoint has required parameters,
|
|
134
|
+
* the `options` parameter must be provided. If there are no required parameters, the `options` parameter is optional.
|
|
131
135
|
*/
|
|
132
136
|
type TESIRequestFunctionSignature2<ActualOpt> = <
|
|
133
137
|
M extends TESIEntryMethod,
|
|
@@ -157,9 +161,13 @@ declare global {
|
|
|
157
161
|
* @template R - The response type.
|
|
158
162
|
*
|
|
159
163
|
* @param endpoint - The real path of the ESI endpoint to send the request to.
|
|
160
|
-
* @param options - An optional object containing additional options for the request.
|
|
164
|
+
* @param options - An optional object containing additional options for the request. If the endpoint has required parameters, this parameter must be provided.
|
|
161
165
|
*
|
|
162
166
|
* @returns A Promise object containing the response data, with the type inferred based on the method and endpoint.
|
|
167
|
+
*
|
|
168
|
+
* @remarks
|
|
169
|
+
* The `...options: HasOpt extends 1 ? [Opt] : [Opt?]` parameter is defined this way to enforce that if the endpoint has required parameters,
|
|
170
|
+
* the `options` parameter must be provided. If there are no required parameters, the `options` parameter is optional.
|
|
163
171
|
*/
|
|
164
172
|
type TESIRequestFunctionEachMethod2<M extends TESIEntryMethod, ActualOpt = {}> = <
|
|
165
173
|
RealEP extends ReplacePathParams<keyof TESIResponseOKMap[M] & string> | keyof TESIResponseOKMap[M],
|
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.0.
|
|
12
|
+
* @summary This file is auto-generated and defines version 3.0.4 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.0.
|
|
12
|
+
* @summary This file is auto-generated and defines version 3.0.4 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";
|