@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.
- package/adapter.js +114 -101
- package/cache/factory.js +3 -0
- package/chainlink-external-adapter-framework-v0.0.6.tgz +0 -0
- package/config/index.js +69 -83
- package/config/provider-limits.js +10 -15
- package/examples/bank-frick/accounts.js +3 -2
- package/examples/bank-frick/index.js +3 -2
- package/examples/coingecko/src/config/index.js +13 -0
- package/examples/coingecko/src/config/overrides.json +10826 -0
- package/examples/coingecko/src/cryptoUtils.js +41 -0
- package/examples/coingecko/src/endpoint/coins.js +33 -0
- package/examples/coingecko/src/endpoint/crypto-marketcap.js +46 -0
- package/examples/coingecko/src/endpoint/crypto-volume.js +46 -0
- package/examples/coingecko/src/endpoint/crypto.js +47 -0
- package/examples/coingecko/src/endpoint/dominance.js +26 -0
- package/examples/coingecko/src/endpoint/global-marketcap.js +26 -0
- package/examples/coingecko/src/endpoint/index.js +15 -0
- package/examples/coingecko/src/globalUtils.js +48 -0
- package/examples/coingecko/src/index.js +14 -0
- package/examples/coingecko/test/e2e/adapter.test.js +262 -0
- package/examples/coingecko/test/integration/adapter.test.js +264 -0
- package/examples/coingecko/test/integration/capturedRequests.json +1 -0
- package/examples/coingecko/test/integration/fixtures.js +41 -0
- package/{package/examples/coingecko → examples/coingecko-old}/batch-warming.js +4 -3
- package/examples/{coingecko → coingecko-old}/index.js +3 -2
- package/{package/examples/coingecko → examples/coingecko-old}/rest.js +3 -2
- package/examples/ncfx/index.js +3 -2
- package/examples/ncfx/websocket.js +3 -2
- package/index.js +17 -23
- package/package.json +5 -4
- package/rate-limiting/index.js +23 -2
- package/transports/batch-warming.js +1 -1
- package/transports/rest.js +9 -2
- package/transports/util.js +2 -1
- package/transports/websocket.js +4 -6
- package/util/recordRequests.js +45 -0
- package/{package/validation/override-functions.js → validation/overrideFunctions.js} +0 -0
- package/adapter.d.ts +0 -107
- package/background-executor.d.ts +0 -11
- package/cache/factory.d.ts +0 -6
- package/cache/index.d.ts +0 -94
- package/cache/local.d.ts +0 -23
- package/cache/metrics.d.ts +0 -27
- package/cache/redis.d.ts +0 -16
- package/chainlink-external-adapter-framework-0.0.6.tgz +0 -0
- package/config/index.d.ts +0 -209
- package/config/provider-limits.d.ts +0 -31
- package/examples/bank-frick/accounts.d.ts +0 -39
- package/examples/bank-frick/config/index.d.ts +0 -4
- package/examples/bank-frick/index.d.ts +0 -2
- package/examples/bank-frick/util.d.ts +0 -4
- package/examples/coingecko/batch-warming.d.ts +0 -2
- package/examples/coingecko/batch-warming.js +0 -52
- package/examples/coingecko/index.d.ts +0 -2
- package/examples/coingecko/rest.d.ts +0 -2
- package/examples/coingecko/rest.js +0 -50
- package/examples/ncfx/config/index.d.ts +0 -12
- package/examples/ncfx/index.d.ts +0 -2
- package/examples/ncfx/websocket.d.ts +0 -36
- package/index.d.ts +0 -11
- package/metrics/constants.d.ts +0 -16
- package/metrics/index.d.ts +0 -15
- package/metrics/util.d.ts +0 -7
- package/package/adapter.d.ts +0 -88
- package/package/adapter.js +0 -112
- package/package/background-executor.d.ts +0 -11
- package/package/background-executor.js +0 -45
- package/package/cache/factory.d.ts +0 -6
- package/package/cache/factory.js +0 -57
- package/package/cache/index.d.ts +0 -90
- package/package/cache/index.js +0 -169
- package/package/cache/local.d.ts +0 -23
- package/package/cache/local.js +0 -83
- package/package/cache/metrics.d.ts +0 -27
- package/package/cache/metrics.js +0 -120
- package/package/cache/redis.d.ts +0 -16
- package/package/cache/redis.js +0 -100
- package/package/config/index.d.ts +0 -195
- package/package/config/index.js +0 -365
- package/package/config/provider-limits.d.ts +0 -31
- package/package/config/provider-limits.js +0 -76
- package/package/examples/coingecko/batch-warming.d.ts +0 -2
- package/package/examples/coingecko/index.d.ts +0 -2
- package/package/examples/coingecko/index.js +0 -10
- package/package/examples/coingecko/rest.d.ts +0 -2
- package/package/examples/ncfx/config/index.d.ts +0 -12
- package/package/examples/ncfx/config/index.js +0 -15
- package/package/examples/ncfx/index.d.ts +0 -2
- package/package/examples/ncfx/index.js +0 -10
- package/package/examples/ncfx/websocket.d.ts +0 -36
- package/package/examples/ncfx/websocket.js +0 -72
- package/package/index.d.ts +0 -12
- package/package/index.js +0 -92
- package/package/metrics/constants.d.ts +0 -16
- package/package/metrics/constants.js +0 -25
- package/package/metrics/index.d.ts +0 -15
- package/package/metrics/index.js +0 -123
- package/package/metrics/util.d.ts +0 -3
- package/package/metrics/util.js +0 -9
- package/package/package.json +0 -72
- package/package/rate-limiting/background/fixed-frequency.d.ts +0 -10
- package/package/rate-limiting/background/fixed-frequency.js +0 -37
- package/package/rate-limiting/index.d.ts +0 -54
- package/package/rate-limiting/index.js +0 -63
- package/package/rate-limiting/metrics.d.ts +0 -3
- package/package/rate-limiting/metrics.js +0 -44
- package/package/rate-limiting/request/simple-counting.d.ts +0 -20
- package/package/rate-limiting/request/simple-counting.js +0 -62
- package/package/test.d.ts +0 -1
- package/package/test.js +0 -6
- package/package/transports/batch-warming.d.ts +0 -34
- package/package/transports/batch-warming.js +0 -101
- package/package/transports/index.d.ts +0 -87
- package/package/transports/index.js +0 -87
- package/package/transports/metrics.d.ts +0 -21
- package/package/transports/metrics.js +0 -105
- package/package/transports/rest.d.ts +0 -43
- package/package/transports/rest.js +0 -129
- package/package/transports/util.d.ts +0 -8
- package/package/transports/util.js +0 -85
- package/package/transports/websocket.d.ts +0 -80
- package/package/transports/websocket.js +0 -169
- package/package/util/expiring-sorted-set.d.ts +0 -21
- package/package/util/expiring-sorted-set.js +0 -47
- package/package/util/index.d.ts +0 -11
- package/package/util/index.js +0 -35
- package/package/util/logger.d.ts +0 -42
- package/package/util/logger.js +0 -62
- package/package/util/request.d.ts +0 -55
- package/package/util/request.js +0 -2
- package/package/validation/error.d.ts +0 -50
- package/package/validation/error.js +0 -79
- package/package/validation/index.d.ts +0 -5
- package/package/validation/index.js +0 -86
- package/package/validation/input-params.d.ts +0 -15
- package/package/validation/input-params.js +0 -30
- package/package/validation/override-functions.d.ts +0 -3
- package/package/validation/preset-tokens.json +0 -23
- package/package/validation/validator.d.ts +0 -47
- package/package/validation/validator.js +0 -303
- package/rate-limiting/background/fixed-frequency.d.ts +0 -10
- package/rate-limiting/index.d.ts +0 -54
- package/rate-limiting/metrics.d.ts +0 -3
- package/rate-limiting/request/simple-counting.d.ts +0 -20
- package/test.d.ts +0 -1
- package/transports/batch-warming.d.ts +0 -35
- package/transports/index.d.ts +0 -70
- package/transports/metrics.d.ts +0 -21
- package/transports/rest.d.ts +0 -44
- package/transports/util.d.ts +0 -8
- package/transports/websocket.d.ts +0 -81
- package/util/expiring-sorted-set.d.ts +0 -21
- package/util/expiring-sorted-set.js +0 -47
- package/util/index.d.ts +0 -12
- package/util/logger.d.ts +0 -42
- package/util/request.d.ts +0 -57
- package/util/subscription-set/expiring-sorted-set.d.ts +0 -22
- package/util/subscription-set/subscription-set.d.ts +0 -18
- package/util/test-payload-loader.d.ts +0 -25
- package/validation/error.d.ts +0 -50
- package/validation/index.d.ts +0 -5
- package/validation/input-params.d.ts +0 -15
- package/validation/override-functions.d.ts +0 -3
- 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.
|
|
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
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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
|
-
|
|
24
|
-
|
|
25
|
-
|
|
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
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
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
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
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
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
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
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
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
|
-
|
|
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
|
-
|
|
105
|
-
await endpoint.transport.initialize(initializedDependencies);
|
|
125
|
+
return dependencies;
|
|
106
126
|
}
|
|
107
|
-
|
|
108
|
-
|
|
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();
|
|
Binary file
|
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
|
-
//
|
|
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
|
|
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
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
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:
|
|
59
|
+
// default: 500,
|
|
60
60
|
// },
|
|
61
61
|
// CACHE_REDIS_MAX_RECONNECT_COOLDOWN: {
|
|
62
62
|
// type: 'number',
|
|
63
63
|
// default: 3000,
|
|
64
64
|
// },
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
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
|
-
|
|
77
|
-
|
|
78
|
-
|
|
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
|
-
//
|
|
99
|
-
//
|
|
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
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
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
|
-
|
|
263
|
-
|
|
264
|
-
|
|
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
|
-
|
|
321
|
-
|
|
322
|
-
|
|
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
|
-
|
|
46
|
-
|
|
47
|
-
|
|
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
|
+
};
|