@chainlink/external-adapter-framework 0.4.0 → 0.5.1
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/basic.d.ts +90 -0
- package/adapter/basic.js +325 -0
- package/adapter/basic.js.map +1 -0
- package/adapter/endpoint.d.ts +17 -0
- package/adapter/endpoint.js +20 -0
- package/adapter/endpoint.js.map +1 -0
- package/adapter/index.d.ts +4 -0
- package/adapter/index.js +21 -0
- package/adapter/index.js.map +1 -0
- package/adapter/price.d.ts +77 -0
- package/adapter/price.js +88 -0
- package/adapter/price.js.map +1 -0
- package/adapter/types.d.ts +124 -0
- package/adapter/types.js +3 -0
- package/adapter/types.js.map +1 -0
- package/background-executor.d.ts +9 -0
- package/background-executor.js +97 -0
- package/background-executor.js.map +1 -0
- package/cache/factory.d.ts +6 -0
- package/cache/factory.js +24 -0
- package/cache/factory.js.map +1 -0
- package/cache/index.d.ts +87 -0
- package/cache/index.js +133 -0
- package/cache/index.js.map +1 -0
- package/cache/local.d.ts +23 -0
- package/cache/local.js +84 -0
- package/cache/local.js.map +1 -0
- package/cache/metrics.d.ts +27 -0
- package/cache/metrics.js +121 -0
- package/cache/metrics.js.map +1 -0
- package/cache/redis.d.ts +16 -0
- package/cache/redis.js +101 -0
- package/cache/redis.js.map +1 -0
- package/config/index.d.ts +298 -0
- package/config/index.js +359 -0
- package/config/index.js.map +1 -0
- package/config/provider-limits.d.ts +27 -0
- package/config/provider-limits.js +75 -0
- package/config/provider-limits.js.map +1 -0
- package/examples/bank-frick/accounts.d.ts +45 -0
- package/examples/bank-frick/accounts.js +203 -0
- package/examples/bank-frick/accounts.js.map +1 -0
- package/examples/bank-frick/config/index.d.ts +17 -0
- package/examples/bank-frick/config/index.js +55 -0
- package/examples/bank-frick/config/index.js.map +1 -0
- package/examples/bank-frick/index.d.ts +2 -0
- package/examples/bank-frick/index.js +16 -0
- package/examples/bank-frick/index.js.map +1 -0
- package/examples/bank-frick/util.d.ts +4 -0
- package/examples/bank-frick/util.js +40 -0
- package/examples/bank-frick/util.js.map +1 -0
- package/examples/coingecko/src/config/index.d.ts +2 -0
- package/examples/coingecko/src/config/index.js +6 -0
- package/examples/coingecko/src/config/index.js.map +1 -0
- package/examples/coingecko/src/config/overrides.json +10825 -0
- package/examples/coingecko/src/crypto-utils.d.ts +62 -0
- package/examples/coingecko/src/crypto-utils.js +60 -0
- package/examples/coingecko/src/crypto-utils.js.map +1 -0
- package/examples/coingecko/src/endpoint/coins.d.ts +26 -0
- package/examples/coingecko/src/endpoint/coins.js +37 -0
- package/examples/coingecko/src/endpoint/coins.js.map +1 -0
- package/examples/coingecko/src/endpoint/crypto-marketcap.d.ts +3 -0
- package/examples/coingecko/src/endpoint/crypto-marketcap.js +30 -0
- package/examples/coingecko/src/endpoint/crypto-marketcap.js.map +1 -0
- package/examples/coingecko/src/endpoint/crypto-volume.d.ts +3 -0
- package/examples/coingecko/src/endpoint/crypto-volume.js +30 -0
- package/examples/coingecko/src/endpoint/crypto-volume.js.map +1 -0
- package/examples/coingecko/src/endpoint/crypto.d.ts +3 -0
- package/examples/coingecko/src/endpoint/crypto.js +28 -0
- package/examples/coingecko/src/endpoint/crypto.js.map +1 -0
- package/examples/coingecko/src/endpoint/dominance.d.ts +3 -0
- package/examples/coingecko/src/endpoint/dominance.js +28 -0
- package/examples/coingecko/src/endpoint/dominance.js.map +1 -0
- package/examples/coingecko/src/endpoint/global-marketcap.d.ts +3 -0
- package/examples/coingecko/src/endpoint/global-marketcap.js +28 -0
- package/examples/coingecko/src/endpoint/global-marketcap.js.map +1 -0
- package/examples/coingecko/src/endpoint/index.d.ts +6 -0
- package/examples/coingecko/src/endpoint/index.js +16 -0
- package/examples/coingecko/src/endpoint/index.js.map +1 -0
- package/examples/coingecko/src/global-utils.d.ts +42 -0
- package/examples/coingecko/src/global-utils.js +47 -0
- package/examples/coingecko/src/global-utils.js.map +1 -0
- package/examples/coingecko/src/index.d.ts +4 -0
- package/examples/coingecko/src/index.js +19 -0
- package/examples/coingecko/src/index.js.map +1 -0
- package/examples/coingecko-old/batch-warming.d.ts +7 -0
- package/examples/coingecko-old/batch-warming.js +54 -0
- package/examples/coingecko-old/batch-warming.js.map +1 -0
- package/examples/coingecko-old/index.d.ts +2 -0
- package/examples/coingecko-old/index.js +12 -0
- package/examples/coingecko-old/index.js.map +1 -0
- package/examples/coingecko-old/rest.d.ts +12 -0
- package/examples/coingecko-old/rest.js +55 -0
- package/examples/coingecko-old/rest.js.map +1 -0
- package/examples/cryptocompare/src/config/index.d.ts +2 -0
- package/examples/cryptocompare/src/config/index.js +6 -0
- package/examples/cryptocompare/src/config/index.js.map +1 -0
- package/examples/cryptocompare/src/endpoints/crypto.d.ts +40 -0
- package/examples/cryptocompare/src/endpoints/crypto.js +54 -0
- package/examples/cryptocompare/src/endpoints/crypto.js.map +1 -0
- package/examples/cryptocompare/src/endpoints/index.d.ts +1 -0
- package/examples/cryptocompare/src/endpoints/index.js +6 -0
- package/examples/cryptocompare/src/endpoints/index.js.map +1 -0
- package/examples/cryptocompare/src/index.d.ts +4 -0
- package/examples/cryptocompare/src/index.js +14 -0
- package/examples/cryptocompare/src/index.js.map +1 -0
- package/examples/genesis/config/index.d.ts +7 -0
- package/examples/genesis/config/index.js +11 -0
- package/examples/genesis/config/index.js.map +1 -0
- package/examples/genesis/index.d.ts +2 -0
- package/examples/genesis/index.js +13 -0
- package/examples/genesis/index.js.map +1 -0
- package/examples/genesis/sseStream.d.ts +27 -0
- package/examples/genesis/sseStream.js +149 -0
- package/examples/genesis/sseStream.js.map +1 -0
- package/examples/ncfx/config/index.d.ts +12 -0
- package/examples/ncfx/config/index.js +16 -0
- package/examples/ncfx/config/index.js.map +1 -0
- package/examples/ncfx/index.d.ts +2 -0
- package/examples/ncfx/index.js +12 -0
- package/examples/ncfx/index.js.map +1 -0
- package/examples/ncfx/websocket.d.ts +37 -0
- package/examples/ncfx/websocket.js +74 -0
- package/examples/ncfx/websocket.js.map +1 -0
- package/index.d.ts +17 -0
- package/index.js +174 -0
- package/index.js.map +1 -0
- package/metrics/constants.d.ts +16 -0
- package/metrics/constants.js +26 -0
- package/metrics/constants.js.map +1 -0
- package/metrics/index.d.ts +19 -0
- package/metrics/index.js +139 -0
- package/metrics/index.js.map +1 -0
- package/metrics/util.d.ts +7 -0
- package/metrics/util.js +10 -0
- package/metrics/util.js.map +1 -0
- package/package.json +50 -42
- package/rate-limiting/background/fixed-frequency.d.ts +10 -0
- package/rate-limiting/background/fixed-frequency.js +36 -0
- package/rate-limiting/background/fixed-frequency.js.map +1 -0
- package/rate-limiting/index.d.ts +56 -0
- package/rate-limiting/index.js +86 -0
- package/rate-limiting/index.js.map +1 -0
- package/rate-limiting/metrics.d.ts +3 -0
- package/rate-limiting/metrics.js +45 -0
- package/rate-limiting/metrics.js.map +1 -0
- package/rate-limiting/request/simple-counting.d.ts +20 -0
- package/rate-limiting/request/simple-counting.js +63 -0
- package/rate-limiting/request/simple-counting.js.map +1 -0
- package/transports/batch-warming.d.ts +53 -0
- package/transports/batch-warming.js +136 -0
- package/transports/batch-warming.js.map +1 -0
- package/transports/index.d.ts +108 -0
- package/transports/index.js +56 -0
- package/transports/index.js.map +1 -0
- package/transports/inference-test.d.ts +0 -0
- package/transports/inference-test.js +202 -0
- package/transports/inference-test.js.map +1 -0
- package/transports/metrics.d.ts +25 -0
- package/transports/metrics.js +122 -0
- package/transports/metrics.js.map +1 -0
- package/transports/rest.d.ts +68 -0
- package/transports/rest.js +131 -0
- package/transports/rest.js.map +1 -0
- package/transports/routing.d.ts +21 -0
- package/transports/routing.js +50 -0
- package/transports/routing.js.map +1 -0
- package/transports/sse.d.ts +61 -0
- package/transports/sse.js +97 -0
- package/transports/sse.js.map +1 -0
- package/transports/util.d.ts +9 -0
- package/transports/util.js +87 -0
- package/transports/util.js.map +1 -0
- package/transports/websocket.d.ts +95 -0
- package/transports/websocket.js +164 -0
- package/transports/websocket.js.map +1 -0
- package/util/censor/censor-list.d.ts +9 -0
- package/util/censor/censor-list.js +13 -0
- package/util/censor/censor-list.js.map +1 -0
- package/util/index.d.ts +13 -0
- package/util/index.js +38 -0
- package/util/index.js.map +1 -0
- package/util/logger.d.ts +49 -0
- package/util/logger.js +123 -0
- package/util/logger.js.map +1 -0
- package/util/request.d.ts +138 -0
- package/util/request.js +3 -0
- package/util/request.js.map +1 -0
- package/util/subscription-set/expiring-sorted-set.d.ts +21 -0
- package/util/subscription-set/expiring-sorted-set.js +36 -0
- package/util/subscription-set/expiring-sorted-set.js.map +1 -0
- package/util/subscription-set/redis-sorted-set.d.ts +9 -0
- package/util/subscription-set/redis-sorted-set.js +29 -0
- package/util/subscription-set/redis-sorted-set.js.map +1 -0
- package/util/subscription-set/subscription-set.d.ts +19 -0
- package/util/subscription-set/subscription-set.js +28 -0
- package/util/subscription-set/subscription-set.js.map +1 -0
- package/util/test-payload-loader.d.ts +26 -0
- package/util/test-payload-loader.js +85 -0
- package/util/test-payload-loader.js.map +1 -0
- package/validation/error.d.ts +48 -0
- package/validation/error.js +78 -0
- package/validation/error.js.map +1 -0
- package/validation/index.d.ts +5 -0
- package/validation/index.js +102 -0
- package/validation/index.js.map +1 -0
- package/validation/input-params.d.ts +14 -0
- package/validation/input-params.js +3 -0
- package/validation/input-params.js.map +1 -0
- package/validation/input-validator.d.ts +16 -0
- package/validation/input-validator.js +123 -0
- package/validation/input-validator.js.map +1 -0
- package/README.md +0 -102
package/config/index.js
ADDED
|
@@ -0,0 +1,359 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.validateAdapterConfig = exports.buildAdapterConfig = exports.BaseSettings = void 0;
|
|
4
|
+
exports.BaseSettings = {
|
|
5
|
+
// V2 compat
|
|
6
|
+
// ADAPTER_URL: {
|
|
7
|
+
// description: 'The URL of another adapter from which data needs to be retrieved',
|
|
8
|
+
// type: 'string',
|
|
9
|
+
// },
|
|
10
|
+
API_ENDPOINT: {
|
|
11
|
+
description: 'The URL that certain transports use to retrieve data',
|
|
12
|
+
type: 'string',
|
|
13
|
+
},
|
|
14
|
+
API_KEY: {
|
|
15
|
+
description: 'Default setting for an EA key',
|
|
16
|
+
type: 'string',
|
|
17
|
+
sensitive: true,
|
|
18
|
+
},
|
|
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
|
+
},
|
|
29
|
+
BASE_URL: {
|
|
30
|
+
description: 'Starting path for the EA handler endpoint',
|
|
31
|
+
type: 'string',
|
|
32
|
+
default: '/',
|
|
33
|
+
},
|
|
34
|
+
BATCH_TRANSPORT_SETUP_VALIDATION: {
|
|
35
|
+
description: 'Flag to toggle batch transport setup validation',
|
|
36
|
+
type: 'boolean',
|
|
37
|
+
default: false,
|
|
38
|
+
},
|
|
39
|
+
CACHE_MAX_AGE: {
|
|
40
|
+
description: 'Maximum amount of time (in ms) that a response will stay cached',
|
|
41
|
+
type: 'number',
|
|
42
|
+
default: 90000,
|
|
43
|
+
},
|
|
44
|
+
// CACHE_MAX_ITEMS: {
|
|
45
|
+
// type: 'number',
|
|
46
|
+
// default: 1000,
|
|
47
|
+
// },
|
|
48
|
+
// CACHE_MIN_AGE: {
|
|
49
|
+
// type: 'number',
|
|
50
|
+
// default: 30000,
|
|
51
|
+
// },
|
|
52
|
+
// CACHE_REDIS_CONNECTION_TIMEOUT: {
|
|
53
|
+
// type: 'number',
|
|
54
|
+
// default: 15000,
|
|
55
|
+
// },
|
|
56
|
+
CACHE_REDIS_HOST: {
|
|
57
|
+
description: 'Hostname for the Redis instance to be used',
|
|
58
|
+
type: 'string',
|
|
59
|
+
default: '127.0.0.1',
|
|
60
|
+
},
|
|
61
|
+
// CACHE_REDIS_MAX_QUEUED_ITEMS: {
|
|
62
|
+
// description: 'Maximum length of the client internal command queue',
|
|
63
|
+
// type: 'number',
|
|
64
|
+
// default: 500,
|
|
65
|
+
// },
|
|
66
|
+
// CACHE_REDIS_MAX_RECONNECT_COOLDOWN: {
|
|
67
|
+
// type: 'number',
|
|
68
|
+
// default: 3000,
|
|
69
|
+
// },
|
|
70
|
+
CACHE_REDIS_PASSWORD: {
|
|
71
|
+
description: 'The password required for redis auth',
|
|
72
|
+
type: 'string',
|
|
73
|
+
sensitive: true,
|
|
74
|
+
},
|
|
75
|
+
CACHE_REDIS_PATH: {
|
|
76
|
+
description: 'The UNIX socket string of the Redis server',
|
|
77
|
+
type: 'string',
|
|
78
|
+
},
|
|
79
|
+
CACHE_REDIS_PORT: {
|
|
80
|
+
description: 'Port for the Redis instance to be used',
|
|
81
|
+
type: 'number',
|
|
82
|
+
default: 6379,
|
|
83
|
+
},
|
|
84
|
+
CACHE_REDIS_TIMEOUT: {
|
|
85
|
+
description: 'Timeout to fail a Redis server request if no response (ms)',
|
|
86
|
+
type: 'number',
|
|
87
|
+
default: 500,
|
|
88
|
+
},
|
|
89
|
+
// CACHE_REDIS_URL: {
|
|
90
|
+
// type: 'string',
|
|
91
|
+
// },
|
|
92
|
+
CACHE_TYPE: {
|
|
93
|
+
description: 'The type of cache to use throughout the EA',
|
|
94
|
+
type: 'enum',
|
|
95
|
+
default: 'local',
|
|
96
|
+
options: ['local', 'redis'],
|
|
97
|
+
},
|
|
98
|
+
CORRELATION_ID_ENABLED: {
|
|
99
|
+
description: 'Flag to enable correlation IDs for sent requests in logging',
|
|
100
|
+
type: 'boolean',
|
|
101
|
+
default: true,
|
|
102
|
+
},
|
|
103
|
+
// DATA_PROVIDER_URL: {
|
|
104
|
+
// description: 'Legacy variable that has the same functionality as ADAPTER_URL',
|
|
105
|
+
// type: 'string',
|
|
106
|
+
// },
|
|
107
|
+
DEBUG: {
|
|
108
|
+
description: 'Toggles debug mode',
|
|
109
|
+
type: 'boolean',
|
|
110
|
+
default: false,
|
|
111
|
+
},
|
|
112
|
+
// DEFAULT_WS_HEARTBEAT_INTERVAL: {
|
|
113
|
+
// description: 'Interval between WS heartbeat pings (ms)',
|
|
114
|
+
// type: 'number',
|
|
115
|
+
// default: 30000,
|
|
116
|
+
// },
|
|
117
|
+
EA_PORT: {
|
|
118
|
+
description: 'Port through which the EA will listen for REST requests (if mode is set to "reader" or "reader-writer")',
|
|
119
|
+
type: 'number',
|
|
120
|
+
default: 8080,
|
|
121
|
+
},
|
|
122
|
+
// ERROR_CAPACITY: {
|
|
123
|
+
// type: 'number',
|
|
124
|
+
// },
|
|
125
|
+
EXPERIMENTAL_METRICS_ENABLED: {
|
|
126
|
+
description: 'Flag to specify whether or not to collect metrics. Used as fallback for METRICS_ENABLED',
|
|
127
|
+
type: 'boolean',
|
|
128
|
+
default: true,
|
|
129
|
+
},
|
|
130
|
+
LOG_LEVEL: {
|
|
131
|
+
description: 'Minimum level required for logs to be output',
|
|
132
|
+
type: 'string',
|
|
133
|
+
default: 'info',
|
|
134
|
+
},
|
|
135
|
+
METRICS_ENABLED: {
|
|
136
|
+
description: 'Flag to specify whether or not to startup the metrics server',
|
|
137
|
+
type: 'boolean',
|
|
138
|
+
default: true,
|
|
139
|
+
},
|
|
140
|
+
METRICS_NAME: {
|
|
141
|
+
description: 'Metrics name',
|
|
142
|
+
type: 'string',
|
|
143
|
+
},
|
|
144
|
+
METRICS_PORT: {
|
|
145
|
+
description: 'Port metrics will be exposed to',
|
|
146
|
+
type: 'number',
|
|
147
|
+
default: 9080,
|
|
148
|
+
},
|
|
149
|
+
METRICS_USE_BASE_URL: {
|
|
150
|
+
description: 'Flag to specify whether or not to prepend the BASE_URL to the metrics endpoint',
|
|
151
|
+
type: 'boolean',
|
|
152
|
+
},
|
|
153
|
+
RATE_LIMIT_API_TIER: {
|
|
154
|
+
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.',
|
|
155
|
+
type: 'string',
|
|
156
|
+
},
|
|
157
|
+
RATE_LIMIT_CAPACITY: {
|
|
158
|
+
description: 'Used as rate limit capacity per minute and ignores tier settings if defined',
|
|
159
|
+
type: 'number',
|
|
160
|
+
},
|
|
161
|
+
RATE_LIMIT_CAPACITY_MINUTE: {
|
|
162
|
+
description: 'Used as rate limit capacity per minute and ignores tier settings if defined. Supercedes RATE_LIMIT_CAPACITY if both vars are set',
|
|
163
|
+
type: 'number',
|
|
164
|
+
},
|
|
165
|
+
RATE_LIMIT_CAPACITY_SECOND: {
|
|
166
|
+
description: 'Used as rate limit capacity per second and ignores tier settings if defined',
|
|
167
|
+
type: 'number',
|
|
168
|
+
},
|
|
169
|
+
REQUEST_COALESCING_ENABLED: {
|
|
170
|
+
description: 'Enable request coalescing',
|
|
171
|
+
type: 'boolean',
|
|
172
|
+
default: false,
|
|
173
|
+
},
|
|
174
|
+
REQUEST_COALESCING_ENTROPY_MAX: {
|
|
175
|
+
description: 'Amount of random delay (entropy) in milliseconds that will be added to requests. Avoids issue where the request coalescing key will not be set before multiple other instances in a burst try to access the same key',
|
|
176
|
+
type: 'number',
|
|
177
|
+
default: 0,
|
|
178
|
+
},
|
|
179
|
+
// REQUEST_COALESCING_INTERVAL: {
|
|
180
|
+
// type: 'number',
|
|
181
|
+
// default: 100,
|
|
182
|
+
// },
|
|
183
|
+
// REQUEST_COALESCING_INTERVAL_COEFFICIENT: {
|
|
184
|
+
// type: 'number',
|
|
185
|
+
// default: 2,
|
|
186
|
+
// },
|
|
187
|
+
// REQUEST_COALESCING_INTERVAL_MAX: {
|
|
188
|
+
// type: 'number',
|
|
189
|
+
// default: 1000,
|
|
190
|
+
// },
|
|
191
|
+
// REQUEST_COALESCING_MAX_RETRIES: {
|
|
192
|
+
// type: 'number',
|
|
193
|
+
// default: 5,
|
|
194
|
+
// },
|
|
195
|
+
// RETRY: {
|
|
196
|
+
// type: 'boolean',
|
|
197
|
+
// default: 1,
|
|
198
|
+
// },
|
|
199
|
+
SSE_SUBSCRIPTION_UPDATE_SLEEP: {
|
|
200
|
+
description: 'Maximum amount of time (in ms) between each update to the set of subscribed feeds',
|
|
201
|
+
type: 'number',
|
|
202
|
+
default: 1000,
|
|
203
|
+
},
|
|
204
|
+
SSE_KEEPALIVE_SLEEP: {
|
|
205
|
+
description: 'Maximum amount of time (in ms) between each SSE keepalive request',
|
|
206
|
+
type: 'number',
|
|
207
|
+
default: 60000,
|
|
208
|
+
},
|
|
209
|
+
SSE_SUBSCRIPTION_TTL: {
|
|
210
|
+
description: 'Maximum amount of time (in ms) an SSE subscription will be cached before being unsubscribed',
|
|
211
|
+
type: 'number',
|
|
212
|
+
default: 300000,
|
|
213
|
+
},
|
|
214
|
+
WARMUP_SUBSCRIPTION_TTL: {
|
|
215
|
+
type: 'number',
|
|
216
|
+
description: 'TTL for batch warmer subscriptions',
|
|
217
|
+
default: 300000,
|
|
218
|
+
},
|
|
219
|
+
// WARMUP_UNHEALTHY_THRESHOLD: {
|
|
220
|
+
// type: 'number',
|
|
221
|
+
// default: 3,
|
|
222
|
+
// },
|
|
223
|
+
WS_API_ENDPOINT: {
|
|
224
|
+
description: 'Override the base websocket URL within the EA.',
|
|
225
|
+
type: 'string',
|
|
226
|
+
},
|
|
227
|
+
WS_API_KEY: {
|
|
228
|
+
description: 'The websocket API key to authenticate with',
|
|
229
|
+
type: 'string',
|
|
230
|
+
sensitive: true,
|
|
231
|
+
},
|
|
232
|
+
WS_SUBSCRIPTION_TTL: {
|
|
233
|
+
description: '',
|
|
234
|
+
type: 'number',
|
|
235
|
+
default: 120000,
|
|
236
|
+
},
|
|
237
|
+
// WS_SUBSCRIPTION_UNRESPONSIVE_TTL: {
|
|
238
|
+
// type: 'number',
|
|
239
|
+
// default: false,
|
|
240
|
+
// },
|
|
241
|
+
// WS_TIME_UNTIL_HANDLE_NEXT_MESSAGE_OVERRIDE: {
|
|
242
|
+
// description: 'Time to wait until adapter should handle next WS message',
|
|
243
|
+
// type: 'number',
|
|
244
|
+
// },
|
|
245
|
+
// V3
|
|
246
|
+
CACHE_POLLING_MAX_RETRIES: {
|
|
247
|
+
description: 'Max amount of times to attempt to find EA response in the cache after the Transport has been set up',
|
|
248
|
+
type: 'number',
|
|
249
|
+
default: 10,
|
|
250
|
+
},
|
|
251
|
+
CACHE_POLLING_SLEEP_MS: {
|
|
252
|
+
description: 'The number of ms to sleep between each retry to fetch the EA response in the cache',
|
|
253
|
+
type: 'number',
|
|
254
|
+
default: 200,
|
|
255
|
+
},
|
|
256
|
+
DEFAULT_CACHE_KEY: {
|
|
257
|
+
description: 'Default key to be used when one cannot be determined from request parameters',
|
|
258
|
+
type: 'string',
|
|
259
|
+
default: 'DEFAULT_CACHE_KEY',
|
|
260
|
+
},
|
|
261
|
+
EA_HOST: {
|
|
262
|
+
description: 'Host this EA will listen for REST requests on (if mode is set to "reader" or "reader-writer")',
|
|
263
|
+
type: 'string',
|
|
264
|
+
default: '::',
|
|
265
|
+
},
|
|
266
|
+
EA_MODE: {
|
|
267
|
+
description: 'Port this EA will listen for REST requests on (if mode is set to "reader" or "reader-writer")',
|
|
268
|
+
type: 'enum',
|
|
269
|
+
default: 'reader-writer',
|
|
270
|
+
options: ['reader', 'writer', 'reader-writer'],
|
|
271
|
+
},
|
|
272
|
+
MAX_COMMON_KEY_SIZE: {
|
|
273
|
+
description: 'Maximum amount of characters that the common part of the cache key or feed ID can have',
|
|
274
|
+
type: 'number',
|
|
275
|
+
default: 300,
|
|
276
|
+
validate: (value) => {
|
|
277
|
+
if (!(value && value >= 150 && value <= 500)) {
|
|
278
|
+
return 'MAX_COMMON_KEY_SIZE must be a number between 150 and 500';
|
|
279
|
+
}
|
|
280
|
+
},
|
|
281
|
+
},
|
|
282
|
+
REST_TRANSPORT_MAX_RATE_LIMIT_RETRIES: {
|
|
283
|
+
description: 'Maximum amount of times the Rest Transport will attempt to set up a request when blocked by the rate limiter',
|
|
284
|
+
type: 'number',
|
|
285
|
+
default: 3,
|
|
286
|
+
},
|
|
287
|
+
REST_TRANSPORT_MS_BETWEEN_RATE_LIMIT_RETRIES: {
|
|
288
|
+
description: 'Time that the Rest Transport will wait between retries when blocked by the rate limiter',
|
|
289
|
+
type: 'number',
|
|
290
|
+
default: 400,
|
|
291
|
+
},
|
|
292
|
+
SMOKE_TEST_PAYLOAD_FILE_NAME: {
|
|
293
|
+
description: 'Name of the test payload file used for the smoke endpoint',
|
|
294
|
+
type: 'string',
|
|
295
|
+
},
|
|
296
|
+
};
|
|
297
|
+
const buildAdapterConfig = ({ overrides = {}, customSettings = {}, }) => {
|
|
298
|
+
const vars = {};
|
|
299
|
+
// Iterate base adapter env vars
|
|
300
|
+
for (const [key, config] of Object.entries(exports.BaseSettings)) {
|
|
301
|
+
const value = getEnv(key, config) ?? overrides?.[key] ?? config.default;
|
|
302
|
+
vars[key] = value;
|
|
303
|
+
}
|
|
304
|
+
// Iterate custom vars
|
|
305
|
+
for (const [key, config] of Object.entries(customSettings)) {
|
|
306
|
+
if (exports.BaseSettings[key]) {
|
|
307
|
+
throw new Error(`Custom env var "${key}" declared, but a base framework env var with that name already exists.`);
|
|
308
|
+
}
|
|
309
|
+
const value = getEnv(key, config) ?? config.default;
|
|
310
|
+
vars[key] = value;
|
|
311
|
+
}
|
|
312
|
+
return vars;
|
|
313
|
+
};
|
|
314
|
+
exports.buildAdapterConfig = buildAdapterConfig;
|
|
315
|
+
const validateAdapterConfig = (adapterConfig, customSettings = {}) => {
|
|
316
|
+
const validationErrors = [];
|
|
317
|
+
Object.entries(exports.BaseSettings)
|
|
318
|
+
.concat(Object.entries(customSettings || {}))
|
|
319
|
+
.forEach(([name, setting]) => {
|
|
320
|
+
validateSetting(name, adapterConfig[name], setting, validationErrors);
|
|
321
|
+
});
|
|
322
|
+
if (validationErrors.length > 0) {
|
|
323
|
+
throw new Error(`Validation failed for the following variables:\n ${validationErrors.join('\n')}`);
|
|
324
|
+
}
|
|
325
|
+
};
|
|
326
|
+
exports.validateAdapterConfig = validateAdapterConfig;
|
|
327
|
+
const validateSetting = (key, value, config, validationErrors) => {
|
|
328
|
+
// Check if a required setting has been provided
|
|
329
|
+
if (config.required && (value === null || value === undefined)) {
|
|
330
|
+
validationErrors.push(`${key}: Value is required, but none was provided`);
|
|
331
|
+
}
|
|
332
|
+
else if (config.validate) {
|
|
333
|
+
// Cast validate to unknown because TS can't select one of multiple variants of the validate function signature
|
|
334
|
+
const validationRes = config.validate(value);
|
|
335
|
+
if (validationRes) {
|
|
336
|
+
validationErrors.push(`${key}: ${validationRes}`);
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
};
|
|
340
|
+
const getEnv = (name, config) => {
|
|
341
|
+
const value = process.env[name];
|
|
342
|
+
if (!value) {
|
|
343
|
+
return null;
|
|
344
|
+
}
|
|
345
|
+
switch (config.type) {
|
|
346
|
+
case 'string':
|
|
347
|
+
return value;
|
|
348
|
+
case 'number':
|
|
349
|
+
return parseInt(value);
|
|
350
|
+
case 'boolean':
|
|
351
|
+
return value === 'true';
|
|
352
|
+
case 'enum':
|
|
353
|
+
if (!config.options?.includes(value)) {
|
|
354
|
+
throw new Error(`Env var "${name}" has value "${value}" which is not included in the valid options (${config.options})`);
|
|
355
|
+
}
|
|
356
|
+
return value;
|
|
357
|
+
}
|
|
358
|
+
};
|
|
359
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/config/index.ts"],"names":[],"mappings":";;;AAAa,QAAA,YAAY,GAAG;IAC1B,YAAY;IACZ,iBAAiB;IACjB,qFAAqF;IACrF,oBAAoB;IACpB,KAAK;IACL,YAAY,EAAE;QACZ,WAAW,EAAE,sDAAsD;QACnE,IAAI,EAAE,QAAQ;KACf;IACD,OAAO,EAAE;QACP,WAAW,EAAE,+BAA+B;QAC5C,IAAI,EAAE,QAAQ;QACd,SAAS,EAAE,IAAI;KAChB;IACD,WAAW,EAAE;QACX,WAAW,EACT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K,QAAQ;YACX,OAAO,QAAQ,CAAC,KAAK,CAAC,CAAA;QACxB,KAAK,SAAS;YACZ,OAAO,KAAK,KAAK,MAAM,CAAA;QACzB,KAAK,MAAM;YACT,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,QAAQ,CAAC,KAAK,CAAC,EAAE;gBACpC,MAAM,IAAI,KAAK,CACb,YAAY,IAAI,gBAAgB,KAAK,iDAAiD,MAAM,CAAC,OAAO,GAAG,CACxG,CAAA;aACF;YACD,OAAO,KAAK,CAAA;KACf;AACH,CAAC,CAAA"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export declare const DEFAULT_MINUTE_RATE_LIMIT = 60;
|
|
2
|
+
export declare const BURST_UNDEFINED_QUOTA_MULTIPLE = 2;
|
|
3
|
+
export declare const DEFAULT_WS_CONNECTIONS = 2;
|
|
4
|
+
export declare const DEFAULT_WS_SUBSCRIPTIONS = 10;
|
|
5
|
+
declare type RateLimitTimeFrame = 'rateLimit1s' | 'rateLimit1m' | 'rateLimit1h';
|
|
6
|
+
declare type HTTPTier = {
|
|
7
|
+
rateLimit1s?: number;
|
|
8
|
+
rateLimit1m?: number;
|
|
9
|
+
rateLimit1h?: number;
|
|
10
|
+
note?: string;
|
|
11
|
+
};
|
|
12
|
+
declare type WSTier = {
|
|
13
|
+
connections: number;
|
|
14
|
+
subscriptions: number;
|
|
15
|
+
};
|
|
16
|
+
export interface Limits {
|
|
17
|
+
http: Record<string, HTTPTier>;
|
|
18
|
+
ws: Record<string, WSTier>;
|
|
19
|
+
}
|
|
20
|
+
interface ProviderRateLimit {
|
|
21
|
+
second: number;
|
|
22
|
+
minute: number;
|
|
23
|
+
}
|
|
24
|
+
export declare const getHTTPLimit: (provider: string, limits: Limits, tier: string, timeframe: RateLimitTimeFrame) => number;
|
|
25
|
+
export declare const getRateLimit: (provider: string, limits: Limits, tier: string) => ProviderRateLimit;
|
|
26
|
+
export declare const getWSLimits: (provider: string, limits: Limits, tier: string) => WSTier;
|
|
27
|
+
export {};
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getWSLimits = exports.getRateLimit = exports.getHTTPLimit = exports.DEFAULT_WS_SUBSCRIPTIONS = exports.DEFAULT_WS_CONNECTIONS = exports.BURST_UNDEFINED_QUOTA_MULTIPLE = exports.DEFAULT_MINUTE_RATE_LIMIT = void 0;
|
|
4
|
+
const util_1 = require("../util");
|
|
5
|
+
exports.DEFAULT_MINUTE_RATE_LIMIT = 60;
|
|
6
|
+
exports.BURST_UNDEFINED_QUOTA_MULTIPLE = 2;
|
|
7
|
+
exports.DEFAULT_WS_CONNECTIONS = 2;
|
|
8
|
+
exports.DEFAULT_WS_SUBSCRIPTIONS = 10;
|
|
9
|
+
const logger = (0, util_1.makeLogger)('ProviderLimits');
|
|
10
|
+
const getHTTPLimit = (provider, limits, tier, timeframe) => {
|
|
11
|
+
const providerLimit = getProviderLimits(provider, limits, tier, 'http');
|
|
12
|
+
return providerLimit?.[timeframe] || 0;
|
|
13
|
+
};
|
|
14
|
+
exports.getHTTPLimit = getHTTPLimit;
|
|
15
|
+
const getRateLimit = (provider, limits, tier) => {
|
|
16
|
+
const providerLimit = getProviderLimits(provider, limits, tier, 'http');
|
|
17
|
+
return calculateRateLimit(providerLimit);
|
|
18
|
+
};
|
|
19
|
+
exports.getRateLimit = getRateLimit;
|
|
20
|
+
const getWSLimits = (provider, limits, tier) => {
|
|
21
|
+
const providerLimit = getProviderLimits(provider, limits, tier, 'ws');
|
|
22
|
+
return calculateWSLimits(providerLimit);
|
|
23
|
+
};
|
|
24
|
+
exports.getWSLimits = getWSLimits;
|
|
25
|
+
const getProviderLimits = (provider, limits, tier, protocol) => {
|
|
26
|
+
const providerConfig = parseLimits(limits);
|
|
27
|
+
if (!providerConfig) {
|
|
28
|
+
throw new Error(`Rate Limit: Provider: "${provider}" doesn't match any provider spec in limits.json`);
|
|
29
|
+
}
|
|
30
|
+
const protocolConfig = providerConfig[protocol];
|
|
31
|
+
if (!protocolConfig) {
|
|
32
|
+
throw new Error(`Rate Limit: "${provider}" doesn't have any configuration for ${protocol} in limits.json`);
|
|
33
|
+
}
|
|
34
|
+
let limitsConfig = protocolConfig[tier.toLowerCase()];
|
|
35
|
+
if (!limitsConfig) {
|
|
36
|
+
logger.debug(`Rate Limit: "${provider} does not have tier ${tier} defined. Falling back to lowest tier"`);
|
|
37
|
+
limitsConfig = Object.values(protocolConfig)?.[0];
|
|
38
|
+
}
|
|
39
|
+
if (!limitsConfig) {
|
|
40
|
+
throw new Error(`Rate Limit: Provider: "${provider}" has no tiers defined for ${protocol} in limits.json`);
|
|
41
|
+
}
|
|
42
|
+
return limitsConfig;
|
|
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
|
+
};
|
|
51
|
+
const parseLimits = (limits) => {
|
|
52
|
+
limits.http = objectKeysToLowercase(limits.http);
|
|
53
|
+
limits.ws = objectKeysToLowercase(limits.ws);
|
|
54
|
+
return limits;
|
|
55
|
+
};
|
|
56
|
+
const calculateWSLimits = (providerLimit) => {
|
|
57
|
+
return {
|
|
58
|
+
connections: providerLimit.connections,
|
|
59
|
+
subscriptions: providerLimit.subscriptions,
|
|
60
|
+
};
|
|
61
|
+
};
|
|
62
|
+
const calculateRateLimit = (providerLimit) => {
|
|
63
|
+
let quota = providerLimit.rateLimit1m;
|
|
64
|
+
if (!quota && providerLimit?.rateLimit1h) {
|
|
65
|
+
quota = providerLimit?.rateLimit1h / 60;
|
|
66
|
+
}
|
|
67
|
+
else if (!quota && providerLimit?.rateLimit1s) {
|
|
68
|
+
quota = providerLimit?.rateLimit1s * 60;
|
|
69
|
+
}
|
|
70
|
+
return {
|
|
71
|
+
second: providerLimit?.rateLimit1s || (quota / 60) * exports.BURST_UNDEFINED_QUOTA_MULTIPLE,
|
|
72
|
+
minute: quota,
|
|
73
|
+
};
|
|
74
|
+
};
|
|
75
|
+
//# sourceMappingURL=provider-limits.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provider-limits.js","sourceRoot":"","sources":["../../../src/config/provider-limits.ts"],"names":[],"mappings":";;;AAAA,kCAAoC;AAEvB,QAAA,yBAAyB,GAAG,EAAE,CAAA;AAC9B,QAAA,8BAA8B,GAAG,CAAC,CAAA;AAElC,QAAA,sBAAsB,GAAG,CAAC,CAAA;AAC1B,QAAA,wBAAwB,GAAG,EAAE,CAAA;AA0B1C,MAAM,MAAM,GAAG,IAAA,iBAAU,EAAC,gBAAgB,CAAC,CAAA;AAEpC,MAAM,YAAY,GAAG,CAC1B,QAAgB,EAChB,MAAc,EACd,IAAY,EACZ,SAA6B,EACrB,EAAE;IACV,MAAM,aAAa,GAAG,iBAAiB,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,CAAA;IACvE,OAAQ,aAA0B,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,CAAA;AACtD,CAAC,CAAA;AARY,QAAA,YAAY,gBAQxB;AAEM,MAAM,YAAY,GAAG,CAAC,QAAgB,EAAE,MAAc,EAAE,IAAY,EAAqB,EAAE;IAChG,MAAM,aAAa,GAAG,iBAAiB,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,CAAA;IACvE,OAAO,kBAAkB,CAAC,aAAyB,CAAC,CAAA;AACtD,CAAC,CAAA;AAHY,QAAA,YAAY,gBAGxB;AAEM,MAAM,WAAW,GAAG,CAAC,QAAgB,EAAE,MAAc,EAAE,IAAY,EAAU,EAAE;IACpF,MAAM,aAAa,GAAG,iBAAiB,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,CAAA;IACrE,OAAO,iBAAiB,CAAC,aAAuB,CAA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G,qBAAqB,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;IAChD,MAAM,CAAC,EAAE,GAAG,qBAAqB,CAAC,MAAM,CAAC,EAAE,CAAC,CAAA;IAC5C,OAAO,MAAM,CAAA;AACf,CAAC,CAAA;AAED,MAAM,iBAAiB,GAAG,CAAC,aAAqB,EAAU,EAAE;IAC1D,OAAO;QACL,WAAW,EAAE,aAAa,CAAC,WAAW;QACtC,aAAa,EAAE,aAAa,CAAC,aAAa;KAC3C,CAAA;AACH,CAAC,CAAA;AAED,MAAM,kBAAkB,GAAG,CAAC,aAAuB,EAAqB,EAAE;IACxE,IAAI,KAAK,GAAG,aAAa,CAAC,WAAW,CAAA;IACrC,IAAI,CAAC,KAAK,IAAI,aAAa,EAAE,WAAW,EAAE;QACxC,KAAK,GAAG,aAAa,EAAE,WAAW,GAAG,EAAE,CAAA;KACxC;SAAM,IAAI,CAAC,KAAK,IAAI,aAAa,EAAE,WAAW,EAAE;QAC/C,KAAK,GAAG,aAAa,EAAE,WAAW,GAAG,EAAE,CAAA;KACxC;IACD,OAAO;QACL,MAAM,EAAE,aAAa,EAAE,WAAW,IAAI,CAAE,KAAgB,GAAG,EAAE,CAAC,GAAG,sCAA8B;QAC/F,MAAM,EAAE,KAAe;KACxB,CAAA;AACH,CAAC,CAAA"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { AxiosRequestConfig, AxiosResponse } from 'axios';
|
|
2
|
+
import { AdapterDependencies, AdapterEndpoint } from '../../adapter';
|
|
3
|
+
import { Cache } from '../../cache';
|
|
4
|
+
import { AdapterConfig } from '../../config';
|
|
5
|
+
import { Transport } from '../../transports';
|
|
6
|
+
import { AdapterRequest, AdapterResponse, SingleNumberResultResponse } from '../../util';
|
|
7
|
+
import { customSettings } from './config';
|
|
8
|
+
import { AdapterInputParameters, BankFrickAccountsRequestSchema, BankFrickAccountsResponseSchema, SigningAlgorithm } from './types';
|
|
9
|
+
export declare type AccountsEndpointTypes = {
|
|
10
|
+
Request: {
|
|
11
|
+
Params: AdapterInputParameters;
|
|
12
|
+
};
|
|
13
|
+
Response: SingleNumberResultResponse;
|
|
14
|
+
CustomSettings: typeof customSettings;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* RestTransport implementation for Bank Frick, which has unusually complex requirements for an EA
|
|
18
|
+
* The RestTransport is generally built to make a single request and return a single response.
|
|
19
|
+
* This transport instead is used to fetch and process pages of data, and also requires a JWT to run
|
|
20
|
+
*
|
|
21
|
+
* This transport does all the heavy lifting in setup(), which is where the paging happens, and it
|
|
22
|
+
* also has complex retry logic that will attempt to refresh the JWT when certain HTTP errors occur
|
|
23
|
+
*/
|
|
24
|
+
export declare class BankFrickAccountsTransport implements Transport<AccountsEndpointTypes> {
|
|
25
|
+
token: string;
|
|
26
|
+
cache: Cache<AdapterResponse<AccountsEndpointTypes['Response']>>;
|
|
27
|
+
initialize(dependencies: AdapterDependencies): Promise<void>;
|
|
28
|
+
/**
|
|
29
|
+
* Creates an AxiosRequestConfig object for fetching a page of accounts from the Bank Frick API
|
|
30
|
+
*/
|
|
31
|
+
prepareRequest(firstPosition: number, inputParams: AdapterInputParameters, config: AdapterConfig<typeof customSettings>): AxiosRequestConfig<BankFrickAccountsRequestSchema>;
|
|
32
|
+
/**
|
|
33
|
+
* Request with retry logic for Bank Frick's API. In addition to standard retry logic, this function
|
|
34
|
+
* compares errors against expected errors from the Bank Frick API, and will throw without retries
|
|
35
|
+
* on a known fatal error, or try to refresh the JWT on a known auth error
|
|
36
|
+
**/
|
|
37
|
+
makeRequest(axiosRequest: AxiosRequestConfig<BankFrickAccountsRequestSchema>, config: AdapterConfig<typeof customSettings>, signingAlgorithm?: SigningAlgorithm): Promise<AxiosResponse<BankFrickAccountsResponseSchema>>;
|
|
38
|
+
validateInputParams(params: AdapterInputParameters): string[];
|
|
39
|
+
/**
|
|
40
|
+
* Fetches pages of data from the Bank Frick API, scans for accounts by IBAN, and returns the balance
|
|
41
|
+
* of all found accounts. Returns a 404 if any IBAN isn't found.
|
|
42
|
+
*/
|
|
43
|
+
foregroundExecute(req: AdapterRequest<AccountsEndpointTypes['Request']>, config: AdapterConfig<typeof customSettings>): Promise<AdapterResponse<AccountsEndpointTypes['Response']>>;
|
|
44
|
+
}
|
|
45
|
+
export declare const accountsRestEndpoint: AdapterEndpoint<AccountsEndpointTypes>;
|