@chainlink/external-adapter-framework 0.0.14 → 0.0.16

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 (164) hide show
  1. package/adapter.js +114 -101
  2. package/cache/factory.js +3 -0
  3. package/chainlink-external-adapter-framework-v0.0.6.tgz +0 -0
  4. package/config/index.js +69 -83
  5. package/config/provider-limits.js +10 -15
  6. package/examples/bank-frick/accounts.js +3 -2
  7. package/examples/bank-frick/index.js +3 -2
  8. package/examples/coingecko/src/config/index.js +13 -0
  9. package/examples/coingecko/src/config/overrides.json +10826 -0
  10. package/examples/coingecko/src/cryptoUtils.js +41 -0
  11. package/examples/coingecko/src/endpoint/coins.js +33 -0
  12. package/examples/coingecko/src/endpoint/crypto-marketcap.js +46 -0
  13. package/examples/coingecko/src/endpoint/crypto-volume.js +46 -0
  14. package/examples/coingecko/src/endpoint/crypto.js +47 -0
  15. package/examples/coingecko/src/endpoint/dominance.js +26 -0
  16. package/examples/coingecko/src/endpoint/global-marketcap.js +26 -0
  17. package/examples/coingecko/src/endpoint/index.js +15 -0
  18. package/examples/coingecko/src/globalUtils.js +48 -0
  19. package/examples/coingecko/src/index.js +14 -0
  20. package/examples/coingecko/test/e2e/adapter.test.js +262 -0
  21. package/examples/coingecko/test/integration/adapter.test.js +264 -0
  22. package/examples/coingecko/test/integration/capturedRequests.json +1 -0
  23. package/examples/coingecko/test/integration/fixtures.js +41 -0
  24. package/{package/examples/coingecko → examples/coingecko-old}/batch-warming.js +4 -3
  25. package/examples/{coingecko → coingecko-old}/index.js +3 -2
  26. package/{package/examples/coingecko → examples/coingecko-old}/rest.js +3 -2
  27. package/examples/ncfx/index.js +3 -2
  28. package/examples/ncfx/websocket.js +3 -2
  29. package/index.js +17 -23
  30. package/package.json +5 -4
  31. package/rate-limiting/index.js +23 -2
  32. package/transports/batch-warming.js +1 -1
  33. package/transports/rest.js +9 -2
  34. package/transports/util.js +2 -1
  35. package/transports/websocket.js +4 -6
  36. package/util/recordRequests.js +45 -0
  37. package/{package/validation/override-functions.js → validation/overrideFunctions.js} +0 -0
  38. package/adapter.d.ts +0 -107
  39. package/background-executor.d.ts +0 -11
  40. package/cache/factory.d.ts +0 -6
  41. package/cache/index.d.ts +0 -94
  42. package/cache/local.d.ts +0 -23
  43. package/cache/metrics.d.ts +0 -27
  44. package/cache/redis.d.ts +0 -16
  45. package/chainlink-external-adapter-framework-0.0.6.tgz +0 -0
  46. package/config/index.d.ts +0 -209
  47. package/config/provider-limits.d.ts +0 -31
  48. package/examples/bank-frick/accounts.d.ts +0 -39
  49. package/examples/bank-frick/config/index.d.ts +0 -4
  50. package/examples/bank-frick/index.d.ts +0 -2
  51. package/examples/bank-frick/util.d.ts +0 -4
  52. package/examples/coingecko/batch-warming.d.ts +0 -2
  53. package/examples/coingecko/batch-warming.js +0 -52
  54. package/examples/coingecko/index.d.ts +0 -2
  55. package/examples/coingecko/rest.d.ts +0 -2
  56. package/examples/coingecko/rest.js +0 -50
  57. package/examples/ncfx/config/index.d.ts +0 -12
  58. package/examples/ncfx/index.d.ts +0 -2
  59. package/examples/ncfx/websocket.d.ts +0 -36
  60. package/index.d.ts +0 -11
  61. package/metrics/constants.d.ts +0 -16
  62. package/metrics/index.d.ts +0 -15
  63. package/metrics/util.d.ts +0 -7
  64. package/package/adapter.d.ts +0 -88
  65. package/package/adapter.js +0 -112
  66. package/package/background-executor.d.ts +0 -11
  67. package/package/background-executor.js +0 -45
  68. package/package/cache/factory.d.ts +0 -6
  69. package/package/cache/factory.js +0 -57
  70. package/package/cache/index.d.ts +0 -90
  71. package/package/cache/index.js +0 -169
  72. package/package/cache/local.d.ts +0 -23
  73. package/package/cache/local.js +0 -83
  74. package/package/cache/metrics.d.ts +0 -27
  75. package/package/cache/metrics.js +0 -120
  76. package/package/cache/redis.d.ts +0 -16
  77. package/package/cache/redis.js +0 -100
  78. package/package/config/index.d.ts +0 -195
  79. package/package/config/index.js +0 -365
  80. package/package/config/provider-limits.d.ts +0 -31
  81. package/package/config/provider-limits.js +0 -76
  82. package/package/examples/coingecko/batch-warming.d.ts +0 -2
  83. package/package/examples/coingecko/index.d.ts +0 -2
  84. package/package/examples/coingecko/index.js +0 -10
  85. package/package/examples/coingecko/rest.d.ts +0 -2
  86. package/package/examples/ncfx/config/index.d.ts +0 -12
  87. package/package/examples/ncfx/config/index.js +0 -15
  88. package/package/examples/ncfx/index.d.ts +0 -2
  89. package/package/examples/ncfx/index.js +0 -10
  90. package/package/examples/ncfx/websocket.d.ts +0 -36
  91. package/package/examples/ncfx/websocket.js +0 -72
  92. package/package/index.d.ts +0 -12
  93. package/package/index.js +0 -92
  94. package/package/metrics/constants.d.ts +0 -16
  95. package/package/metrics/constants.js +0 -25
  96. package/package/metrics/index.d.ts +0 -15
  97. package/package/metrics/index.js +0 -123
  98. package/package/metrics/util.d.ts +0 -3
  99. package/package/metrics/util.js +0 -9
  100. package/package/package.json +0 -72
  101. package/package/rate-limiting/background/fixed-frequency.d.ts +0 -10
  102. package/package/rate-limiting/background/fixed-frequency.js +0 -37
  103. package/package/rate-limiting/index.d.ts +0 -54
  104. package/package/rate-limiting/index.js +0 -63
  105. package/package/rate-limiting/metrics.d.ts +0 -3
  106. package/package/rate-limiting/metrics.js +0 -44
  107. package/package/rate-limiting/request/simple-counting.d.ts +0 -20
  108. package/package/rate-limiting/request/simple-counting.js +0 -62
  109. package/package/test.d.ts +0 -1
  110. package/package/test.js +0 -6
  111. package/package/transports/batch-warming.d.ts +0 -34
  112. package/package/transports/batch-warming.js +0 -101
  113. package/package/transports/index.d.ts +0 -87
  114. package/package/transports/index.js +0 -87
  115. package/package/transports/metrics.d.ts +0 -21
  116. package/package/transports/metrics.js +0 -105
  117. package/package/transports/rest.d.ts +0 -43
  118. package/package/transports/rest.js +0 -129
  119. package/package/transports/util.d.ts +0 -8
  120. package/package/transports/util.js +0 -85
  121. package/package/transports/websocket.d.ts +0 -80
  122. package/package/transports/websocket.js +0 -169
  123. package/package/util/expiring-sorted-set.d.ts +0 -21
  124. package/package/util/expiring-sorted-set.js +0 -47
  125. package/package/util/index.d.ts +0 -11
  126. package/package/util/index.js +0 -35
  127. package/package/util/logger.d.ts +0 -42
  128. package/package/util/logger.js +0 -62
  129. package/package/util/request.d.ts +0 -55
  130. package/package/util/request.js +0 -2
  131. package/package/validation/error.d.ts +0 -50
  132. package/package/validation/error.js +0 -79
  133. package/package/validation/index.d.ts +0 -5
  134. package/package/validation/index.js +0 -86
  135. package/package/validation/input-params.d.ts +0 -15
  136. package/package/validation/input-params.js +0 -30
  137. package/package/validation/override-functions.d.ts +0 -3
  138. package/package/validation/preset-tokens.json +0 -23
  139. package/package/validation/validator.d.ts +0 -47
  140. package/package/validation/validator.js +0 -303
  141. package/rate-limiting/background/fixed-frequency.d.ts +0 -10
  142. package/rate-limiting/index.d.ts +0 -54
  143. package/rate-limiting/metrics.d.ts +0 -3
  144. package/rate-limiting/request/simple-counting.d.ts +0 -20
  145. package/test.d.ts +0 -1
  146. package/transports/batch-warming.d.ts +0 -35
  147. package/transports/index.d.ts +0 -70
  148. package/transports/metrics.d.ts +0 -21
  149. package/transports/rest.d.ts +0 -44
  150. package/transports/util.d.ts +0 -8
  151. package/transports/websocket.d.ts +0 -81
  152. package/util/expiring-sorted-set.d.ts +0 -21
  153. package/util/expiring-sorted-set.js +0 -47
  154. package/util/index.d.ts +0 -12
  155. package/util/logger.d.ts +0 -42
  156. package/util/request.d.ts +0 -57
  157. package/util/subscription-set/expiring-sorted-set.d.ts +0 -22
  158. package/util/subscription-set/subscription-set.d.ts +0 -18
  159. package/util/test-payload-loader.d.ts +0 -25
  160. package/validation/error.d.ts +0 -50
  161. package/validation/index.d.ts +0 -5
  162. package/validation/input-params.d.ts +0 -15
  163. package/validation/override-functions.d.ts +0 -3
  164. package/validation/validator.d.ts +0 -47
package/adapter.js CHANGED
@@ -1,115 +1,128 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.initializeAdapter = exports.initializeDependencies = void 0;
3
+ exports.Adapter = exports.AdapterEndpoint = void 0;
4
4
  const cache_1 = require("./cache");
5
+ const config_1 = require("./config");
5
6
  const rate_limiting_1 = require("./rate-limiting");
6
7
  const util_1 = require("./util");
7
8
  const logger = (0, util_1.makeLogger)('Adapter');
8
- /**
9
- * This function will take an adapter structure and go through each endpoint, calculating
10
- * each one's allocation of the total rate limits that are set for the adapter as a whole.
11
- *
12
- * @param adapter - the adapter to initialize rate limiting for
13
- */
14
- const calculateRateLimitAllocations = (adapter) => {
15
- const numberOfEndpoints = adapter.endpoints.length;
16
- const endpointsWithExplicitAllocations = adapter.endpoints.filter((e) => e.rateLimiting);
17
- const totalExplicitAllocation = endpointsWithExplicitAllocations
18
- .map((e) => e.rateLimiting?.allocationPercentage || 0)
19
- .reduce((sum, next) => sum + next, 0);
20
- if (totalExplicitAllocation > 100) {
21
- throw new Error('The total allocation set for all endpoints summed cannot exceed 100%');
9
+ class AdapterEndpoint {
10
+ constructor(params) {
11
+ this.name = params.name;
12
+ this.aliases = params.aliases;
13
+ this.transport = params.transport;
14
+ this.inputParameters = params.inputParameters;
15
+ this.rateLimiting = params.rateLimiting;
22
16
  }
23
- if (totalExplicitAllocation === 100 &&
24
- numberOfEndpoints - endpointsWithExplicitAllocations.length > 0) {
25
- throw new Error('The explicit allocation is at 100% but there are endpoints with implicit allocation');
17
+ }
18
+ exports.AdapterEndpoint = AdapterEndpoint;
19
+ class Adapter {
20
+ constructor(params) {
21
+ // After initialization
22
+ this.initialized = false;
23
+ /** Object containing alias translations for all endpoints */
24
+ this.endpointsMap = {};
25
+ // Copy over params
26
+ this.name = params.name;
27
+ this.defaultEndpoint = params.defaultEndpoint?.toLowerCase();
28
+ this.endpoints = params.endpoints;
29
+ this.envDefaultOverrides = params.envDefaultOverrides;
30
+ this.customSettings = params.customSettings;
31
+ this.rateLimiting = params.rateLimiting;
32
+ this.overrides = params.overrides;
33
+ this.config = (0, config_1.buildAdapterConfig)({
34
+ overrides: this.envDefaultOverrides,
35
+ customSettings: this.customSettings,
36
+ });
37
+ this.normalizeEndpointNames();
38
+ this.calculateRateLimitAllocations();
26
39
  }
27
- const implicitAllocation = 100 - totalExplicitAllocation;
28
- logger.debug('Adapter rate limit allocations:');
29
- for (const endpoint of adapter.endpoints) {
30
- if (!endpoint.rateLimiting) {
31
- endpoint.rateLimiting = {
32
- allocationPercentage: implicitAllocation / (numberOfEndpoints - endpointsWithExplicitAllocations.length),
33
- };
40
+ /**
41
+ * Initializes all of the [[Transport]]s in the adapter, passing along any [[AdapterDependencies]] and [[AdapterConfig]].
42
+ * Additionally, it builds a map out of all the endpoint names and aliases (checking for duplicates).
43
+ */
44
+ async initialize(dependencies) {
45
+ if (this.initialized) {
46
+ throw new Error('This adapter has already been initialized!');
34
47
  }
35
- logger.debug(`Endpoint [${endpoint.name}] - ${endpoint.rateLimiting?.allocationPercentage}%`);
36
- }
37
- };
38
- /**
39
- * This function will process dependencies for an adapter, such as caches or rate limiters,
40
- * in order to inject them into transports and other relevant places later in the lifecycle.
41
- *
42
- * @param config - the configuration for this adapter
43
- * @param inputDependencies - a partial obj of initialized dependencies to override the created ones
44
- * @param rateLimitingConfig - details from the adapter regarding rate limiting
45
- * @returns a set of AdapterDependencies all initialized
46
- */
47
- const initializeDependencies = (adapter, config, inputDependencies) => {
48
- const dependencies = inputDependencies || {};
49
- if (!dependencies.cache) {
50
- dependencies.cache = cache_1.CacheFactory.buildCache(config);
51
- }
52
- // In the future we might want something more complex, but for now it's better to simplify
53
- // and just use the same rate limiting for everything. Once we have a more complex use case we
54
- // can think of ways to make this more configurable.
55
- const rateLimitingTier = (0, rate_limiting_1.getRateLimitingTier)(adapter.rateLimiting?.tiers, config.RATE_LIMIT_API_TIER);
56
- if (!dependencies.requestRateLimiter) {
57
- dependencies.requestRateLimiter = new rate_limiting_1.SimpleCountingRateLimiter().initialize(adapter.endpoints, rateLimitingTier);
58
- }
59
- if (!dependencies.backgroundExecuteRateLimiter) {
60
- dependencies.backgroundExecuteRateLimiter = new rate_limiting_1.FixedFrequencyRateLimiter().initialize(adapter.endpoints, rateLimitingTier);
61
- }
62
- if (!dependencies.subscriptionSetFactory) {
63
- dependencies.subscriptionSetFactory = new util_1.SubscriptionSetFactory(config);
48
+ this.dependencies = this.initializeDependencies(dependencies);
49
+ for (const endpoint of this.endpoints) {
50
+ // Add aliases to map to use in validation
51
+ const aliases = [endpoint.name, ...(endpoint.aliases || [])];
52
+ for (const alias of aliases) {
53
+ if (this.endpointsMap[alias]) {
54
+ throw new Error(`Duplicate endpoint / alias: "${alias}"`);
55
+ }
56
+ this.endpointsMap[alias] = endpoint;
57
+ }
58
+ logger.debug(`Initializing transport for endpoint "${endpoint.name}"...`);
59
+ await endpoint.transport.initialize(this.dependencies, this.config);
60
+ }
61
+ logger.debug('Adapter initialization complete.');
62
+ this.initialized = true;
64
63
  }
65
- return dependencies;
66
- };
67
- exports.initializeDependencies = initializeDependencies;
68
- /**
69
- * Takes an adapter and normalizes all endpoint names and aliases, as well as the default endpoint.
70
- * i.e. makes them lowercase for now
71
- * @param adapter - an instance of an Adapter
72
- */
73
- const normalizeEndpointNames = (adapter) => {
74
- // Make endpoints case insensitive, including default
75
- adapter.defaultEndpoint = adapter.defaultEndpoint?.toLowerCase();
76
- for (const endpoint of adapter.endpoints) {
77
- endpoint.name = endpoint.name.toLowerCase();
78
- endpoint.aliases = endpoint.aliases?.map((a) => a.toLowerCase());
64
+ /**
65
+ * Takes an adapter and normalizes all endpoint names and aliases, as well as the default endpoint.
66
+ * i.e. makes them lowercase for now
67
+ */
68
+ normalizeEndpointNames() {
69
+ for (const endpoint of this.endpoints) {
70
+ endpoint.name = endpoint.name.toLowerCase();
71
+ endpoint.aliases = endpoint.aliases?.map((a) => a.toLowerCase());
72
+ }
79
73
  }
80
- };
81
- /**
82
- * Initializes all of the [[Transport]]s in the adapter, passing along any [[AdapterDependencies]] and [[AdapterConfig]].
83
- * Additionally, it builds a map out of all the endpoint names and aliases (checking for duplicates).
84
- *
85
- * @param adapter - an instance of an Adapter
86
- * @param dependencies - dependencies that the adapter will need at initialization
87
- * @param config - configuration variables already processed and validated
88
- * @returns - the adapter with all transports initialized and aliases map built
89
- */
90
- const initializeAdapter = async (adapter, config, dependencies) => {
91
- normalizeEndpointNames(adapter);
92
- calculateRateLimitAllocations(adapter);
93
- const initializedDependencies = (0, exports.initializeDependencies)(adapter, config, dependencies);
94
- const endpointsMap = {};
95
- for (const endpoint of adapter.endpoints) {
96
- // Add aliases to map to use in validation
97
- const aliases = [endpoint.name, ...(endpoint.aliases || [])];
98
- for (const alias of aliases) {
99
- if (endpointsMap[alias]) {
100
- throw new Error(`Duplicate endpoint / alias: "${alias}"`);
74
+ /**
75
+ * This function will take an adapter structure and go through each endpoint, calculating
76
+ * each one's allocation of the total rate limits that are set for the adapter as a whole.
77
+ *
78
+ */
79
+ calculateRateLimitAllocations() {
80
+ const numberOfEndpoints = this.endpoints.length;
81
+ const endpointsWithExplicitAllocations = this.endpoints.filter((e) => e.rateLimiting);
82
+ const totalExplicitAllocation = endpointsWithExplicitAllocations
83
+ .map((e) => e.rateLimiting?.allocationPercentage || 0)
84
+ .reduce((sum, next) => sum + next, 0);
85
+ if (totalExplicitAllocation > 100) {
86
+ throw new Error('The total allocation set for all endpoints summed cannot exceed 100%');
87
+ }
88
+ if (totalExplicitAllocation === 100 &&
89
+ numberOfEndpoints - endpointsWithExplicitAllocations.length > 0) {
90
+ throw new Error('The explicit allocation is at 100% but there are endpoints with implicit allocation');
91
+ }
92
+ const implicitAllocation = 100 - totalExplicitAllocation;
93
+ logger.debug('Adapter rate limit allocations:');
94
+ for (const endpoint of this.endpoints) {
95
+ if (!endpoint.rateLimiting) {
96
+ endpoint.rateLimiting = {
97
+ allocationPercentage: implicitAllocation / (numberOfEndpoints - endpointsWithExplicitAllocations.length),
98
+ };
101
99
  }
102
- endpointsMap[alias] = endpoint;
100
+ logger.debug(`Endpoint [${endpoint.name}] - ${endpoint.rateLimiting?.allocationPercentage}%`);
101
+ }
102
+ }
103
+ /**
104
+ * This function will process dependencies for an adapter, such as caches or rate limiters,
105
+ * in order to inject them into transports and other relevant places later in the lifecycle.
106
+ *
107
+ * @param inputDependencies - a partial obj of initialized dependencies to override the created ones
108
+ * @returns a set of AdapterDependencies all initialized
109
+ */
110
+ initializeDependencies(inputDependencies) {
111
+ const dependencies = inputDependencies || {};
112
+ if (!dependencies.cache) {
113
+ dependencies.cache = cache_1.CacheFactory.buildCache(this.config);
114
+ }
115
+ const rateLimitingTier = (0, rate_limiting_1.getRateLimitingTier)(this.config, this.rateLimiting?.tiers);
116
+ if (!dependencies.requestRateLimiter) {
117
+ dependencies.requestRateLimiter = new rate_limiting_1.SimpleCountingRateLimiter().initialize(this.endpoints, rateLimitingTier);
118
+ }
119
+ if (!dependencies.backgroundExecuteRateLimiter) {
120
+ dependencies.backgroundExecuteRateLimiter = new rate_limiting_1.FixedFrequencyRateLimiter().initialize(this.endpoints, rateLimitingTier);
121
+ }
122
+ if (!dependencies.subscriptionSetFactory) {
123
+ dependencies.subscriptionSetFactory = new util_1.SubscriptionSetFactory(this.config);
103
124
  }
104
- logger.debug(`Initializing transport for endpoint "${endpoint.name}"...`);
105
- await endpoint.transport.initialize(initializedDependencies);
125
+ return dependencies;
106
126
  }
107
- logger.debug('Adapter initialization complete.');
108
- return {
109
- ...adapter,
110
- endpointsMap,
111
- dependencies: initializedDependencies,
112
- config,
113
- };
114
- };
115
- exports.initializeAdapter = initializeAdapter;
127
+ }
128
+ exports.Adapter = Adapter;
package/cache/factory.js CHANGED
@@ -44,6 +44,9 @@ class CacheFactory {
44
44
  enableAutoPipelining: true,
45
45
  host: config.CACHE_REDIS_HOST,
46
46
  port: config.CACHE_REDIS_PORT,
47
+ password: config.CACHE_REDIS_PASSWORD,
48
+ path: config.CACHE_REDIS_PATH,
49
+ timeout: config.CACHE_REDIS_TIMEOUT,
47
50
  });
48
51
  redis.on('connect', () => {
49
52
  cacheMetrics.redisConnectionsOpen.inc();
package/config/index.js CHANGED
@@ -4,34 +4,33 @@ Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.buildAdapterConfig = exports.BaseSettings = void 0;
5
5
  exports.BaseSettings = {
6
6
  // V2 compat
7
- // TODO: Remove non used in v3 ones
7
+ // ADAPTER_URL: {
8
+ // description: 'The URL of another adapter from which data needs to be retrieved',
9
+ // type: 'string',
10
+ // },
8
11
  API_ENDPOINT: {
9
- description: 'The URL that the certain transports use to retrieve data',
12
+ description: 'The URL that certain transports use to retrieve data',
10
13
  type: 'string',
11
14
  },
12
15
  API_KEY: {
13
16
  description: 'Default setting for an EA key',
14
17
  type: 'string',
15
18
  },
16
- // API_TIMEOUT: {
17
- // type: 'number',
18
- // default: 30000,
19
- // },
20
- // API_VERBOSE: {
21
- // type: 'boolean',
22
- // },
19
+ API_TIMEOUT: {
20
+ description: 'The number of milliseconds a request can be pending before returning a timeout error for data provider request',
21
+ type: 'number',
22
+ default: 30000,
23
+ },
24
+ API_VERBOSE: {
25
+ description: 'Toggle whether the response from the EA should contain just the results or also include the full response body from the queried API.',
26
+ type: 'boolean',
27
+ default: false,
28
+ },
23
29
  BASE_URL: {
24
30
  description: 'Starting path for the EA handler endpoint',
25
31
  type: 'string',
26
32
  default: '/',
27
33
  },
28
- // CACHE_ENABLED: {
29
- // type: 'boolean',
30
- // default: true,
31
- // },
32
- // CACHE_KEY_GROUP: {
33
- // type: 'string',
34
- // },
35
34
  CACHE_MAX_AGE: {
36
35
  description: 'Maximum amount of time (in ms) that a response will stay cached',
37
36
  type: 'number',
@@ -55,28 +54,32 @@ exports.BaseSettings = {
55
54
  default: '127.0.0.1',
56
55
  },
57
56
  // CACHE_REDIS_MAX_QUEUED_ITEMS: {
57
+ // description: 'Maximum length of the client internal command queue',
58
58
  // type: 'number',
59
- // default: 100,
59
+ // default: 500,
60
60
  // },
61
61
  // CACHE_REDIS_MAX_RECONNECT_COOLDOWN: {
62
62
  // type: 'number',
63
63
  // default: 3000,
64
64
  // },
65
- // CACHE_REDIS_PASSWORD: {
66
- // type: 'string',
67
- // },
68
- // CACHE_REDIS_PATH: {
69
- // type: 'string',
70
- // },
65
+ CACHE_REDIS_PASSWORD: {
66
+ description: 'The password required for redis auth',
67
+ type: 'string',
68
+ },
69
+ CACHE_REDIS_PATH: {
70
+ description: 'The UNIX socket string of the Redis server',
71
+ type: 'string',
72
+ },
71
73
  CACHE_REDIS_PORT: {
72
74
  description: 'Port for the Redis instance to be used',
73
75
  type: 'number',
74
76
  default: 6379,
75
77
  },
76
- // CACHE_REDIS_TIMEOUT: {
77
- // type: 'number',
78
- // default: 500,
79
- // },
78
+ CACHE_REDIS_TIMEOUT: {
79
+ description: 'Timeout to fail a Redis server request if no response (ms)',
80
+ type: 'number',
81
+ default: 500,
82
+ },
80
83
  // CACHE_REDIS_URL: {
81
84
  // type: 'string',
82
85
  // },
@@ -86,30 +89,25 @@ exports.BaseSettings = {
86
89
  default: 'local',
87
90
  options: ['local', 'redis'],
88
91
  },
89
- // CACHE_UPDATE_AGE_ON_GET: {
90
- // type: 'boolean',
91
- // default: false,
92
- // },
93
92
  CORRELATION_ID_ENABLED: {
94
93
  description: 'Flag to enable correlation IDs for sent requests in logging',
95
94
  type: 'boolean',
96
95
  default: true,
97
96
  },
98
- // DEBUG: {
99
- // type: 'boolean',
100
- // },
101
- // DEFAULT_WS_HEARTBEAT_INTERVAL: {
102
- // type: 'number',
103
- // default: 30000,
97
+ // DATA_PROVIDER_URL: {
98
+ // description: 'Legacy variable that has the same functionality as ADAPTER_URL',
99
+ // type: 'string',
104
100
  // },
101
+ DEBUG: {
102
+ description: 'Toggles debug mode',
103
+ type: 'boolean',
104
+ default: false,
105
+ },
105
106
  EA_PORT: {
106
107
  description: 'Port through which the EA will listen for REST requests (if mode is set to "reader" or "reader-writer")',
107
108
  type: 'number',
108
109
  default: 8080,
109
110
  },
110
- // ENV_ADAPTER_URL: {
111
- // type: 'string',
112
- // },
113
111
  // ERROR_CAPACITY: {
114
112
  // type: 'number',
115
113
  // },
@@ -118,9 +116,6 @@ exports.BaseSettings = {
118
116
  type: 'boolean',
119
117
  default: true,
120
118
  },
121
- // LEGACY_ENV_ADAPTER_URL: {
122
- // type: 'string',
123
- // },
124
119
  LOG_LEVEL: {
125
120
  description: 'Minimum level required for logs to be output',
126
121
  type: 'string',
@@ -148,25 +143,22 @@ exports.BaseSettings = {
148
143
  description: 'Rate limiting tier to use from the available options for the adapter. If not present, the adapter will run using the first tier on the list.',
149
144
  type: 'string',
150
145
  },
151
- // RATE_LIMIT_CAPACITY_MINUTE: {
152
- // type: 'number',
153
- // },
154
- // RATE_LIMIT_CAPACITY_SECOND: {
155
- // type: 'number',
156
- // },
157
- // RATE_LIMIT_CAPACITY: {
158
- // type: 'number',
159
- // },
160
- // RATE_LIMIT_ENABLED: {
161
- // type: 'boolean',
162
- // default: true,
163
- // },
164
- // RECORD: {
165
- // type: 'boolean',
166
- // },
167
- // REQUEST_COALESCING_ENABLED: {
168
- // type: 'boolean',
169
- // },
146
+ RATE_LIMIT_CAPACITY: {
147
+ description: 'Used as rate limit capacity per minute and ignores tier settings if defined',
148
+ type: 'number',
149
+ },
150
+ RATE_LIMIT_CAPACITY_MINUTE: {
151
+ description: 'Used as rate limit capacity per minute and ignores tier settings if defined. Supercedes RATE_LIMIT_CAPACITY if both vars are set',
152
+ type: 'number',
153
+ },
154
+ RATE_LIMIT_CAPACITY_SECOND: {
155
+ description: 'Used as rate limit capacity per second and ignores tier settings if defined',
156
+ type: 'number',
157
+ },
158
+ REQUEST_COALESCING_ENABLED: {
159
+ description: 'Enable request coalescing',
160
+ type: 'boolean',
161
+ },
170
162
  // REQUEST_COALESCING_ENTROPY_MAX: {
171
163
  // type: 'number',
172
164
  // default: 0,
@@ -203,9 +195,6 @@ exports.BaseSettings = {
203
195
  // type: 'number',
204
196
  // default: 500,
205
197
  // },
206
- // TIMEOUT: {
207
- // type: 'number',
208
- // },
209
198
  // WARMUP_ENABLED: {
210
199
  // type: 'boolean',
211
200
  // default: true,
@@ -259,10 +248,11 @@ exports.BaseSettings = {
259
248
  // WS_SUBSCRIPTION_PRIORITY_LIST: {
260
249
  // type: 'string',
261
250
  // },
262
- // WS_SUBSCRIPTION_TTL: {
263
- // type: 'number',
264
- // default: 120000,
265
- // },
251
+ WS_SUBSCRIPTION_TTL: {
252
+ description: '',
253
+ type: 'number',
254
+ default: 120000,
255
+ },
266
256
  // WS_SUBSCRIPTION_UNRESPONSIVE_TTL: {
267
257
  // type: 'number',
268
258
  // default: false,
@@ -297,16 +287,6 @@ exports.BaseSettings = {
297
287
  default: 'reader-writer',
298
288
  options: ['reader', 'writer', 'reader-writer'],
299
289
  },
300
- REST_TRANSPORT_MAX_RATE_LIMIT_RETRIES: {
301
- description: 'Maximum amount of times the Rest Transport will attempt to set up a request when blocked by the rate limiter',
302
- type: 'number',
303
- default: 3,
304
- },
305
- REST_TRANSPORT_MS_BETWEEN_RATE_LIMIT_RETRIES: {
306
- description: 'Time that the Rest Transport will wait between retries when blocked by the rate limiter',
307
- type: 'number',
308
- default: 400,
309
- },
310
290
  MAX_COMMON_KEY_SIZE: {
311
291
  description: 'Maximum amount of characters that the common part of the cache key or feed ID can have',
312
292
  type: 'number',
@@ -317,10 +297,16 @@ exports.BaseSettings = {
317
297
  }
318
298
  },
319
299
  },
320
- // CACHE_KEY_IGNORED_PROPS : {
321
- // description: 'Properties to ignore when generating a feed ID for requests',
322
- // type: 'string'
323
- // }
300
+ REST_TRANSPORT_MAX_RATE_LIMIT_RETRIES: {
301
+ description: 'Maximum amount of times the Rest Transport will attempt to set up a request when blocked by the rate limiter',
302
+ type: 'number',
303
+ default: 3,
304
+ },
305
+ REST_TRANSPORT_MS_BETWEEN_RATE_LIMIT_RETRIES: {
306
+ description: 'Time that the Rest Transport will wait between retries when blocked by the rate limiter',
307
+ type: 'number',
308
+ default: 400,
309
+ },
324
310
  SMOKE_TEST_PAYLOAD_FILE_NAME: {
325
311
  description: 'Name of the test payload file used for the smoke endpoint',
326
312
  type: 'string',
@@ -41,22 +41,17 @@ const getProviderLimits = (provider, limits, tier, protocol) => {
41
41
  }
42
42
  return limitsConfig;
43
43
  };
44
+ const objectKeysToLowercase = (obj) => {
45
+ const lower = {};
46
+ for (const key in obj) {
47
+ lower[key.toLowerCase()] = obj[key];
48
+ }
49
+ return lower;
50
+ };
44
51
  const parseLimits = (limits) => {
45
- const _mapObject = (fn) => (o) => {
46
- const entries = Object.entries(o);
47
- const mapped = entries.map(fn);
48
- return Object.fromEntries(mapped);
49
- };
50
- const _formatProtocol = _mapObject((entry) => {
51
- const [tierName, rest] = entry;
52
- return [tierName.toLowerCase(), { ...rest }];
53
- });
54
- const _formatProvider = (ls) => {
55
- const http = _formatProtocol(ls.http);
56
- const ws = _formatProtocol(ls?.ws);
57
- return { http, ws };
58
- };
59
- return _formatProvider(limits);
52
+ limits.http = objectKeysToLowercase(limits.http);
53
+ limits.ws = objectKeysToLowercase(limits.ws);
54
+ return limits;
60
55
  };
61
56
  const calculateWSLimits = (providerLimit) => {
62
57
  return {
@@ -8,6 +8,7 @@ const axios_1 = __importDefault(require("axios"));
8
8
  const util_1 = require("./util");
9
9
  const util_2 = require("../../util");
10
10
  const error_1 = require("../../validation/error");
11
+ const adapter_1 = require("../../adapter");
11
12
  const logger = (0, util_2.makeLogger)('BankFrickTransport');
12
13
  // Note: this is a shallow pattern that only checks for a country code since IBANs in the sandbox are invalid
13
14
  const ibanPattern = /^[A-Z]{2}[A-Z\d]{14,30}$/;
@@ -184,8 +185,8 @@ class BankFrickAccountsTransport {
184
185
  }
185
186
  }
186
187
  exports.BankFrickAccountsTransport = BankFrickAccountsTransport;
187
- exports.accountsRestEndpoint = {
188
+ exports.accountsRestEndpoint = new adapter_1.AdapterEndpoint({
188
189
  name: 'accounts',
189
190
  transport: new BankFrickAccountsTransport(),
190
191
  inputParameters,
191
- };
192
+ });
@@ -1,9 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.adapter = void 0;
4
+ const adapter_1 = require("../../adapter");
4
5
  const accounts_1 = require("./accounts");
5
6
  const config_1 = require("./config");
6
- exports.adapter = {
7
+ exports.adapter = new adapter_1.Adapter({
7
8
  name: 'bank-frick',
8
9
  defaultEndpoint: 'accounts',
9
10
  endpoints: [accounts_1.accountsRestEndpoint],
@@ -11,4 +12,4 @@ exports.adapter = {
11
12
  envDefaultOverrides: {
12
13
  API_ENDPOINT: 'https://olbsandbox.bankfrick.li/webapi/v2',
13
14
  },
14
- };
15
+ });
@@ -0,0 +1,13 @@
1
+ "use strict";
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';
6
+ exports.DEFAULT_API_ENDPOINT = 'https://api.coingecko.com/api/v3';
7
+ 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
+ };