@chainlink/external-adapter-framework 0.0.14 → 0.0.15
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/.c8rc.json +3 -0
- package/.eslintignore +10 -0
- package/.eslintrc.js +96 -0
- package/.github/README.MD +42 -0
- package/.github/actions/setup/action.yaml +13 -0
- package/.github/workflows/label.yaml +39 -0
- package/.github/workflows/main.yaml +39 -0
- package/.github/workflows/publish.yaml +17 -0
- package/.prettierignore +13 -0
- package/.yarnrc +0 -0
- package/README.md +103 -0
- package/dist/examples/coingecko/test/e2e/adapter.test.ts.js +82953 -0
- package/dist/examples/coingecko/test/integration/adapter.test.ts.js +91672 -0
- package/dist/main.js +72703 -0
- package/docker-compose.yaml +35 -0
- package/env.sh +54 -0
- package/env2.sh +55 -0
- package/jest.config.js +5 -0
- package/package.json +14 -3
- package/publish.sh +0 -0
- package/src/adapter.ts +263 -0
- package/src/background-executor.ts +52 -0
- package/src/cache/factory.ts +26 -0
- package/src/cache/index.ts +258 -0
- package/src/cache/local.ts +73 -0
- package/src/cache/metrics.ts +112 -0
- package/src/cache/redis.ts +93 -0
- package/src/config/index.ts +517 -0
- package/src/config/provider-limits.ts +127 -0
- package/src/examples/bank-frick/README.MD +10 -0
- package/src/examples/bank-frick/accounts.ts +246 -0
- package/src/examples/bank-frick/config/index.ts +53 -0
- package/src/examples/bank-frick/index.ts +13 -0
- package/src/examples/bank-frick/types.d.ts +38 -0
- package/src/examples/bank-frick/util.ts +55 -0
- package/src/examples/coingecko/src/config/index.ts +12 -0
- package/src/examples/coingecko/src/config/overrides.json +10826 -0
- package/src/examples/coingecko/src/cryptoUtils.ts +88 -0
- package/src/examples/coingecko/src/endpoint/coins.ts +54 -0
- package/src/examples/coingecko/src/endpoint/crypto-marketcap.ts +66 -0
- package/src/examples/coingecko/src/endpoint/crypto-volume.ts +66 -0
- package/src/examples/coingecko/src/endpoint/crypto.ts +63 -0
- package/src/examples/coingecko/src/endpoint/dominance.ts +40 -0
- package/src/examples/coingecko/src/endpoint/global-marketcap.ts +40 -0
- package/src/examples/coingecko/src/endpoint/index.ts +6 -0
- package/src/examples/coingecko/src/globalUtils.ts +78 -0
- package/src/examples/coingecko/src/index.ts +17 -0
- package/src/examples/coingecko/test/e2e/adapter.test.ts +278 -0
- package/src/examples/coingecko/test/integration/__snapshots__/adapter.test.ts.snap +15 -0
- package/src/examples/coingecko/test/integration/adapter.test.ts +281 -0
- package/src/examples/coingecko/test/integration/capturedRequests.json +1 -0
- package/src/examples/coingecko/test/integration/fixtures.ts +42 -0
- package/src/examples/coingecko-old/batch-warming.ts +79 -0
- package/src/examples/coingecko-old/index.ts +9 -0
- package/src/examples/coingecko-old/rest.ts +77 -0
- package/src/examples/ncfx/config/index.ts +12 -0
- package/src/examples/ncfx/index.ts +9 -0
- package/src/examples/ncfx/websocket.ts +99 -0
- package/src/index.ts +149 -0
- package/src/metrics/constants.ts +23 -0
- package/src/metrics/index.ts +115 -0
- package/src/metrics/util.ts +18 -0
- package/src/rate-limiting/background/fixed-frequency.ts +45 -0
- package/src/rate-limiting/index.ts +100 -0
- package/src/rate-limiting/metrics.ts +18 -0
- package/src/rate-limiting/request/simple-counting.ts +76 -0
- package/src/transports/batch-warming.ts +127 -0
- package/src/transports/index.ts +152 -0
- package/src/transports/metrics.ts +95 -0
- package/src/transports/rest.ts +168 -0
- package/src/transports/util.ts +63 -0
- package/src/transports/websocket.ts +245 -0
- package/src/util/index.ts +23 -0
- package/src/util/logger.ts +69 -0
- package/src/util/recordRequests.ts +47 -0
- package/src/util/request.ts +117 -0
- package/src/util/subscription-set/expiring-sorted-set.ts +54 -0
- package/src/util/subscription-set/subscription-set.ts +35 -0
- package/src/util/test-payload-loader.ts +87 -0
- package/src/validation/error.ts +116 -0
- package/src/validation/index.ts +110 -0
- package/src/validation/input-params.ts +45 -0
- package/src/validation/override-functions.ts +44 -0
- package/src/validation/overrideFunctions.ts +44 -0
- package/src/validation/preset-tokens.json +23 -0
- package/src/validation/validator.ts +384 -0
- package/test/adapter.test.ts +27 -0
- package/test/background-executor.test.ts +108 -0
- package/test/cache/cache-key.test.ts +114 -0
- package/test/cache/helper.ts +100 -0
- package/test/cache/local.test.ts +54 -0
- package/test/cache/redis.test.ts +89 -0
- package/test/correlation.test.ts +114 -0
- package/test/index.test.ts +37 -0
- package/test/metrics/feed-id.test.ts +38 -0
- package/test/metrics/helper.ts +14 -0
- package/test/metrics/labels.test.ts +36 -0
- package/test/metrics/metrics.test.ts +267 -0
- package/test/metrics/redis-metrics.test.ts +113 -0
- package/test/metrics/warmer-metrics.test.ts +193 -0
- package/test/metrics/ws-metrics.test.ts +225 -0
- package/test/rate-limit-config.test.ts +242 -0
- package/test/smoke/smoke.test.ts +166 -0
- package/test/smoke/test-payload-fail.json +3 -0
- package/test/smoke/test-payload.js +22 -0
- package/test/smoke/test-payload.json +7 -0
- package/test/transports/batch.test.ts +466 -0
- package/test/transports/rest.test.ts +242 -0
- package/test/transports/websocket.test.ts +183 -0
- package/test/tsconfig.json +5 -0
- package/test/util.ts +77 -0
- package/test/validation.test.ts +178 -0
- package/test.sh +20 -0
- package/test2.sh +2 -0
- package/tsconfig.json +28 -0
- package/typedoc.json +6 -0
- package/webpack.config.js +57 -0
- package/yarn-error.log +3778 -0
- package/adapter.d.ts +0 -107
- package/adapter.js +0 -115
- package/background-executor.d.ts +0 -11
- package/background-executor.js +0 -45
- package/cache/factory.d.ts +0 -6
- package/cache/factory.js +0 -55
- package/cache/index.d.ts +0 -94
- package/cache/index.js +0 -173
- package/cache/local.d.ts +0 -23
- package/cache/local.js +0 -83
- package/cache/metrics.d.ts +0 -27
- package/cache/metrics.js +0 -120
- package/cache/redis.d.ts +0 -16
- package/cache/redis.js +0 -100
- package/chainlink-external-adapter-framework-0.0.6.tgz +0 -0
- package/config/index.d.ts +0 -209
- package/config/index.js +0 -380
- package/config/provider-limits.d.ts +0 -31
- package/config/provider-limits.js +0 -79
- package/examples/bank-frick/accounts.d.ts +0 -39
- package/examples/bank-frick/accounts.js +0 -191
- package/examples/bank-frick/config/index.d.ts +0 -4
- package/examples/bank-frick/config/index.js +0 -54
- package/examples/bank-frick/index.d.ts +0 -2
- package/examples/bank-frick/index.js +0 -14
- package/examples/bank-frick/util.d.ts +0 -4
- package/examples/bank-frick/util.js +0 -39
- 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/index.js +0 -10
- 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/config/index.js +0 -15
- package/examples/ncfx/index.d.ts +0 -2
- package/examples/ncfx/index.js +0 -10
- package/examples/ncfx/websocket.d.ts +0 -36
- package/examples/ncfx/websocket.js +0 -72
- package/index.d.ts +0 -11
- package/index.js +0 -133
- package/metrics/constants.d.ts +0 -16
- package/metrics/constants.js +0 -25
- package/metrics/index.d.ts +0 -15
- package/metrics/index.js +0 -122
- package/metrics/util.d.ts +0 -7
- package/metrics/util.js +0 -9
- 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/batch-warming.js +0 -52
- 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/coingecko/rest.js +0 -50
- 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/override-functions.js +0 -40
- 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/background/fixed-frequency.js +0 -35
- package/rate-limiting/index.d.ts +0 -54
- package/rate-limiting/index.js +0 -63
- package/rate-limiting/metrics.d.ts +0 -3
- package/rate-limiting/metrics.js +0 -44
- package/rate-limiting/request/simple-counting.d.ts +0 -20
- package/rate-limiting/request/simple-counting.js +0 -62
- package/test.d.ts +0 -1
- package/test.js +0 -6
- package/transports/batch-warming.d.ts +0 -35
- package/transports/batch-warming.js +0 -101
- package/transports/index.d.ts +0 -70
- package/transports/index.js +0 -87
- package/transports/metrics.d.ts +0 -21
- package/transports/metrics.js +0 -105
- package/transports/rest.d.ts +0 -44
- package/transports/rest.js +0 -131
- package/transports/util.d.ts +0 -8
- package/transports/util.js +0 -85
- package/transports/websocket.d.ts +0 -81
- package/transports/websocket.js +0 -168
- 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/index.js +0 -35
- package/util/logger.d.ts +0 -42
- package/util/logger.js +0 -62
- package/util/request.d.ts +0 -57
- package/util/request.js +0 -2
- package/util/subscription-set/expiring-sorted-set.d.ts +0 -22
- package/util/subscription-set/expiring-sorted-set.js +0 -47
- package/util/subscription-set/subscription-set.d.ts +0 -18
- package/util/subscription-set/subscription-set.js +0 -19
- package/util/test-payload-loader.d.ts +0 -25
- package/util/test-payload-loader.js +0 -83
- package/validation/error.d.ts +0 -50
- package/validation/error.js +0 -79
- package/validation/index.d.ts +0 -5
- package/validation/index.js +0 -91
- package/validation/input-params.d.ts +0 -15
- package/validation/input-params.js +0 -30
- package/validation/override-functions.d.ts +0 -3
- package/validation/override-functions.js +0 -40
- package/validation/preset-tokens.json +0 -23
- package/validation/validator.d.ts +0 -47
- package/validation/validator.js +0 -303
package/config/index.js
DELETED
|
@@ -1,380 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// Import { getRandomRequiredEnv, getRandomEnv, getEnv } from '../util'
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.buildAdapterConfig = exports.BaseSettings = void 0;
|
|
5
|
-
exports.BaseSettings = {
|
|
6
|
-
// V2 compat
|
|
7
|
-
// TODO: Remove non used in v3 ones
|
|
8
|
-
API_ENDPOINT: {
|
|
9
|
-
description: 'The URL that the certain transports use to retrieve data',
|
|
10
|
-
type: 'string',
|
|
11
|
-
},
|
|
12
|
-
API_KEY: {
|
|
13
|
-
description: 'Default setting for an EA key',
|
|
14
|
-
type: 'string',
|
|
15
|
-
},
|
|
16
|
-
// API_TIMEOUT: {
|
|
17
|
-
// type: 'number',
|
|
18
|
-
// default: 30000,
|
|
19
|
-
// },
|
|
20
|
-
// API_VERBOSE: {
|
|
21
|
-
// type: 'boolean',
|
|
22
|
-
// },
|
|
23
|
-
BASE_URL: {
|
|
24
|
-
description: 'Starting path for the EA handler endpoint',
|
|
25
|
-
type: 'string',
|
|
26
|
-
default: '/',
|
|
27
|
-
},
|
|
28
|
-
// CACHE_ENABLED: {
|
|
29
|
-
// type: 'boolean',
|
|
30
|
-
// default: true,
|
|
31
|
-
// },
|
|
32
|
-
// CACHE_KEY_GROUP: {
|
|
33
|
-
// type: 'string',
|
|
34
|
-
// },
|
|
35
|
-
CACHE_MAX_AGE: {
|
|
36
|
-
description: 'Maximum amount of time (in ms) that a response will stay cached',
|
|
37
|
-
type: 'number',
|
|
38
|
-
default: 90000,
|
|
39
|
-
},
|
|
40
|
-
// CACHE_MAX_ITEMS: {
|
|
41
|
-
// type: 'number',
|
|
42
|
-
// default: 1000,
|
|
43
|
-
// },
|
|
44
|
-
// CACHE_MIN_AGE: {
|
|
45
|
-
// type: 'number',
|
|
46
|
-
// default: 30000,
|
|
47
|
-
// },
|
|
48
|
-
// CACHE_REDIS_CONNECTION_TIMEOUT: {
|
|
49
|
-
// type: 'number',
|
|
50
|
-
// default: 15000,
|
|
51
|
-
// },
|
|
52
|
-
CACHE_REDIS_HOST: {
|
|
53
|
-
description: 'Hostname for the Redis instance to be used',
|
|
54
|
-
type: 'string',
|
|
55
|
-
default: '127.0.0.1',
|
|
56
|
-
},
|
|
57
|
-
// CACHE_REDIS_MAX_QUEUED_ITEMS: {
|
|
58
|
-
// type: 'number',
|
|
59
|
-
// default: 100,
|
|
60
|
-
// },
|
|
61
|
-
// CACHE_REDIS_MAX_RECONNECT_COOLDOWN: {
|
|
62
|
-
// type: 'number',
|
|
63
|
-
// default: 3000,
|
|
64
|
-
// },
|
|
65
|
-
// CACHE_REDIS_PASSWORD: {
|
|
66
|
-
// type: 'string',
|
|
67
|
-
// },
|
|
68
|
-
// CACHE_REDIS_PATH: {
|
|
69
|
-
// type: 'string',
|
|
70
|
-
// },
|
|
71
|
-
CACHE_REDIS_PORT: {
|
|
72
|
-
description: 'Port for the Redis instance to be used',
|
|
73
|
-
type: 'number',
|
|
74
|
-
default: 6379,
|
|
75
|
-
},
|
|
76
|
-
// CACHE_REDIS_TIMEOUT: {
|
|
77
|
-
// type: 'number',
|
|
78
|
-
// default: 500,
|
|
79
|
-
// },
|
|
80
|
-
// CACHE_REDIS_URL: {
|
|
81
|
-
// type: 'string',
|
|
82
|
-
// },
|
|
83
|
-
CACHE_TYPE: {
|
|
84
|
-
description: 'The type of cache to use throughout the EA',
|
|
85
|
-
type: 'enum',
|
|
86
|
-
default: 'local',
|
|
87
|
-
options: ['local', 'redis'],
|
|
88
|
-
},
|
|
89
|
-
// CACHE_UPDATE_AGE_ON_GET: {
|
|
90
|
-
// type: 'boolean',
|
|
91
|
-
// default: false,
|
|
92
|
-
// },
|
|
93
|
-
CORRELATION_ID_ENABLED: {
|
|
94
|
-
description: 'Flag to enable correlation IDs for sent requests in logging',
|
|
95
|
-
type: 'boolean',
|
|
96
|
-
default: true,
|
|
97
|
-
},
|
|
98
|
-
// DEBUG: {
|
|
99
|
-
// type: 'boolean',
|
|
100
|
-
// },
|
|
101
|
-
// DEFAULT_WS_HEARTBEAT_INTERVAL: {
|
|
102
|
-
// type: 'number',
|
|
103
|
-
// default: 30000,
|
|
104
|
-
// },
|
|
105
|
-
EA_PORT: {
|
|
106
|
-
description: 'Port through which the EA will listen for REST requests (if mode is set to "reader" or "reader-writer")',
|
|
107
|
-
type: 'number',
|
|
108
|
-
default: 8080,
|
|
109
|
-
},
|
|
110
|
-
// ENV_ADAPTER_URL: {
|
|
111
|
-
// type: 'string',
|
|
112
|
-
// },
|
|
113
|
-
// ERROR_CAPACITY: {
|
|
114
|
-
// type: 'number',
|
|
115
|
-
// },
|
|
116
|
-
EXPERIMENTAL_METRICS_ENABLED: {
|
|
117
|
-
description: 'Flag to specify whether or not to collect metrics. Used as fallback for METRICS_ENABLED',
|
|
118
|
-
type: 'boolean',
|
|
119
|
-
default: true,
|
|
120
|
-
},
|
|
121
|
-
// LEGACY_ENV_ADAPTER_URL: {
|
|
122
|
-
// type: 'string',
|
|
123
|
-
// },
|
|
124
|
-
LOG_LEVEL: {
|
|
125
|
-
description: 'Minimum level required for logs to be output',
|
|
126
|
-
type: 'string',
|
|
127
|
-
default: 'info',
|
|
128
|
-
},
|
|
129
|
-
METRICS_ENABLED: {
|
|
130
|
-
description: 'Flag to specify whether or not to startup the metrics server',
|
|
131
|
-
type: 'boolean',
|
|
132
|
-
default: true,
|
|
133
|
-
},
|
|
134
|
-
METRICS_NAME: {
|
|
135
|
-
description: 'Metrics name',
|
|
136
|
-
type: 'string',
|
|
137
|
-
},
|
|
138
|
-
METRICS_PORT: {
|
|
139
|
-
description: 'Port metrics will be exposed to',
|
|
140
|
-
type: 'number',
|
|
141
|
-
default: 9080,
|
|
142
|
-
},
|
|
143
|
-
METRICS_USE_BASE_URL: {
|
|
144
|
-
description: 'Flag to specify whether or not to prepend the BASE_URL to the metrics endpoint',
|
|
145
|
-
type: 'boolean',
|
|
146
|
-
},
|
|
147
|
-
RATE_LIMIT_API_TIER: {
|
|
148
|
-
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
|
-
type: 'string',
|
|
150
|
-
},
|
|
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
|
-
// },
|
|
170
|
-
// REQUEST_COALESCING_ENTROPY_MAX: {
|
|
171
|
-
// type: 'number',
|
|
172
|
-
// default: 0,
|
|
173
|
-
// },
|
|
174
|
-
// REQUEST_COALESCING_INTERVAL_COEFFICIENT: {
|
|
175
|
-
// type: 'number',
|
|
176
|
-
// default: 2,
|
|
177
|
-
// },
|
|
178
|
-
// REQUEST_COALESCING_INTERVAL_MAX: {
|
|
179
|
-
// type: 'number',
|
|
180
|
-
// default: 1000,
|
|
181
|
-
// },
|
|
182
|
-
// REQUEST_COALESCING_INTERVAL: {
|
|
183
|
-
// type: 'number',
|
|
184
|
-
// default: 100,
|
|
185
|
-
// },
|
|
186
|
-
// REQUEST_COALESCING_MAX_RETRIES: {
|
|
187
|
-
// type: 'number',
|
|
188
|
-
// default: 5,
|
|
189
|
-
// },
|
|
190
|
-
// RETRY: {
|
|
191
|
-
// type: 'boolean',
|
|
192
|
-
// default: 1,
|
|
193
|
-
// },
|
|
194
|
-
// SERVER_RATE_LIMIT_MAX: {
|
|
195
|
-
// type: 'number',
|
|
196
|
-
// default: 250,
|
|
197
|
-
// },
|
|
198
|
-
// SERVER_SLOW_DOWN_AFTER_FACTOR: {
|
|
199
|
-
// type: 'number',
|
|
200
|
-
// default: 0.8,
|
|
201
|
-
// },
|
|
202
|
-
// SERVER_SLOW_DOWN_DELAY_MS: {
|
|
203
|
-
// type: 'number',
|
|
204
|
-
// default: 500,
|
|
205
|
-
// },
|
|
206
|
-
// TIMEOUT: {
|
|
207
|
-
// type: 'number',
|
|
208
|
-
// },
|
|
209
|
-
// WARMUP_ENABLED: {
|
|
210
|
-
// type: 'boolean',
|
|
211
|
-
// default: true,
|
|
212
|
-
// },
|
|
213
|
-
// WARMUP_INTERVAL: {
|
|
214
|
-
// type: 'number',
|
|
215
|
-
// },
|
|
216
|
-
WARMUP_SUBSCRIPTION_TTL: {
|
|
217
|
-
type: 'number',
|
|
218
|
-
description: 'TTL for batch warmer subscriptions',
|
|
219
|
-
default: 10000,
|
|
220
|
-
},
|
|
221
|
-
// WARMUP_UNHEALTHY_THRESHOLD: {
|
|
222
|
-
// type: 'number',
|
|
223
|
-
// default: 3,
|
|
224
|
-
// },
|
|
225
|
-
// WS_API_ENDPOINT: {
|
|
226
|
-
// type: 'string',
|
|
227
|
-
// },
|
|
228
|
-
// WS_API_KEY: {
|
|
229
|
-
// type: 'string',
|
|
230
|
-
// },
|
|
231
|
-
// WS_CONNECTION_KEY: {
|
|
232
|
-
// type: 'string',
|
|
233
|
-
// default: 1,
|
|
234
|
-
// },
|
|
235
|
-
// WS_CONNECTION_LIMIT: {
|
|
236
|
-
// type: 'number',
|
|
237
|
-
// default: 1,
|
|
238
|
-
// },
|
|
239
|
-
// WS_CONNECTION_RETRY_DELAY: {
|
|
240
|
-
// type: 'number',
|
|
241
|
-
// default: 1000,
|
|
242
|
-
// },
|
|
243
|
-
// WS_CONNECTION_RETRY_LIMIT: {
|
|
244
|
-
// type: 'number',
|
|
245
|
-
// default: 3,
|
|
246
|
-
// },
|
|
247
|
-
// WS_CONNECTION_TTL: {
|
|
248
|
-
// type: 'number',
|
|
249
|
-
// default: 70000,
|
|
250
|
-
// },
|
|
251
|
-
// WS_ENABLED: {
|
|
252
|
-
// type: 'boolean',
|
|
253
|
-
// default: false,
|
|
254
|
-
// },
|
|
255
|
-
// WS_SUBSCRIPTION_LIMIT: {
|
|
256
|
-
// type: 'number',
|
|
257
|
-
// default: 10,
|
|
258
|
-
// },
|
|
259
|
-
// WS_SUBSCRIPTION_PRIORITY_LIST: {
|
|
260
|
-
// type: 'string',
|
|
261
|
-
// },
|
|
262
|
-
// WS_SUBSCRIPTION_TTL: {
|
|
263
|
-
// type: 'number',
|
|
264
|
-
// default: 120000,
|
|
265
|
-
// },
|
|
266
|
-
// WS_SUBSCRIPTION_UNRESPONSIVE_TTL: {
|
|
267
|
-
// type: 'number',
|
|
268
|
-
// default: false,
|
|
269
|
-
// },
|
|
270
|
-
// WS_TIME_UNTIL_HANDLE_NEXT_MESSAGE_OVERRIDE: {
|
|
271
|
-
// type: 'number',
|
|
272
|
-
// },
|
|
273
|
-
// V3
|
|
274
|
-
CACHE_POLLING_MAX_RETRIES: {
|
|
275
|
-
description: 'Max amount of times to attempt to find EA response in the cache after the Transport has been set up',
|
|
276
|
-
type: 'number',
|
|
277
|
-
default: 10,
|
|
278
|
-
},
|
|
279
|
-
CACHE_POLLING_SLEEP_MS: {
|
|
280
|
-
description: 'The number of ms to sleep between each retry to fetch the EA response in the cache',
|
|
281
|
-
type: 'number',
|
|
282
|
-
default: 200,
|
|
283
|
-
},
|
|
284
|
-
DEFAULT_CACHE_KEY: {
|
|
285
|
-
description: 'Default key to be used when one cannot be determined from request parameters',
|
|
286
|
-
type: 'string',
|
|
287
|
-
default: 'DEFAULT_CACHE_KEY',
|
|
288
|
-
},
|
|
289
|
-
EA_HOST: {
|
|
290
|
-
description: 'Host this EA will listen for REST requests on (if mode is set to "reader" or "reader-writer")',
|
|
291
|
-
type: 'string',
|
|
292
|
-
default: '::',
|
|
293
|
-
},
|
|
294
|
-
EA_MODE: {
|
|
295
|
-
description: 'Port this EA will listen for REST requests on (if mode is set to "reader" or "reader-writer")',
|
|
296
|
-
type: 'enum',
|
|
297
|
-
default: 'reader-writer',
|
|
298
|
-
options: ['reader', 'writer', 'reader-writer'],
|
|
299
|
-
},
|
|
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
|
-
MAX_COMMON_KEY_SIZE: {
|
|
311
|
-
description: 'Maximum amount of characters that the common part of the cache key or feed ID can have',
|
|
312
|
-
type: 'number',
|
|
313
|
-
default: 300,
|
|
314
|
-
validate: (value) => {
|
|
315
|
-
if (!(value && value >= 150 && value <= 500)) {
|
|
316
|
-
return 'MAX_COMMON_KEY_SIZE must be a number between 150 and 500';
|
|
317
|
-
}
|
|
318
|
-
},
|
|
319
|
-
},
|
|
320
|
-
// CACHE_KEY_IGNORED_PROPS : {
|
|
321
|
-
// description: 'Properties to ignore when generating a feed ID for requests',
|
|
322
|
-
// type: 'string'
|
|
323
|
-
// }
|
|
324
|
-
SMOKE_TEST_PAYLOAD_FILE_NAME: {
|
|
325
|
-
description: 'Name of the test payload file used for the smoke endpoint',
|
|
326
|
-
type: 'string',
|
|
327
|
-
},
|
|
328
|
-
};
|
|
329
|
-
const buildAdapterConfig = ({ overrides = {}, customSettings = {}, }) => {
|
|
330
|
-
const validationErrors = [];
|
|
331
|
-
const vars = {};
|
|
332
|
-
// Iterate base adapter env vars
|
|
333
|
-
for (const [key, config] of Object.entries(exports.BaseSettings)) {
|
|
334
|
-
const value = getEnv(key, config) ?? overrides?.[key] ?? config.default;
|
|
335
|
-
vars[key] = value;
|
|
336
|
-
}
|
|
337
|
-
// Iterate custom vars
|
|
338
|
-
for (const [key, config] of Object.entries(customSettings)) {
|
|
339
|
-
if (exports.BaseSettings[key]) {
|
|
340
|
-
throw new Error(`Custom env var "${key}" declared, but a base framework env var with that name already exists.`);
|
|
341
|
-
}
|
|
342
|
-
const value = getEnv(key, config) ?? config.default;
|
|
343
|
-
// Check if a required setting has been provided
|
|
344
|
-
if (config.required && value === null) {
|
|
345
|
-
validationErrors.push(`${key}: Value is required, but none was provided`);
|
|
346
|
-
}
|
|
347
|
-
else if (config.validate) {
|
|
348
|
-
// Cast validate to unknown because TS can't select one of multiple variants of the validate function signature
|
|
349
|
-
const validationRes = config.validate(value);
|
|
350
|
-
if (validationRes) {
|
|
351
|
-
validationErrors.push(`${key}: ${validationRes}`);
|
|
352
|
-
}
|
|
353
|
-
}
|
|
354
|
-
vars[key] = value;
|
|
355
|
-
}
|
|
356
|
-
if (validationErrors.length > 0) {
|
|
357
|
-
throw new Error(`Validation failed for the following variables:\n ${validationErrors.join('\n')}`);
|
|
358
|
-
}
|
|
359
|
-
return vars;
|
|
360
|
-
};
|
|
361
|
-
exports.buildAdapterConfig = buildAdapterConfig;
|
|
362
|
-
const getEnv = (name, config) => {
|
|
363
|
-
const value = process.env[name];
|
|
364
|
-
if (!value) {
|
|
365
|
-
return null;
|
|
366
|
-
}
|
|
367
|
-
switch (config.type) {
|
|
368
|
-
case 'string':
|
|
369
|
-
return value;
|
|
370
|
-
case 'number':
|
|
371
|
-
return parseInt(value);
|
|
372
|
-
case 'boolean':
|
|
373
|
-
return value === 'true';
|
|
374
|
-
case 'enum':
|
|
375
|
-
if (!config.options?.includes(value)) {
|
|
376
|
-
throw new Error(`Env var "${name}" has value "${value}" which is not included in the valid options (${config.options})`);
|
|
377
|
-
}
|
|
378
|
-
return value;
|
|
379
|
-
}
|
|
380
|
-
};
|
|
@@ -1,31 +0,0 @@
|
|
|
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: {
|
|
18
|
-
[tierName: string]: HTTPTier;
|
|
19
|
-
};
|
|
20
|
-
ws: {
|
|
21
|
-
[tierName: string]: WSTier;
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
interface ProviderRateLimit {
|
|
25
|
-
second: number;
|
|
26
|
-
minute: number;
|
|
27
|
-
}
|
|
28
|
-
export declare const getHTTPLimit: (provider: string, limits: Limits, tier: string, timeframe: RateLimitTimeFrame) => number;
|
|
29
|
-
export declare const getRateLimit: (provider: string, limits: Limits, tier: string) => ProviderRateLimit;
|
|
30
|
-
export declare const getWSLimits: (provider: string, limits: Limits, tier: string) => WSTier;
|
|
31
|
-
export {};
|
|
@@ -1,79 +0,0 @@
|
|
|
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 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);
|
|
60
|
-
};
|
|
61
|
-
const calculateWSLimits = (providerLimit) => {
|
|
62
|
-
return {
|
|
63
|
-
connections: providerLimit.connections,
|
|
64
|
-
subscriptions: providerLimit.subscriptions,
|
|
65
|
-
};
|
|
66
|
-
};
|
|
67
|
-
const calculateRateLimit = (providerLimit) => {
|
|
68
|
-
let quota = providerLimit.rateLimit1m;
|
|
69
|
-
if (!quota && providerLimit?.rateLimit1h) {
|
|
70
|
-
quota = providerLimit?.rateLimit1h / 60;
|
|
71
|
-
}
|
|
72
|
-
else if (!quota && providerLimit?.rateLimit1s) {
|
|
73
|
-
quota = providerLimit?.rateLimit1s * 60;
|
|
74
|
-
}
|
|
75
|
-
return {
|
|
76
|
-
second: providerLimit?.rateLimit1s || (quota / 60) * exports.BURST_UNDEFINED_QUOTA_MULTIPLE,
|
|
77
|
-
minute: quota,
|
|
78
|
-
};
|
|
79
|
-
};
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { AxiosRequestConfig, AxiosResponse } from 'axios';
|
|
2
|
-
import { AdapterInputParameters, BankFrickAccountsRequestSchema, BankFrickAccountsResponseSchema, SigningAlgorithm } from './types';
|
|
3
|
-
import { customSettings } from './config';
|
|
4
|
-
import { Transport } from '../../transports';
|
|
5
|
-
import { AdapterRequest, AdapterResponse } from '../../util';
|
|
6
|
-
import { AdapterConfig } from '../../config';
|
|
7
|
-
import { Cache } from '../../cache';
|
|
8
|
-
import { AdapterDependencies, AdapterEndpoint } from '../../adapter';
|
|
9
|
-
/**
|
|
10
|
-
* RestTransport implementation for Bank Frick, which has unusually complex requirements for an EA
|
|
11
|
-
* The RestTransport is generally built to make a single request and return a single response.
|
|
12
|
-
* This transport instead is used to fetch and process pages of data, and also requires a JWT to run
|
|
13
|
-
*
|
|
14
|
-
* This transport does all the heavy lifting in setup(), which is where the paging happens, and it
|
|
15
|
-
* also has complex retry logic that will attempt to refresh the JWT when certain HTTP errors occur
|
|
16
|
-
*/
|
|
17
|
-
export declare class BankFrickAccountsTransport implements Transport<AdapterInputParameters, number, typeof customSettings> {
|
|
18
|
-
token: string;
|
|
19
|
-
cache: Cache;
|
|
20
|
-
initialize(dependencies: AdapterDependencies): Promise<void>;
|
|
21
|
-
hasBeenSetUp(): Promise<boolean>;
|
|
22
|
-
/**
|
|
23
|
-
* Creates an AxiosRequestConfig object for fetching a page of accounts from the Bank Frick API
|
|
24
|
-
*/
|
|
25
|
-
prepareRequest(firstPosition: number, inputParams: AdapterInputParameters, config: AdapterConfig<typeof customSettings>): AxiosRequestConfig<BankFrickAccountsRequestSchema>;
|
|
26
|
-
/**
|
|
27
|
-
* Request with retry logic for Bank Frick's API. In addition to standard retry logic, this function
|
|
28
|
-
* compares errors against expected errors from the Bank Frick API, and will throw without retries
|
|
29
|
-
* on a known fatal error, or try to refresh the JWT on a known auth error
|
|
30
|
-
**/
|
|
31
|
-
makeRequest(axiosRequest: AxiosRequestConfig<BankFrickAccountsRequestSchema>, config: AdapterConfig<typeof customSettings>, signingAlgorithm?: SigningAlgorithm): Promise<AxiosResponse<BankFrickAccountsResponseSchema>>;
|
|
32
|
-
validateInputParams(params: AdapterInputParameters): string[];
|
|
33
|
-
/**
|
|
34
|
-
* Fetches pages of data from the Bank Frick API, scans for accounts by IBAN, and returns the balance
|
|
35
|
-
* of all found accounts. Returns a 404 if any IBAN isn't found.
|
|
36
|
-
*/
|
|
37
|
-
setup(req: AdapterRequest<AdapterInputParameters>, config: AdapterConfig<typeof customSettings>): Promise<AdapterResponse<number>>;
|
|
38
|
-
}
|
|
39
|
-
export declare const accountsRestEndpoint: AdapterEndpoint;
|