@chainlink/external-adapter-framework 0.0.20 → 0.0.22

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.
Files changed (49) hide show
  1. package/background-executor.d.ts +1 -3
  2. package/background-executor.js +9 -4
  3. package/cache/factory.js +0 -27
  4. package/cache/index.js +1 -16
  5. package/cache/local.js +0 -26
  6. package/cache/redis.js +0 -45
  7. package/config/index.d.ts +1 -1
  8. package/examples/coingecko/src/config/index.d.ts +2 -0
  9. package/examples/coingecko/src/config/index.js +1 -9
  10. package/examples/coingecko/src/config/overrides.json +0 -1
  11. package/examples/coingecko/src/cryptoUtils.d.ts +31 -0
  12. package/examples/coingecko/src/cryptoUtils.js +20 -1
  13. package/examples/coingecko/src/endpoint/coins.d.ts +9 -0
  14. package/examples/coingecko/src/endpoint/coins.js +3 -2
  15. package/examples/coingecko/src/endpoint/crypto-marketcap.d.ts +3 -0
  16. package/examples/coingecko/src/endpoint/crypto-marketcap.js +5 -22
  17. package/examples/coingecko/src/endpoint/crypto-volume.d.ts +3 -0
  18. package/examples/coingecko/src/endpoint/crypto-volume.js +5 -22
  19. package/examples/coingecko/src/endpoint/crypto.d.ts +3 -0
  20. package/examples/coingecko/src/endpoint/crypto.js +5 -25
  21. package/examples/coingecko/src/endpoint/dominance.d.ts +3 -0
  22. package/examples/coingecko/src/endpoint/dominance.js +4 -3
  23. package/examples/coingecko/src/endpoint/global-marketcap.d.ts +3 -0
  24. package/examples/coingecko/src/endpoint/global-marketcap.js +4 -3
  25. package/examples/coingecko/src/endpoint/index.d.ts +6 -0
  26. package/examples/coingecko/src/globalUtils.d.ts +27 -0
  27. package/examples/coingecko/src/globalUtils.js +6 -8
  28. package/examples/coingecko/src/index.d.ts +4 -0
  29. package/examples/coingecko/src/index.js +7 -3
  30. package/examples/coingecko-old/batch-warming.d.ts +7 -0
  31. package/examples/coingecko-old/index.d.ts +2 -0
  32. package/examples/coingecko-old/rest.d.ts +12 -0
  33. package/index.d.ts +2 -2
  34. package/index.js +24 -7
  35. package/metrics/index.d.ts +1 -1
  36. package/metrics/index.js +7 -3
  37. package/package.json +11 -5
  38. package/rate-limiting/index.d.ts +2 -2
  39. package/test.js +2 -2
  40. package/transports/batch-warming.d.ts +1 -1
  41. package/transports/batch-warming.js +1 -37
  42. package/transports/index.d.ts +3 -1
  43. package/transports/index.js +3 -1
  44. package/transports/metrics.d.ts +1 -1
  45. package/transports/rest.js +0 -32
  46. package/transports/util.js +0 -33
  47. package/transports/websocket.js +0 -31
  48. package/util/request.d.ts +0 -1
  49. package/validation/index.js +4 -2
@@ -1,5 +1,3 @@
1
- /// <reference types="node" />
2
- import { Server } from 'http';
3
1
  import { Adapter } from './adapter';
4
2
  /**
5
3
  * Very simple background loop that will call the [[Transport.backgroundExecute]] functions in all Transports.
@@ -8,4 +6,4 @@ import { Adapter } from './adapter';
8
6
  * @param adapter - an initialized External Adapter
9
7
  * @param server - the http server to attach an on close listener to
10
8
  */
11
- export declare function callBackgroundExecutes(adapter: Adapter, server?: Server): Promise<void>;
9
+ export declare function callBackgroundExecutes(adapter: Adapter, apiShutdownPromise?: Promise<void>): Promise<void>;
@@ -10,12 +10,18 @@ const logger = (0, util_1.makeLogger)('BackgroundExecutor');
10
10
  * @param adapter - an initialized External Adapter
11
11
  * @param server - the http server to attach an on close listener to
12
12
  */
13
- async function callBackgroundExecutes(adapter, server) {
13
+ async function callBackgroundExecutes(adapter, apiShutdownPromise) {
14
14
  // Set up variable to check later on to see if we need to stop this background "thread"
15
15
  // If no server is provided, the listener won't be set and serverClosed will always be false
16
16
  let serverClosed = false;
17
- server?.on('close', () => {
17
+ const timeoutsMap = {};
18
+ apiShutdownPromise?.then(() => {
18
19
  serverClosed = true;
20
+ for (const endpointName in timeoutsMap) {
21
+ logger.debug(`Clearing timeout for endpoint "${endpointName}"`);
22
+ timeoutsMap[endpointName].unref();
23
+ clearTimeout(timeoutsMap[endpointName]);
24
+ }
19
25
  });
20
26
  for (const endpoint of adapter.endpoints) {
21
27
  const backgroundExecute = endpoint.transport.backgroundExecute?.bind(endpoint.transport);
@@ -35,8 +41,7 @@ async function callBackgroundExecutes(adapter, server) {
35
41
  logger.debug(`Calling background execute for endpoint "${endpoint.name}"`);
36
42
  const timeToWait = await backgroundExecute(context);
37
43
  logger.debug(`Finished background execute for endpoint "${endpoint.name}", sleeping for ${timeToWait}ms`);
38
- await (0, util_1.sleep)(timeToWait);
39
- handler();
44
+ timeoutsMap[endpoint.name] = setTimeout(handler, timeToWait);
40
45
  };
41
46
  // Start recursive async calls
42
47
  handler();
package/cache/factory.js CHANGED
@@ -1,27 +1,4 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
26
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
4
  };
@@ -30,7 +7,6 @@ exports.CacheFactory = void 0;
30
7
  const ioredis_1 = __importDefault(require("ioredis"));
31
8
  const util_1 = require("../util");
32
9
  const local_1 = require("./local");
33
- const cacheMetrics = __importStar(require("./metrics"));
34
10
  const redis_1 = require("./redis");
35
11
  const logger = (0, util_1.makeLogger)('CacheFactory');
36
12
  class CacheFactory {
@@ -48,9 +24,6 @@ class CacheFactory {
48
24
  path: config.CACHE_REDIS_PATH,
49
25
  timeout: config.CACHE_REDIS_TIMEOUT,
50
26
  });
51
- redis.on('connect', () => {
52
- cacheMetrics.redisConnectionsOpen.inc();
53
- });
54
27
  return new redis_1.RedisCache(redis);
55
28
  }
56
29
  }
package/cache/index.js CHANGED
@@ -10,25 +10,12 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
10
10
  if (k2 === undefined) k2 = k;
11
11
  o[k2] = m[k];
12
12
  }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
13
  var __exportStar = (this && this.__exportStar) || function(m, exports) {
26
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
27
15
  };
28
16
  Object.defineProperty(exports, "__esModule", { value: true });
29
17
  exports.buildCacheMiddleware = exports.pollResponseFromCache = exports.calculateKey = exports.calculateFeedId = exports.calculateCacheKey = void 0;
30
18
  const util_1 = require("../util");
31
- const cacheMetrics = __importStar(require("./metrics"));
32
19
  __exportStar(require("./local"), exports);
33
20
  __exportStar(require("./redis"), exports);
34
21
  __exportStar(require("./factory"), exports);
@@ -157,10 +144,8 @@ const buildCacheMiddleware = (adapter) => async (req, res) => {
157
144
  if (response) {
158
145
  logger.debug('Found response from cache, sending that');
159
146
  if (adapter.config.METRICS_ENABLED && adapter.config.EXPERIMENTAL_METRICS_ENABLED) {
160
- const label = cacheMetrics.cacheMetricsLabel(req.requestContext.cacheKey, req.requestContext.meta?.metrics?.feedId || 'N/A', adapter.config.CACHE_TYPE);
161
147
  // Record cache staleness and cache get count and value
162
- const staleness = calculateStaleness(response.maxAge, adapter.config.CACHE_MAX_AGE);
163
- cacheMetrics.cacheGet(label, response.result, staleness);
148
+ calculateStaleness(response.maxAge, adapter.config.CACHE_MAX_AGE);
164
149
  req.requestContext.meta = {
165
150
  ...req.requestContext.meta,
166
151
  metrics: { ...req.requestContext.meta?.metrics, cacheHit: true },
package/cache/local.js CHANGED
@@ -1,31 +1,7 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
2
  Object.defineProperty(exports, "__esModule", { value: true });
26
3
  exports.LocalCache = void 0;
27
4
  const util_1 = require("../util");
28
- const cacheMetrics = __importStar(require("./metrics"));
29
5
  const logger = (0, util_1.makeLogger)('LocalCache');
30
6
  /**
31
7
  * Local implementation of a Cache. It uses a simple js Object, storing entries with both
@@ -69,8 +45,6 @@ class LocalCache {
69
45
  const feedId = value.meta?.metrics?.feedId;
70
46
  if (feedId) {
71
47
  // Record cache set count, max age, and staleness (set to 0 for cache set)
72
- const label = cacheMetrics.cacheMetricsLabel(key, feedId, cacheMetrics.CacheTypes.Local);
73
- cacheMetrics.cacheSet(label, ttl);
74
48
  }
75
49
  }
76
50
  async setMany(entries, ttl) {
package/cache/redis.js CHANGED
@@ -1,31 +1,7 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
2
  Object.defineProperty(exports, "__esModule", { value: true });
26
3
  exports.RedisCache = void 0;
27
4
  const util_1 = require("../util");
28
- const cacheMetrics = __importStar(require("./metrics"));
29
5
  const logger = (0, util_1.makeLogger)('RedisCache');
30
6
  /**
31
7
  * Redis implementation of a Cache. It uses a simple js Object, storing entries with both
@@ -40,10 +16,6 @@ class RedisCache {
40
16
  async get(key) {
41
17
  logger.trace(`Getting key ${key}`);
42
18
  const value = await this.client.get(key);
43
- // Record get command sent to Redis
44
- cacheMetrics.redisCommandsSentCount
45
- .labels({ status: cacheMetrics.CMD_SENT_STATUS.SUCCESS, function_name: 'get' })
46
- .inc();
47
19
  if (!value) {
48
20
  logger.debug(`No entry in redis cache for key "${key}", returning undefined`);
49
21
  return undefined;
@@ -53,10 +25,6 @@ class RedisCache {
53
25
  async delete(key) {
54
26
  logger.trace(`Deleting key ${key}`);
55
27
  await this.client.del(key);
56
- // Record delete command sent to Redis
57
- cacheMetrics.redisCommandsSentCount
58
- .labels({ status: cacheMetrics.CMD_SENT_STATUS.SUCCESS, function_name: 'delete' })
59
- .inc();
60
28
  }
61
29
  async set(key, value, ttl) {
62
30
  logger.trace(`Setting key ${key}`);
@@ -65,13 +33,7 @@ class RedisCache {
65
33
  const feedId = value.meta?.metrics?.feedId;
66
34
  if (feedId) {
67
35
  // Record cache set count, max age, and staleness (set to 0 for cache set)
68
- const label = cacheMetrics.cacheMetricsLabel(key, feedId, cacheMetrics.CacheTypes.Redis);
69
- cacheMetrics.cacheSet(label, ttl);
70
36
  }
71
- // Record set command sent to Redis
72
- cacheMetrics.redisCommandsSentCount
73
- .labels({ status: cacheMetrics.CMD_SENT_STATUS.SUCCESS, function_name: 'set' })
74
- .inc();
75
37
  }
76
38
  async setMany(entries, ttl) {
77
39
  logger.trace(`Setting a bunch of keys`);
@@ -86,15 +48,8 @@ class RedisCache {
86
48
  // Only record metrics if feed Id is present, otherwise assuming value is not adapter response to record
87
49
  const feedId = entry.value.meta?.metrics?.feedId;
88
50
  if (feedId) {
89
- // Record cache set count, max age, and staleness (set to 0 for cache set)
90
- const label = cacheMetrics.cacheMetricsLabel(entry.key, feedId, cacheMetrics.CacheTypes.Redis);
91
- cacheMetrics.cacheSet(label, ttl);
92
51
  }
93
52
  }
94
- // Record setMany command sent to Redis
95
- cacheMetrics.redisCommandsSentCount
96
- .labels({ status: cacheMetrics.CMD_SENT_STATUS.SUCCESS, function_name: 'exec' })
97
- .inc();
98
53
  }
99
54
  }
100
55
  exports.RedisCache = RedisCache;
package/config/index.d.ts CHANGED
@@ -159,7 +159,7 @@ export declare const BaseSettings: {
159
159
  readonly description: "Maximum amount of characters that the common part of the cache key or feed ID can have";
160
160
  readonly type: "number";
161
161
  readonly default: 300;
162
- readonly validate: (value?: number | undefined) => "MAX_COMMON_KEY_SIZE must be a number between 150 and 500" | undefined;
162
+ readonly validate: (value?: number) => "MAX_COMMON_KEY_SIZE must be a number between 150 and 500" | undefined;
163
163
  };
164
164
  readonly REST_TRANSPORT_MAX_RATE_LIMIT_RETRIES: {
165
165
  readonly description: "Maximum amount of times the Rest Transport will attempt to set up a request when blocked by the rate limiter";
@@ -0,0 +1,2 @@
1
+ export declare const DEFAULT_API_ENDPOINT = "https://api.coingecko.com/api/v3";
2
+ export declare const PRO_API_ENDPOINT = "https://pro-api.coingecko.com/api/v3";
@@ -1,13 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.customSettings = exports.PRO_API_ENDPOINT = exports.DEFAULT_API_ENDPOINT = exports.DEFAULT_ENDPOINT = exports.NAME = void 0;
4
- exports.NAME = 'COINGECKO';
5
- exports.DEFAULT_ENDPOINT = 'crypto';
3
+ exports.PRO_API_ENDPOINT = exports.DEFAULT_API_ENDPOINT = void 0;
6
4
  exports.DEFAULT_API_ENDPOINT = 'https://api.coingecko.com/api/v3';
7
5
  exports.PRO_API_ENDPOINT = 'https://pro-api.coingecko.com/api/v3';
8
- exports.customSettings = {
9
- API_KEY: {
10
- description: 'API key for the CoinGecko API',
11
- type: 'string',
12
- },
13
- };
@@ -9003,7 +9003,6 @@
9003
9003
  "CRDC": "cardiocoin",
9004
9004
  "$CRDN": "cardence",
9005
9005
  "CEVO": "cardanoevo",
9006
- "ADA": "binance-peg-cardano",
9007
9006
  "ADA": "cardano",
9008
9007
  "CCM": "car-coin",
9009
9008
  "CARBON": "carboncoin",
@@ -0,0 +1,31 @@
1
+ import { AxiosRequestConfig, AxiosResponse } from 'axios';
2
+ import { AdapterConfig } from '../../../config';
3
+ import { InputParameters } from '../../../validation';
4
+ export interface CryptoRequestParams {
5
+ coinid?: string;
6
+ base?: string;
7
+ quote: string;
8
+ }
9
+ export declare const cryptoInputParams: InputParameters;
10
+ export interface ProviderRequestBody {
11
+ ids: string;
12
+ vs_currencies: string;
13
+ include_market_cap?: boolean;
14
+ include_24hr_vol?: boolean;
15
+ }
16
+ export interface ProviderResponseBody {
17
+ [base: string]: {
18
+ [quote: string]: number;
19
+ };
20
+ }
21
+ interface ResultEntryWithoutOverrides {
22
+ value: number;
23
+ params: {
24
+ quote: string;
25
+ base?: string;
26
+ coinid?: string;
27
+ };
28
+ }
29
+ export declare const buildBatchedRequestBody: (params: CryptoRequestParams[], config: AdapterConfig) => AxiosRequestConfig<ProviderRequestBody>;
30
+ export declare const constructEntry: (res: AxiosResponse<ProviderResponseBody>, requestPayload: CryptoRequestParams, resultPath: string) => ResultEntryWithoutOverrides | undefined;
31
+ export {};
@@ -1,8 +1,27 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.constructEntry = exports.buildBatchedRequestBody = void 0;
3
+ exports.constructEntry = exports.buildBatchedRequestBody = exports.cryptoInputParams = void 0;
4
4
  const config_1 = require("./config");
5
5
  const logger_1 = require("../../../util/logger");
6
+ exports.cryptoInputParams = {
7
+ coinid: {
8
+ description: 'The CoinGecko id or to query',
9
+ type: 'string',
10
+ required: false,
11
+ },
12
+ base: {
13
+ aliases: ['from', 'coin'],
14
+ type: 'string',
15
+ description: 'The symbol of symbols of the currency to query',
16
+ required: false,
17
+ },
18
+ quote: {
19
+ aliases: ['to', 'market'],
20
+ type: 'string',
21
+ description: 'The symbol of the currency to convert to',
22
+ required: true,
23
+ },
24
+ };
6
25
  const buildBatchedRequestBody = (params, config) => {
7
26
  return {
8
27
  baseURL: config.API_KEY ? config_1.PRO_API_ENDPOINT : config_1.DEFAULT_API_ENDPOINT,
@@ -0,0 +1,9 @@
1
+ import { AdapterEndpoint } from '../../../../../src/adapter';
2
+ import { InputParameters } from '../../../../../src/validation';
3
+ export declare const inputParameters: InputParameters;
4
+ export interface CoinsResponse {
5
+ id: string;
6
+ symbol: string;
7
+ name: string;
8
+ }
9
+ export declare const endpoint: AdapterEndpoint<import("../../../../util/request").AdapterRequestData, CoinsResponse[], import("../../../../config").SettingsMap>;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.endpoint = exports.inputParameters = void 0;
4
+ const adapter_1 = require("../../../../../src/adapter");
4
5
  const transports_1 = require("../../../../../src/transports");
5
6
  const config_1 = require("../config");
6
7
  exports.inputParameters = {};
@@ -26,8 +27,8 @@ const restEndpointTransport = new transports_1.RestTransport({
26
27
  coalescing: true,
27
28
  },
28
29
  });
29
- exports.endpoint = {
30
+ exports.endpoint = new adapter_1.AdapterEndpoint({
30
31
  name: 'coins',
31
32
  transport: restEndpointTransport,
32
33
  inputParameters: exports.inputParameters,
33
- };
34
+ });
@@ -0,0 +1,3 @@
1
+ import { AdapterEndpoint } from '../../../../adapter';
2
+ import { CryptoRequestParams } from '../cryptoUtils';
3
+ export declare const endpoint: AdapterEndpoint<CryptoRequestParams, unknown, import("../../../../config").SettingsMap>;
@@ -1,26 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.endpoint = exports.inputParameters = void 0;
3
+ exports.endpoint = void 0;
4
+ const adapter_1 = require("../../../../adapter");
4
5
  const batch_warming_1 = require("../../../../transports/batch-warming");
5
- const input_params_1 = require("../../../../validation/input-params");
6
6
  const cryptoUtils_1 = require("../cryptoUtils");
7
- exports.inputParameters = {
8
- overrides: input_params_1.baseInputParameters['overrides'],
9
- coinid: {
10
- description: 'The CoinGecko id or to query',
11
- required: false,
12
- },
13
- base: {
14
- aliases: ['from', 'coin'],
15
- description: 'The symbol of symbols of the currency to query',
16
- required: false,
17
- },
18
- quote: {
19
- aliases: ['to', 'market'],
20
- description: 'The symbol of the currency to convert to',
21
- required: true,
22
- },
23
- };
24
7
  const batchEndpointTransport = new batch_warming_1.BatchWarmingTransport({
25
8
  prepareRequest: (params, context) => {
26
9
  const requestBody = (0, cryptoUtils_1.buildBatchedRequestBody)(params, context.adapterConfig);
@@ -38,9 +21,9 @@ const batchEndpointTransport = new batch_warming_1.BatchWarmingTransport({
38
21
  return entries;
39
22
  },
40
23
  });
41
- exports.endpoint = {
24
+ exports.endpoint = new adapter_1.AdapterEndpoint({
42
25
  name: 'marketcap',
43
26
  aliases: ['crypto-marketcap'],
44
27
  transport: batchEndpointTransport,
45
- inputParameters: exports.inputParameters,
46
- };
28
+ inputParameters: cryptoUtils_1.cryptoInputParams,
29
+ });
@@ -0,0 +1,3 @@
1
+ import { AdapterEndpoint } from '../../../../adapter';
2
+ import { CryptoRequestParams } from '../cryptoUtils';
3
+ export declare const endpoint: AdapterEndpoint<CryptoRequestParams, unknown, import("../../../../config").SettingsMap>;
@@ -1,26 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.endpoint = exports.inputParameters = void 0;
3
+ exports.endpoint = void 0;
4
+ const adapter_1 = require("../../../../adapter");
4
5
  const batch_warming_1 = require("../../../../transports/batch-warming");
5
- const input_params_1 = require("../../../../validation/input-params");
6
6
  const cryptoUtils_1 = require("../cryptoUtils");
7
- exports.inputParameters = {
8
- overrides: input_params_1.baseInputParameters['overrides'],
9
- coinid: {
10
- description: 'The CoinGecko id or to query',
11
- required: false,
12
- },
13
- base: {
14
- aliases: ['from', 'coin'],
15
- description: 'The symbol of symbols of the currency to query',
16
- required: false,
17
- },
18
- quote: {
19
- aliases: ['to', 'market'],
20
- description: 'The symbol of the currency to convert to',
21
- required: true,
22
- },
23
- };
24
7
  const batchEndpointTransport = new batch_warming_1.BatchWarmingTransport({
25
8
  prepareRequest: (params, context) => {
26
9
  const requestBody = (0, cryptoUtils_1.buildBatchedRequestBody)(params, context.adapterConfig);
@@ -38,9 +21,9 @@ const batchEndpointTransport = new batch_warming_1.BatchWarmingTransport({
38
21
  return entries;
39
22
  },
40
23
  });
41
- exports.endpoint = {
24
+ exports.endpoint = new adapter_1.AdapterEndpoint({
42
25
  name: 'volume',
43
26
  aliases: ['crypto-volume'],
44
27
  transport: batchEndpointTransport,
45
- inputParameters: exports.inputParameters,
46
- };
28
+ inputParameters: cryptoUtils_1.cryptoInputParams,
29
+ });
@@ -0,0 +1,3 @@
1
+ import { AdapterEndpoint } from '../../../../adapter';
2
+ import { CryptoRequestParams } from '../cryptoUtils';
3
+ export declare const endpoint: AdapterEndpoint<CryptoRequestParams, unknown, import("../../../../config").SettingsMap>;
@@ -1,26 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.endpoint = exports.inputParameters = void 0;
3
+ exports.endpoint = void 0;
4
+ const adapter_1 = require("../../../../adapter");
4
5
  const batch_warming_1 = require("../../../../transports/batch-warming");
5
- const input_params_1 = require("../../../../validation/input-params");
6
6
  const cryptoUtils_1 = require("../cryptoUtils");
7
- exports.inputParameters = {
8
- overrides: input_params_1.baseInputParameters['overrides'],
9
- coinid: {
10
- description: 'The CoinGecko id or to query',
11
- required: false,
12
- },
13
- base: {
14
- aliases: ['from', 'coin'],
15
- description: 'The symbol of symbols of the currency to query',
16
- required: false,
17
- },
18
- quote: {
19
- aliases: ['to', 'market'],
20
- description: 'The symbol of the currency to convert to',
21
- required: true,
22
- },
23
- };
24
7
  const batchEndpointTransport = new batch_warming_1.BatchWarmingTransport({
25
8
  prepareRequest: (params, context) => {
26
9
  return (0, cryptoUtils_1.buildBatchedRequestBody)(params, context.adapterConfig);
@@ -29,9 +12,6 @@ const batchEndpointTransport = new batch_warming_1.BatchWarmingTransport({
29
12
  const entries = [];
30
13
  for (const requestPayload of params) {
31
14
  const entry = (0, cryptoUtils_1.constructEntry)(res, requestPayload, requestPayload.quote.toLowerCase());
32
- // NOTE: the `entries` array is going to be shorter than the `params` array if one of the params has a bad token.
33
- // Is that okay? I did this to avoid caching an invalid value for transient DP issues. Just want to make
34
- // sure this works within the core framework
35
15
  if (entry) {
36
16
  entries.push(entry);
37
17
  }
@@ -39,9 +19,9 @@ const batchEndpointTransport = new batch_warming_1.BatchWarmingTransport({
39
19
  return entries;
40
20
  },
41
21
  });
42
- exports.endpoint = {
22
+ exports.endpoint = new adapter_1.AdapterEndpoint({
43
23
  name: 'crypto',
44
24
  aliases: ['crypto-batched', 'batched', 'batch'],
45
25
  transport: batchEndpointTransport,
46
- inputParameters: exports.inputParameters,
47
- };
26
+ inputParameters: cryptoUtils_1.cryptoInputParams,
27
+ });
@@ -0,0 +1,3 @@
1
+ import { AdapterEndpoint } from '../../../../adapter';
2
+ import { AdapterRequestParams } from '../globalUtils';
3
+ export declare const endpoint: AdapterEndpoint<AdapterRequestParams, unknown, import("../../../../config").SettingsMap>;
@@ -1,11 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.endpoint = void 0;
4
+ const adapter_1 = require("../../../../adapter");
4
5
  const batch_warming_1 = require("../../../../transports/batch-warming");
5
6
  const globalUtils_1 = require("../globalUtils");
6
7
  const batchEndpointTransport = new batch_warming_1.BatchWarmingTransport({
7
8
  prepareRequest: (params, context) => {
8
- return (0, globalUtils_1.buildGlobalRequestBody)(context.adapterConfig);
9
+ return (0, globalUtils_1.buildGlobalRequestBody)(context.adapterConfig.API_KEY);
9
10
  },
10
11
  parseResponse: (params, res) => {
11
12
  const entries = [];
@@ -18,9 +19,9 @@ const batchEndpointTransport = new batch_warming_1.BatchWarmingTransport({
18
19
  return entries;
19
20
  },
20
21
  });
21
- exports.endpoint = {
22
+ exports.endpoint = new adapter_1.AdapterEndpoint({
22
23
  name: 'dominance',
23
24
  aliases: ['market_cap_percentage'],
24
25
  transport: batchEndpointTransport,
25
26
  inputParameters: globalUtils_1.inputParameters,
26
- };
27
+ });
@@ -0,0 +1,3 @@
1
+ import { AdapterEndpoint } from '../../../../adapter';
2
+ import { AdapterRequestParams } from '../globalUtils';
3
+ export declare const endpoint: AdapterEndpoint<AdapterRequestParams, unknown, import("../../../../config").SettingsMap>;
@@ -1,11 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.endpoint = void 0;
4
+ const adapter_1 = require("../../../../adapter");
4
5
  const batch_warming_1 = require("../../../../transports/batch-warming");
5
6
  const globalUtils_1 = require("../globalUtils");
6
7
  const batchEndpointTransport = new batch_warming_1.BatchWarmingTransport({
7
8
  prepareRequest: (params, context) => {
8
- return (0, globalUtils_1.buildGlobalRequestBody)(context.adapterConfig);
9
+ return (0, globalUtils_1.buildGlobalRequestBody)(context.adapterConfig.API_KEY);
9
10
  },
10
11
  parseResponse: (params, res) => {
11
12
  const entries = [];
@@ -18,9 +19,9 @@ const batchEndpointTransport = new batch_warming_1.BatchWarmingTransport({
18
19
  return entries;
19
20
  },
20
21
  });
21
- exports.endpoint = {
22
+ exports.endpoint = new adapter_1.AdapterEndpoint({
22
23
  name: 'globalmarketcap',
23
24
  aliases: ['total_market_cap'],
24
25
  transport: batchEndpointTransport,
25
26
  inputParameters: globalUtils_1.inputParameters,
26
- };
27
+ });
@@ -0,0 +1,6 @@
1
+ export { endpoint as coins } from './coins';
2
+ export { endpoint as crypto } from './crypto';
3
+ export { endpoint as cryptoMarketcap } from './crypto-marketcap';
4
+ export { endpoint as globalMarketcap } from './global-marketcap';
5
+ export { endpoint as dominance } from './dominance';
6
+ export { endpoint as cryptoVolume } from './crypto-volume';
@@ -0,0 +1,27 @@
1
+ import { AxiosRequestConfig, AxiosResponse } from 'axios';
2
+ import { InputParameters } from '../../../validation';
3
+ export declare const inputParameters: InputParameters;
4
+ export interface AdapterRequestParams {
5
+ market: string;
6
+ }
7
+ export interface ProviderResponseBody {
8
+ data: {
9
+ active_cryptocurrencies: number;
10
+ upcoming_icos: number;
11
+ ongoing_icos: number;
12
+ ended_icos: number;
13
+ markets: number;
14
+ total_market_cap: Record<string, number>;
15
+ total_volume: Record<string, number>;
16
+ market_cap_percentage: Record<string, number>;
17
+ market_cap_change_percentage_24h_usd: number;
18
+ updated_at: number;
19
+ };
20
+ }
21
+ interface ResultEntry {
22
+ value: number;
23
+ params: AdapterRequestParams;
24
+ }
25
+ export declare const buildGlobalRequestBody: (apiKey?: string) => AxiosRequestConfig<never>;
26
+ export declare const constructEntry: (res: AxiosResponse<ProviderResponseBody>, requestPayload: AdapterRequestParams, resultPath: 'total_market_cap' | 'market_cap_percentage') => ResultEntry | undefined;
27
+ export {};