eve-esi-types 3.0.2 → 3.0.3

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/rq-util.d.mts CHANGED
@@ -181,6 +181,9 @@ export declare function getLogger(): {
181
181
  clog: (...args: any[]) => void;
182
182
  rlog: (...args: any[]) => void;
183
183
  };
184
+ export type TFireWithoutAuth = {
185
+ fireWithoutAuth<M extends TESIEntryMethod, RealEP extends ReplacePathParams<keyof TESIResponseOKMap[M] & string> | keyof TESIResponseOKMap[M], EP extends InferEndpointOrigin<RealEP, keyof TESIResponseOKMap[M]> extends never ? RealEP : InferEndpointOrigin<RealEP, keyof TESIResponseOKMap[M]>, PathParams extends RealEP extends EP ? IfNeedPathParams<EP> : TPathParamsNever, Opt extends IdentifyParameters<TESIResponseOKMap[M][Extract<EP, keyof TESIResponseOKMap[M]>], ESIRequestOptions & PathParams>, R extends InferESIResponseResult<M, Extract<EP, keyof TESIResponseOKMap[M]>>, HasOpt = HasRequireParams<TESIResponseOKMap[M][Extract<EP, keyof TESIResponseOKMap[M]>]> extends never ? 0 : 1>(fn: TESIRequestFunctionSignature2<ESIRequestOptions> | TESIRequestFunctionMethods2<ESIRequestOptions>, method: M, endpoint: RealEP, ...opt: HasOpt extends 1 ? [Opt] : [Opt?]): Promise<R>;
186
+ }["fireWithoutAuth"];
184
187
  /**
185
188
  * Need typescript v5.5 later
186
189
  * @import * as ESI from "../v2";
@@ -189,12 +192,6 @@ export declare function getLogger(): {
189
192
  * @typedef {ESI.IESIRequestFunction2<ESIRequestOptions>} IESIRequestFunction2
190
193
  * @typedef {ESI.TESIRequestFunctionMethods2<ESIRequestOptions>} TESIRequestFunctionMethods2
191
194
  */
192
- /**
193
- * #### Fire a request that does not require authentication.
194
- *
195
- * @type {import("./rq-util.d.mts").fireWithoutAuth}
196
- */
197
- export declare function fireWithoutAuth<M extends TESIEntryMethod, RealEP extends ReplacePathParams<keyof TESIResponseOKMap[M] & string> | keyof TESIResponseOKMap[M], EP extends InferEndpointOrigin<RealEP, keyof TESIResponseOKMap[M]> extends never ? RealEP : InferEndpointOrigin<RealEP, keyof TESIResponseOKMap[M]>, PathParams extends RealEP extends EP ? IfNeedPathParams<EP> : TPathParamsNever, Opt extends IdentifyParameters<TESIResponseOKMap[M][Extract<EP, keyof TESIResponseOKMap[M]>], ESIRequestOptions & PathParams>, R extends InferESIResponseResult<M, Extract<EP, keyof TESIResponseOKMap[M]>>>(fn: TESIRequestFunctionSignature2<ESIRequestOptions> | TESIRequestFunctionMethods2<ESIRequestOptions>, method: M, endpoint: RealEP, opt?: Opt): Promise<R>;
198
195
  /**
199
196
  * #### Fire a request that does not require authentication.
200
197
  *
package/lib/rq-util.mjs CHANGED
@@ -320,29 +320,27 @@ export function getLogger() {
320
320
  const rlog = consoleUtil.getLogger("- - -> Run ESI request".cyan);
321
321
  return { clog, rlog };
322
322
  }
323
- /**
324
- * Need typescript v5.5 later
325
- * @import * as ESI from "../v2";
326
- * @typedef {ESI.TESIResponseOKMap} TESIResponseOKMap
327
- * @typedef {ESI.TPathParamsNever} TPathParamsNever
328
- * @typedef {ESI.IESIRequestFunction2<ESIRequestOptions>} IESIRequestFunction2
329
- * @typedef {ESI.TESIRequestFunctionMethods2<ESIRequestOptions>} TESIRequestFunctionMethods2
330
- */
331
- // type ESIEndpointBrand<EP> = EP & { __esi: "x"; };
332
- // type EPPost = ESIEndpointBrand<keyof TESIResponseOKMap["post"]>;
333
323
  /**
334
324
  * #### Fire a request that does not require authentication.
335
325
  *
336
- * @type {import("./rq-util.d.mts").fireWithoutAuth}
326
+ * @type {import("./rq-util.d.mts").TFireWithoutAuth}
337
327
  */
338
- export function fireWithoutAuth(fn, method, endpoint, opt) {
328
+ const fireWithoutAuth = (fn, method, endpoint, ...opt) => {
339
329
  if (typeof fn === "function") {
340
330
  // @ts-expect-error TODO: ts(2345) The argument type does not match the type of the specified parameter
341
331
  return fn(method, endpoint, opt);
342
332
  }
343
333
  // @ts-expect-error TODO: ts(2345) The argument type does not match the type of the specified parameter
344
334
  return fn[method](endpoint, opt);
345
- }
335
+ };
336
+ /**
337
+ * Need typescript v5.5 later
338
+ * @import * as ESI from "../v2";
339
+ * @typedef {ESI.TESIResponseOKMap} TESIResponseOKMap
340
+ * @typedef {ESI.TPathParamsNever} TPathParamsNever
341
+ * @typedef {ESI.IESIRequestFunction2<ESIRequestOptions>} IESIRequestFunction2
342
+ * @typedef {ESI.TESIRequestFunctionMethods2<ESIRequestOptions>} TESIRequestFunctionMethods2
343
+ */
346
344
  /**
347
345
  * #### Fire a request that does not require authentication.
348
346
  *
@@ -418,7 +416,13 @@ export async function fireRequestsDoesNotRequireAuth(fn) {
418
416
  });
419
417
  // TODO: want TypeScript semantics to throw an error because there is a required query parameter, but it's not possible
420
418
  // Or rather, I don't know how to do it.
421
- await fireWithoutAuth(fn, "get", "/characters/{character_id}/search/");
419
+ await fireWithoutAuth(fn, "get", "/characters/{character_id}/search/", {
420
+ auth: true,
421
+ pathParams: 1234,
422
+ query: {
423
+ categories: ["alliance"], search: "test!!"
424
+ }
425
+ });
422
426
  log(willFailed);
423
427
  }
424
428
  catch (e) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eve-esi-types",
3
- "version": "3.0.2",
3
+ "version": "3.0.3",
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": {
package/tagged-rq.mjs CHANGED
@@ -27,7 +27,7 @@ esi.universe.post("/universe/names/", {
27
27
  body: [44992, 434243723, 109299958, 10000002]
28
28
  }).then(console.log);
29
29
  esi.universe.get("/universe/structures/", { query: { filter: "market" } }).then(console.log);
30
- // node tagged-rq.mjs -x -withError
30
+ // node tagged-rq.mjs -x -debug -withError
31
31
  if (util.is("withError")) {
32
32
  esi.assets.get("/characters/2112625428/assets/", {
33
33
  auth: true
@@ -47,5 +47,7 @@ if (util.is("withError")) {
47
47
  pathParams: [1234, 56789],
48
48
  auth: true
49
49
  });
50
- esi.character.post("/characters/affiliation/").catch(console.log);
50
+ esi.character.post("/characters/affiliation/", {
51
+ body: [12345]
52
+ }).catch(console.log);
51
53
  }
@@ -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.2 of the EVE Online ESI response types.
12
+ * @summary This file is auto-generated and defines version 3.0.3 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";
@@ -92,9 +92,10 @@ export declare type TaggedEndpointRequestFunction2<M extends TESIEntryMethod, Ta
92
92
  PathParams extends RealEP extends EP ? IfNeedPathParams<EP>: TPathParamsNever,
93
93
  Opt extends IdentifyParameters<TESIResponseOKMap[M][EP], ActualOpt & PathParams>,
94
94
  R extends InferESIResponseResult<M, EP>,
95
+ HasOpt = HasRequireParams<TESIResponseOKMap[M][EP]> extends never ? 0 : 1
95
96
  // RealEPX = ReplacePathParamsX<RealEPX>,
96
97
  // EPX = ReplacePathParams<EP>,
97
- >(endpoint: RealEP, options?: Opt) => Promise<R>;
98
+ >(endpoint: RealEP, ...options: HasOpt extends 1 ? [Opt] : [Opt?]) => Promise<R>;
98
99
 
99
100
 
100
101
  // - - - - - - - - - - - - - - - - - - - - - - - - - -
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.2 of the EVE Online ESI response types.
12
+ * @summary This file is auto-generated and defines version 3.0.3 of the EVE Online ESI response types.
13
13
  */
14
14
 
15
15
  import type { TESIResponseOKMap } from "./response-map.d.ts";
@@ -138,8 +138,9 @@ declare global {
138
138
  // If RealEP points to an endpoint origin (not a replaced endpoint), the path parameter is required
139
139
  PathParams extends RealEP extends EP ? IfNeedPathParams<EP>: TPathParamsNever,
140
140
  Opt extends IdentifyParameters<TESIResponseOKMap[M][EP], ActualOpt & PathParams>,
141
- R extends InferESIResponseResult<M, EP>
142
- >(method: M, endpoint: RealEP, options?: Opt) => Promise<R>;
141
+ R extends InferESIResponseResult<M, EP>,
142
+ HasOpt = HasRequireParams<TESIResponseOKMap[M][EP]> extends never ? 0 : 1
143
+ >(method: M, endpoint: RealEP, ...options: HasOpt extends 1 ? [Opt] : [Opt?]) => Promise<R>;
143
144
 
144
145
  /**
145
146
  * Represents a function that can make ESI requests for a specific HTTP method.
@@ -165,8 +166,9 @@ declare global {
165
166
  EP extends InferEndpointOrigin<RealEP, keyof TESIResponseOKMap[M]> extends never ? RealEP: InferEndpointOrigin<RealEP, keyof TESIResponseOKMap[M]>,
166
167
  PathParams extends RealEP extends EP ? IfNeedPathParams<EP>: TPathParamsNever,
167
168
  Opt extends IdentifyParameters<TESIResponseOKMap[M][EP], ActualOpt & PathParams>,
168
- R extends InferESIResponseResult<M, EP>
169
- >(endpoint: RealEP, options?: Opt) => Promise<R>;
169
+ R extends InferESIResponseResult<M, EP>,
170
+ HasOpt = HasRequireParams<TESIResponseOKMap[M][EP]> extends never ? 0 : 1
171
+ >(endpoint: RealEP, ...options: HasOpt extends 1 ? [Opt] : [Opt?]) => Promise<R>;
170
172
 
171
173
  /**
172
174
  * Replaces path parameters in a string with numbers.
@@ -222,6 +224,22 @@ declare global {
222
224
  // }[keyof TESIResponseOKMap[Method]]
223
225
  // }[TESIEntryMethod];
224
226
 
227
+ /**
228
+ * Determines if the given entry has required parameters.
229
+ *
230
+ * This type checks if an entry has any required parameters by excluding the keys "result", "tag", and "cachedSeconds".
231
+ * If any keys remain after this exclusion, it means the entry has required parameters.
232
+ *
233
+ * @template Entry - The entry type to check for required parameters.
234
+ *
235
+ * @example
236
+ * ```ts
237
+ * type ExampleEntry = { result: string, tag: string, cachedSeconds: number, auth: string };
238
+ * type HasRequired = HasRequireParams<ExampleEntry>; // "auth"
239
+ * ```
240
+ */
241
+ type HasRequireParams<Entry> = Exclude<keyof Entry, "result" | "tag" | "cachedSeconds">;
242
+
225
243
  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
226
244
  // Version 2 types
227
245
  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@@ -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.2 of the EVE Online ESI response types.
12
+ * @summary This file is auto-generated and defines version 3.0.3 of the EVE Online ESI response types.
13
13
  */
14
14
  import "./types-index.d.ts";
15
15
 
@@ -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.2 of the EVE Online ESI response types.
12
+ * @summary This file is auto-generated and defines version 3.0.3 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.d.mts CHANGED
@@ -13,7 +13,6 @@ export declare const getRequestPending: () => number;
13
13
  /**
14
14
  * fire ESI request ESIRequestOptions
15
15
  *
16
- * @type {TESIRequestFunctionSignature2<ESIRequestOptions>}
17
16
  * @throws {ESIRequestError}
18
17
  * @async
19
18
  */
package/v2.mjs CHANGED
@@ -35,7 +35,7 @@ let LOG = isDebug();
35
35
  * Get the number of currently executing ESI requests
36
36
  */
37
37
  let ax = 0;
38
- /** @type {(m?: Truthy) => number} */
38
+ /** @type {function(Truthy=): number} */
39
39
  const incrementAx = (minus) => minus ? ax-- : ax++;
40
40
  /**
41
41
  * @returns Get The Current ESI request pending count.
@@ -47,11 +47,10 @@ export const getRequestPending = () => ax;
47
47
  /**
48
48
  * fire ESI request ESIRequestOptions
49
49
  *
50
- * @type {TESIRequestFunctionSignature2<ESIRequestOptions>}
51
50
  * @throws {ESIRequestError}
52
51
  * @async
53
52
  */
54
- export const fire = async (mthd, endp, opt) => {
53
+ export const fire = /** @type {TESIRequestFunctionSignature2<ESIRequestOptions>} */ (async (mthd, endp, opt) => {
55
54
  /** @type {number[]=} */
56
55
  let pathParams;
57
56
  if (opt && typeof opt.pathParams !== "undefined") {
@@ -81,7 +80,7 @@ export const fire = async (mthd, endp, opt) => {
81
80
  catch (e) {
82
81
  throw e;
83
82
  }
84
- };
83
+ });
85
84
  // It should complete correctly.
86
85
  /**
87
86
  * @param {TESIRequestFunctionSignature2<ESIRequestOptions>} fn