@coingecko/coingecko-typescript 1.4.0 → 1.6.0
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/CHANGELOG.md +34 -0
- package/README.md +3 -4
- package/client.d.mts +5 -5
- package/client.d.mts.map +1 -1
- package/client.d.ts +5 -5
- package/client.d.ts.map +1 -1
- package/client.js +25 -22
- package/client.js.map +1 -1
- package/client.mjs +14 -11
- package/client.mjs.map +1 -1
- package/core/resource.d.mts +1 -1
- package/core/resource.d.mts.map +1 -1
- package/core/resource.d.ts +1 -1
- package/core/resource.d.ts.map +1 -1
- package/core/resource.js.map +1 -1
- package/core/resource.mjs.map +1 -1
- package/internal/headers.d.mts.map +1 -1
- package/internal/headers.d.ts.map +1 -1
- package/internal/headers.js +4 -4
- package/internal/headers.js.map +1 -1
- package/internal/headers.mjs +4 -4
- package/internal/headers.mjs.map +1 -1
- package/internal/request-options.d.mts +1 -0
- package/internal/request-options.d.mts.map +1 -1
- package/internal/request-options.d.ts +1 -0
- package/internal/request-options.d.ts.map +1 -1
- package/internal/request-options.js.map +1 -1
- package/internal/request-options.mjs.map +1 -1
- package/internal/uploads.js +1 -1
- package/internal/uploads.js.map +1 -1
- package/internal/uploads.mjs +1 -1
- package/internal/uploads.mjs.map +1 -1
- package/internal/utils/log.js +1 -1
- package/internal/utils/log.js.map +1 -1
- package/internal/utils/log.mjs +1 -1
- package/internal/utils/log.mjs.map +1 -1
- package/internal/utils/path.d.mts.map +1 -1
- package/internal/utils/path.d.ts.map +1 -1
- package/internal/utils/path.js.map +1 -1
- package/internal/utils/path.mjs +1 -1
- package/internal/utils/path.mjs.map +1 -1
- package/internal/utils/values.d.mts +2 -0
- package/internal/utils/values.d.mts.map +1 -1
- package/internal/utils/values.d.ts +2 -0
- package/internal/utils/values.d.ts.map +1 -1
- package/internal/utils/values.js +4 -1
- package/internal/utils/values.js.map +1 -1
- package/internal/utils/values.mjs +2 -0
- package/internal/utils/values.mjs.map +1 -1
- package/package.json +1 -1
- package/src/client.ts +28 -11
- package/src/core/resource.ts +1 -1
- package/src/internal/headers.ts +5 -5
- package/src/internal/request-options.ts +1 -0
- package/src/internal/uploads.ts +1 -1
- package/src/internal/utils/log.ts +1 -1
- package/src/internal/utils/path.ts +1 -1
- package/src/internal/utils/values.ts +3 -0
- package/src/version.ts +1 -1
- package/version.d.mts +1 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
- package/version.mjs +1 -1
package/src/client.ts
CHANGED
|
@@ -5,7 +5,6 @@ import type { HTTPMethod, PromiseOrValue, MergedRequestInit, FinalizedRequestIni
|
|
|
5
5
|
import { uuid4 } from './internal/utils/uuid';
|
|
6
6
|
import { validatePositiveInteger, isAbsoluteURL, safeJSON } from './internal/utils/values';
|
|
7
7
|
import { sleep } from './internal/utils/sleep';
|
|
8
|
-
import { type Logger, type LogLevel, parseLogLevel } from './internal/utils/log';
|
|
9
8
|
export type { Logger, LogLevel } from './internal/utils/log';
|
|
10
9
|
import { castToError, isAbortError } from './internal/errors';
|
|
11
10
|
import type { APIResponseProps } from './internal/parse';
|
|
@@ -17,9 +16,6 @@ import * as Errors from './core/error';
|
|
|
17
16
|
import * as Uploads from './core/uploads';
|
|
18
17
|
import * as API from './resources/index';
|
|
19
18
|
import { APIPromise } from './core/api-promise';
|
|
20
|
-
import { type Fetch } from './internal/builtin-types';
|
|
21
|
-
import { HeadersLike, NullableHeaders, buildHeaders } from './internal/headers';
|
|
22
|
-
import { FinalRequestOptions, RequestOptions } from './internal/request-options';
|
|
23
19
|
import {
|
|
24
20
|
AssetPlatformGetParams,
|
|
25
21
|
AssetPlatformGetResponse,
|
|
@@ -29,9 +25,6 @@ import { ExchangeRateGetResponse, ExchangeRates } from './resources/exchange-rat
|
|
|
29
25
|
import { Key, KeyGetResponse } from './resources/key';
|
|
30
26
|
import { Ping, PingGetResponse } from './resources/ping';
|
|
31
27
|
import { TokenListGetAllJsonResponse, TokenLists } from './resources/token-lists';
|
|
32
|
-
import { readEnv } from './internal/utils/env';
|
|
33
|
-
import { formatRequestDetails, loggerFor } from './internal/utils/log';
|
|
34
|
-
import { isEmptyObj } from './internal/utils/values';
|
|
35
28
|
import { CoinGetIDParams, CoinGetIDResponse, Coins } from './resources/coins/coins';
|
|
36
29
|
import { Companies } from './resources/companies/companies';
|
|
37
30
|
import { DerivativeGetResponse, Derivatives } from './resources/derivatives/derivatives';
|
|
@@ -56,6 +49,18 @@ import {
|
|
|
56
49
|
import { Onchain } from './resources/onchain/onchain';
|
|
57
50
|
import { Search, SearchGetParams, SearchGetResponse } from './resources/search/search';
|
|
58
51
|
import { Simple } from './resources/simple/simple';
|
|
52
|
+
import { type Fetch } from './internal/builtin-types';
|
|
53
|
+
import { HeadersLike, NullableHeaders, buildHeaders } from './internal/headers';
|
|
54
|
+
import { FinalRequestOptions, RequestOptions } from './internal/request-options';
|
|
55
|
+
import { readEnv } from './internal/utils/env';
|
|
56
|
+
import {
|
|
57
|
+
type LogLevel,
|
|
58
|
+
type Logger,
|
|
59
|
+
formatRequestDetails,
|
|
60
|
+
loggerFor,
|
|
61
|
+
parseLogLevel,
|
|
62
|
+
} from './internal/utils/log';
|
|
63
|
+
import { isEmptyObj } from './internal/utils/values';
|
|
59
64
|
|
|
60
65
|
const environments = {
|
|
61
66
|
pro: 'https://pro-api.coingecko.com/api/v3',
|
|
@@ -243,6 +248,13 @@ export class Coingecko {
|
|
|
243
248
|
});
|
|
244
249
|
}
|
|
245
250
|
|
|
251
|
+
/**
|
|
252
|
+
* Check whether the base URL is set to its default.
|
|
253
|
+
*/
|
|
254
|
+
#baseURLOverridden(): boolean {
|
|
255
|
+
return this.baseURL !== environments[this._options.environment || 'pro'];
|
|
256
|
+
}
|
|
257
|
+
|
|
246
258
|
protected defaultQuery(): Record<string, string | undefined> | undefined {
|
|
247
259
|
return this._options.defaultQuery;
|
|
248
260
|
}
|
|
@@ -322,11 +334,16 @@ export class Coingecko {
|
|
|
322
334
|
return Errors.APIError.generate(status, error, message, headers);
|
|
323
335
|
}
|
|
324
336
|
|
|
325
|
-
buildURL(
|
|
337
|
+
buildURL(
|
|
338
|
+
path: string,
|
|
339
|
+
query: Record<string, unknown> | null | undefined,
|
|
340
|
+
defaultBaseURL?: string | undefined,
|
|
341
|
+
): string {
|
|
342
|
+
const baseURL = (!this.#baseURLOverridden() && defaultBaseURL) || this.baseURL;
|
|
326
343
|
const url =
|
|
327
344
|
isAbsoluteURL(path) ?
|
|
328
345
|
new URL(path)
|
|
329
|
-
: new URL(
|
|
346
|
+
: new URL(baseURL + (baseURL.endsWith('/') && path.startsWith('/') ? path.slice(1) : path));
|
|
330
347
|
|
|
331
348
|
const defaultQuery = this.defaultQuery();
|
|
332
349
|
if (!isEmptyObj(defaultQuery)) {
|
|
@@ -667,9 +684,9 @@ export class Coingecko {
|
|
|
667
684
|
{ retryCount = 0 }: { retryCount?: number } = {},
|
|
668
685
|
): { req: FinalizedRequestInit; url: string; timeout: number } {
|
|
669
686
|
const options = { ...inputOptions };
|
|
670
|
-
const { method, path, query } = options;
|
|
687
|
+
const { method, path, query, defaultBaseURL } = options;
|
|
671
688
|
|
|
672
|
-
const url = this.buildURL(path!, query as Record<string, unknown
|
|
689
|
+
const url = this.buildURL(path!, query as Record<string, unknown>, defaultBaseURL);
|
|
673
690
|
if ('timeout' in options) validatePositiveInteger('timeout', options.timeout);
|
|
674
691
|
options.timeout = options.timeout ?? this.timeout;
|
|
675
692
|
const { bodyHeaders, body } = this.buildBody({ options });
|
package/src/core/resource.ts
CHANGED
package/src/internal/headers.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
2
|
|
|
3
|
+
import { isReadonlyArray } from './utils/values';
|
|
4
|
+
|
|
3
5
|
type HeaderValue = string | undefined | null;
|
|
4
6
|
export type HeadersLike =
|
|
5
7
|
| Headers
|
|
@@ -9,7 +11,7 @@ export type HeadersLike =
|
|
|
9
11
|
| null
|
|
10
12
|
| NullableHeaders;
|
|
11
13
|
|
|
12
|
-
const brand_privateNullableHeaders = Symbol('brand.privateNullableHeaders');
|
|
14
|
+
const brand_privateNullableHeaders = /* @__PURE__ */ Symbol('brand.privateNullableHeaders');
|
|
13
15
|
|
|
14
16
|
/**
|
|
15
17
|
* @internal
|
|
@@ -25,8 +27,6 @@ export type NullableHeaders = {
|
|
|
25
27
|
nulls: Set<string>;
|
|
26
28
|
};
|
|
27
29
|
|
|
28
|
-
const isArray = Array.isArray as (val: unknown) => val is readonly unknown[];
|
|
29
|
-
|
|
30
30
|
function* iterateHeaders(headers: HeadersLike): IterableIterator<readonly [string, string | null]> {
|
|
31
31
|
if (!headers) return;
|
|
32
32
|
|
|
@@ -43,7 +43,7 @@ function* iterateHeaders(headers: HeadersLike): IterableIterator<readonly [strin
|
|
|
43
43
|
let iter: Iterable<readonly (HeaderValue | readonly HeaderValue[])[]>;
|
|
44
44
|
if (headers instanceof Headers) {
|
|
45
45
|
iter = headers.entries();
|
|
46
|
-
} else if (
|
|
46
|
+
} else if (isReadonlyArray(headers)) {
|
|
47
47
|
iter = headers;
|
|
48
48
|
} else {
|
|
49
49
|
shouldClear = true;
|
|
@@ -52,7 +52,7 @@ function* iterateHeaders(headers: HeadersLike): IterableIterator<readonly [strin
|
|
|
52
52
|
for (let row of iter) {
|
|
53
53
|
const name = row[0];
|
|
54
54
|
if (typeof name !== 'string') throw new TypeError('expected header name to be a string');
|
|
55
|
-
const values =
|
|
55
|
+
const values = isReadonlyArray(row[1]) ? row[1] : [row[1]];
|
|
56
56
|
let didClear = false;
|
|
57
57
|
for (const value of values) {
|
|
58
58
|
if (value === undefined) continue;
|
package/src/internal/uploads.ts
CHANGED
|
@@ -90,7 +90,7 @@ export const multipartFormRequestOptions = async (
|
|
|
90
90
|
return { ...opts, body: await createForm(opts.body, fetch) };
|
|
91
91
|
};
|
|
92
92
|
|
|
93
|
-
const supportsFormDataMap = new WeakMap<Fetch, Promise<boolean>>();
|
|
93
|
+
const supportsFormDataMap = /** @__PURE__ */ new WeakMap<Fetch, Promise<boolean>>();
|
|
94
94
|
|
|
95
95
|
/**
|
|
96
96
|
* node-fetch doesn't support the global FormData object in recent node versions. Instead of sending
|
|
@@ -58,7 +58,7 @@ const noopLogger = {
|
|
|
58
58
|
debug: noop,
|
|
59
59
|
};
|
|
60
60
|
|
|
61
|
-
let cachedLoggers = new WeakMap<Logger, [LogLevel, Logger]>();
|
|
61
|
+
let cachedLoggers = /** @__PURE__ */ new WeakMap<Logger, [LogLevel, Logger]>();
|
|
62
62
|
|
|
63
63
|
export function loggerFor(client: Coingecko): Logger {
|
|
64
64
|
const logger = client.logger;
|
|
@@ -62,4 +62,4 @@ export const createPathTagFunction = (pathEncoder = encodeURIPath) =>
|
|
|
62
62
|
/**
|
|
63
63
|
* URI-encodes path params and ensures no unsafe /./ or /../ path segments are introduced.
|
|
64
64
|
*/
|
|
65
|
-
export const path = createPathTagFunction(encodeURIPath);
|
|
65
|
+
export const path = /* @__PURE__ */ createPathTagFunction(encodeURIPath);
|
|
@@ -9,6 +9,9 @@ export const isAbsoluteURL = (url: string): boolean => {
|
|
|
9
9
|
return startsWithSchemeRegexp.test(url);
|
|
10
10
|
};
|
|
11
11
|
|
|
12
|
+
export let isArray = (val: unknown): val is unknown[] => ((isArray = Array.isArray), isArray(val));
|
|
13
|
+
export let isReadonlyArray = isArray as (val: unknown) => val is readonly unknown[];
|
|
14
|
+
|
|
12
15
|
/** Returns an object if the given value isn't an object, otherwise returns as-is */
|
|
13
16
|
export function maybeObj(x: unknown): object {
|
|
14
17
|
if (typeof x !== 'object') {
|
package/src/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const VERSION = '1.
|
|
1
|
+
export const VERSION = '1.6.0'; // x-release-please-version
|
package/version.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "1.
|
|
1
|
+
export declare const VERSION = "1.6.0";
|
|
2
2
|
//# sourceMappingURL=version.d.mts.map
|
package/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "1.
|
|
1
|
+
export declare const VERSION = "1.6.0";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
package/version.js
CHANGED
package/version.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const VERSION = '1.
|
|
1
|
+
export const VERSION = '1.6.0'; // x-release-please-version
|
|
2
2
|
//# sourceMappingURL=version.mjs.map
|