@chainlink/external-adapter-framework 0.0.8 → 0.0.12
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 +9 -0
- package/.eslintrc.js +96 -0
- package/.github/README.MD +17 -0
- package/.github/actions/setup/action.yaml +13 -0
- package/.github/workflows/main.yaml +39 -0
- package/.github/workflows/publish.yaml +20 -0
- package/.prettierignore +13 -0
- package/.yarnrc +0 -0
- package/README.md +103 -0
- package/dist/src/adapter.d.ts +135 -0
- package/dist/src/adapter.js +145 -0
- package/{package → dist/src}/background-executor.d.ts +2 -2
- package/{background-executor.js → dist/src/background-executor.js} +0 -0
- package/{cache → dist/src/cache}/factory.d.ts +0 -0
- package/{package → dist/src}/cache/factory.js +0 -2
- package/{package → dist/src}/cache/index.d.ts +10 -6
- package/{package → dist/src}/cache/index.js +13 -9
- package/{cache → dist/src/cache}/local.d.ts +0 -0
- package/{cache → dist/src/cache}/local.js +0 -0
- package/{cache → dist/src/cache}/metrics.d.ts +0 -0
- package/{cache → dist/src/cache}/metrics.js +0 -0
- package/{cache → dist/src/cache}/redis.d.ts +0 -0
- package/{package → dist/src}/cache/redis.js +5 -5
- package/dist/src/chainlink-external-adapter-framework-0.0.6.tgz +0 -0
- package/{package → dist/src}/config/index.d.ts +20 -1
- package/{package → dist/src}/config/index.js +24 -9
- package/{config → dist/src/config}/provider-limits.d.ts +0 -0
- package/{config → dist/src/config}/provider-limits.js +0 -0
- package/dist/src/examples/bank-frick/accounts.d.ts +39 -0
- package/dist/src/examples/bank-frick/accounts.js +192 -0
- package/dist/src/examples/bank-frick/config/index.d.ts +4 -0
- package/dist/src/examples/bank-frick/config/index.js +54 -0
- package/dist/src/examples/bank-frick/index.d.ts +2 -0
- package/dist/src/examples/bank-frick/index.js +15 -0
- package/dist/src/examples/bank-frick/util.d.ts +4 -0
- package/dist/src/examples/bank-frick/util.js +39 -0
- package/dist/src/examples/coingecko/batch-warming.d.ts +7 -0
- package/{package → dist/src}/examples/coingecko/batch-warming.js +3 -2
- package/dist/src/examples/coingecko/index.d.ts +2 -0
- package/{package → dist/src}/examples/coingecko/index.js +3 -2
- package/dist/src/examples/coingecko/rest.d.ts +12 -0
- package/{package → dist/src}/examples/coingecko/rest.js +3 -2
- package/{examples → dist/src/examples}/ncfx/config/index.d.ts +0 -0
- package/{examples → dist/src/examples}/ncfx/config/index.js +0 -0
- package/dist/src/examples/ncfx/index.d.ts +13 -0
- package/{package → dist/src}/examples/ncfx/index.js +3 -2
- package/{package → dist/src}/examples/ncfx/websocket.d.ts +12 -1
- package/{package → dist/src}/examples/ncfx/websocket.js +3 -2
- package/{package → dist/src}/index.d.ts +2 -3
- package/{package → dist/src}/index.js +55 -19
- package/{metrics → dist/src/metrics}/constants.d.ts +0 -0
- package/{metrics → dist/src/metrics}/constants.js +0 -0
- package/{metrics → dist/src/metrics}/index.d.ts +0 -0
- package/{package → dist/src}/metrics/index.js +0 -1
- package/dist/src/metrics/util.d.ts +7 -0
- package/{package → dist/src}/metrics/util.js +2 -2
- package/{adapter.d.ts → dist/src/package/adapter.d.ts} +2 -2
- package/{adapter.js → dist/src/package/adapter.js} +0 -0
- package/{background-executor.d.ts → dist/src/package/background-executor.d.ts} +0 -0
- package/{package → dist/src/package}/background-executor.js +0 -0
- package/{package → dist/src/package}/cache/factory.d.ts +0 -0
- package/{cache → dist/src/package/cache}/factory.js +0 -0
- package/{cache → dist/src/package/cache}/index.d.ts +0 -0
- package/{cache → dist/src/package/cache}/index.js +0 -0
- package/{package → dist/src/package}/cache/local.d.ts +0 -0
- package/{package → dist/src/package}/cache/local.js +0 -0
- package/{package → dist/src/package}/cache/metrics.d.ts +0 -0
- package/{package → dist/src/package}/cache/metrics.js +0 -0
- package/{package → dist/src/package}/cache/redis.d.ts +0 -0
- package/{cache → dist/src/package/cache}/redis.js +0 -0
- package/{config → dist/src/package/config}/index.d.ts +0 -0
- package/{config → dist/src/package/config}/index.js +0 -0
- package/{package → dist/src/package}/config/provider-limits.d.ts +0 -0
- package/{package → dist/src/package}/config/provider-limits.js +2 -1
- package/{examples → dist/src/package/examples}/coingecko/batch-warming.d.ts +0 -0
- package/{examples → dist/src/package/examples}/coingecko/batch-warming.js +0 -0
- package/{examples → dist/src/package/examples}/coingecko/index.d.ts +0 -0
- package/{examples → dist/src/package/examples}/coingecko/index.js +0 -0
- package/{examples → dist/src/package/examples}/coingecko/rest.d.ts +0 -0
- package/{examples → dist/src/package/examples}/coingecko/rest.js +0 -0
- package/{package → dist/src/package}/examples/ncfx/config/index.d.ts +0 -0
- package/{package → dist/src/package}/examples/ncfx/config/index.js +0 -0
- package/{examples → dist/src/package/examples}/ncfx/index.d.ts +0 -0
- package/{examples → dist/src/package/examples}/ncfx/index.js +0 -0
- package/{examples → dist/src/package/examples}/ncfx/websocket.d.ts +0 -0
- package/{examples → dist/src/package/examples}/ncfx/websocket.js +0 -0
- package/{index.d.ts → dist/src/package/index.d.ts} +1 -1
- package/{index.js → dist/src/package/index.js} +0 -0
- package/{package → dist/src/package}/metrics/constants.d.ts +0 -0
- package/{package → dist/src/package}/metrics/constants.js +0 -0
- package/{package → dist/src/package}/metrics/index.d.ts +0 -0
- package/{metrics → dist/src/package/metrics}/index.js +0 -0
- package/{metrics → dist/src/package/metrics}/util.d.ts +0 -0
- package/{metrics → dist/src/package/metrics}/util.js +0 -0
- package/dist/src/package/package.json +72 -0
- package/{package → dist/src/package}/rate-limiting/background/fixed-frequency.d.ts +0 -0
- package/{package → dist/src/package}/rate-limiting/background/fixed-frequency.js +0 -0
- package/{package → dist/src/package}/rate-limiting/index.d.ts +2 -2
- package/{package → dist/src/package}/rate-limiting/index.js +0 -0
- package/{package → dist/src/package}/rate-limiting/metrics.d.ts +0 -0
- package/{package → dist/src/package}/rate-limiting/metrics.js +0 -0
- package/{package → dist/src/package}/rate-limiting/request/simple-counting.d.ts +0 -0
- package/{package → dist/src/package}/rate-limiting/request/simple-counting.js +0 -0
- package/{package → dist/src/package}/test.d.ts +0 -0
- package/{package → dist/src/package}/test.js +0 -0
- package/{package → dist/src/package}/transports/batch-warming.d.ts +0 -0
- package/{package → dist/src/package}/transports/batch-warming.js +0 -0
- package/{package → dist/src/package}/transports/index.d.ts +0 -0
- package/{package → dist/src/package}/transports/index.js +0 -0
- package/{package → dist/src/package}/transports/metrics.d.ts +1 -1
- package/{package → dist/src/package}/transports/metrics.js +0 -0
- package/{package → dist/src/package}/transports/rest.d.ts +0 -0
- package/{package → dist/src/package}/transports/rest.js +0 -0
- package/{package → dist/src/package}/transports/util.d.ts +0 -0
- package/{package → dist/src/package}/transports/util.js +0 -0
- package/{package → dist/src/package}/transports/websocket.d.ts +0 -0
- package/{package → dist/src/package}/transports/websocket.js +0 -0
- package/{package → dist/src/package}/util/expiring-sorted-set.d.ts +0 -0
- package/{package → dist/src/package}/util/expiring-sorted-set.js +0 -0
- package/{package → dist/src/package}/util/index.d.ts +0 -0
- package/{package → dist/src/package}/util/index.js +0 -0
- package/{package → dist/src/package}/util/logger.d.ts +0 -0
- package/{package → dist/src/package}/util/logger.js +0 -0
- package/{package → dist/src/package}/util/request.d.ts +0 -0
- package/{package → dist/src/package}/util/request.js +0 -0
- package/{package → dist/src/package}/validation/error.d.ts +0 -0
- package/{package → dist/src/package}/validation/error.js +0 -0
- package/{package → dist/src/package}/validation/index.d.ts +0 -0
- package/{package → dist/src/package}/validation/index.js +0 -0
- package/{package → dist/src/package}/validation/input-params.d.ts +0 -0
- package/{package → dist/src/package}/validation/input-params.js +0 -0
- package/{package → dist/src/package}/validation/override-functions.d.ts +0 -0
- package/{package → dist/src/package}/validation/override-functions.js +0 -0
- package/{package → dist/src/package}/validation/preset-tokens.json +0 -0
- package/{package → dist/src/package}/validation/validator.d.ts +0 -0
- package/{package → dist/src/package}/validation/validator.js +0 -0
- package/{package → dist/src}/package.json +5 -2
- package/{rate-limiting → dist/src/rate-limiting}/background/fixed-frequency.d.ts +2 -1
- package/{rate-limiting → dist/src/rate-limiting}/background/fixed-frequency.js +0 -2
- package/{rate-limiting → dist/src/rate-limiting}/index.d.ts +4 -3
- package/{rate-limiting → dist/src/rate-limiting}/index.js +0 -0
- package/{rate-limiting → dist/src/rate-limiting}/metrics.d.ts +0 -0
- package/{rate-limiting → dist/src/rate-limiting}/metrics.js +0 -0
- package/{rate-limiting → dist/src/rate-limiting}/request/simple-counting.d.ts +2 -1
- package/{rate-limiting → dist/src/rate-limiting}/request/simple-counting.js +0 -0
- package/{test.d.ts → dist/src/test.d.ts} +0 -0
- package/{test.js → dist/src/test.js} +2 -2
- package/{transports → dist/src/transports}/batch-warming.d.ts +4 -3
- package/{transports → dist/src/transports}/batch-warming.js +4 -4
- package/{transports → dist/src/transports}/index.d.ts +5 -22
- package/{transports → dist/src/transports}/index.js +3 -3
- package/{transports → dist/src/transports}/metrics.d.ts +4 -3
- package/{transports → dist/src/transports}/metrics.js +2 -2
- package/{transports → dist/src/transports}/rest.d.ts +2 -1
- package/{transports → dist/src/transports}/rest.js +3 -1
- package/{transports → dist/src/transports}/util.d.ts +0 -0
- package/{transports → dist/src/transports}/util.js +0 -0
- package/{transports → dist/src/transports}/websocket.d.ts +7 -7
- package/{transports → dist/src/transports}/websocket.js +8 -11
- package/{util → dist/src/util}/expiring-sorted-set.d.ts +0 -0
- package/{util → dist/src/util}/expiring-sorted-set.js +0 -0
- package/{util → dist/src/util}/index.d.ts +2 -1
- package/{util → dist/src/util}/index.js +1 -1
- package/{util → dist/src/util}/logger.d.ts +0 -0
- package/{util → dist/src/util}/logger.js +0 -0
- package/{util → dist/src/util}/request.d.ts +5 -3
- package/{util → dist/src/util}/request.js +0 -0
- package/dist/src/util/subscription-set/expiring-sorted-set.d.ts +22 -0
- package/dist/src/util/subscription-set/expiring-sorted-set.js +47 -0
- package/dist/src/util/subscription-set/subscription-set.d.ts +18 -0
- package/dist/src/util/subscription-set/subscription-set.js +19 -0
- package/dist/src/util/test-payload-loader.d.ts +25 -0
- package/dist/src/util/test-payload-loader.js +83 -0
- package/{validation → dist/src/validation}/error.d.ts +4 -4
- package/{validation → dist/src/validation}/error.js +1 -1
- package/{validation → dist/src/validation}/index.d.ts +0 -0
- package/{validation → dist/src/validation}/index.js +8 -3
- package/{validation → dist/src/validation}/input-params.d.ts +0 -0
- package/{validation → dist/src/validation}/input-params.js +0 -0
- package/dist/src/validation/override-functions.d.ts +3 -0
- package/{validation → dist/src/validation}/override-functions.js +0 -0
- package/{validation → dist/src/validation}/preset-tokens.json +0 -0
- package/{validation → dist/src/validation}/validator.d.ts +0 -0
- package/{validation → dist/src/validation}/validator.js +0 -0
- package/docker-compose.yaml +35 -0
- package/env.sh +54 -0
- package/env2.sh +55 -0
- package/package.json +5 -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 +130 -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/batch-warming.ts +78 -0
- package/src/examples/coingecko/index.ts +9 -0
- package/src/examples/coingecko/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/test.ts +5 -0
- package/src/transports/batch-warming.ts +122 -0
- package/src/transports/index.ts +152 -0
- package/src/transports/metrics.ts +95 -0
- package/src/transports/rest.ts +164 -0
- package/src/transports/util.ts +63 -0
- package/src/transports/websocket.ts +245 -0
- package/src/util/index.ts +22 -0
- package/src/util/logger.ts +69 -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/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 +192 -0
- package/test/metrics/ws-metrics.test.ts +225 -0
- package/test/rate-limit-config.test.ts +242 -0
- package/test/smoke.test.ts +166 -0
- package/test/transports/batch.test.ts +465 -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-payload-fail.json +3 -0
- package/test-payload.js +22 -0
- package/test-payload.json +7 -0
- package/test.sh +20 -0
- package/test2.sh +2 -0
- package/tsconfig.json +25 -0
- package/typedoc.json +6 -0
- package/webpack.config.js +23 -0
- package/chainlink-external-adapter-framework-v0.0.8.tgz +0 -0
- package/package/adapter.d.ts +0 -88
- package/package/adapter.js +0 -112
- package/package/examples/coingecko/batch-warming.d.ts +0 -2
- package/package/examples/coingecko/index.d.ts +0 -2
- package/package/examples/coingecko/rest.d.ts +0 -2
- package/package/examples/ncfx/index.d.ts +0 -2
- package/package/metrics/util.d.ts +0 -3
- package/validation/override-functions.d.ts +0 -3
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
import FakeTimers from '@sinonjs/fake-timers'
|
|
2
|
+
import test from 'ava'
|
|
3
|
+
import axios, { AxiosError } from 'axios'
|
|
4
|
+
import { Server, WebSocket } from 'mock-socket'
|
|
5
|
+
import { AddressInfo } from 'net'
|
|
6
|
+
import { expose } from '../../src'
|
|
7
|
+
import { Adapter, AdapterEndpoint } from '../../src/adapter'
|
|
8
|
+
import { DEFAULT_SHARED_MS_BETWEEN_REQUESTS } from '../../src/rate-limiting'
|
|
9
|
+
import { DEFAULT_WS_TTL, WebSocketClassProvider, WebSocketTransport } from '../../src/transports'
|
|
10
|
+
import { ProviderResult } from '../../src/util'
|
|
11
|
+
import { InputParameters } from '../../src/validation'
|
|
12
|
+
import { MockCache } from '../util'
|
|
13
|
+
|
|
14
|
+
interface AdapterRequestParams {
|
|
15
|
+
base: string
|
|
16
|
+
quote: string
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export const inputParameters: InputParameters = {
|
|
20
|
+
base: {
|
|
21
|
+
type: 'string',
|
|
22
|
+
required: true,
|
|
23
|
+
},
|
|
24
|
+
quote: {
|
|
25
|
+
type: 'string',
|
|
26
|
+
required: true,
|
|
27
|
+
},
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
interface ProviderMessage {
|
|
31
|
+
pair: string
|
|
32
|
+
value: number
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const URL = 'wss://test-ws.com/asd'
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Sets the mocked websocket instance in the provided provider class.
|
|
39
|
+
* We need this here, because the tests will connect using their instance of WebSocketClassProvider;
|
|
40
|
+
* fetching from this library to the \@chainlink/ea-bootstrap package would access _another_ instance
|
|
41
|
+
* of the same constructor. Although it should be a singleton, dependencies are different so that
|
|
42
|
+
* means that the static classes themselves are also different.
|
|
43
|
+
*
|
|
44
|
+
* @param provider - singleton WebSocketClassProvider
|
|
45
|
+
*/
|
|
46
|
+
export const mockWebSocketProvider = (provider: typeof WebSocketClassProvider): void => {
|
|
47
|
+
// Extend mock WebSocket class to bypass protocol headers error
|
|
48
|
+
class MockWebSocket extends WebSocket {
|
|
49
|
+
constructor(url: string, protocol: string | string[] | Record<string, string> | undefined) {
|
|
50
|
+
super(url, protocol instanceof Object ? undefined : protocol)
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// Need to disable typing, the mock-socket impl does not implement the ws interface fully
|
|
55
|
+
provider.set(MockWebSocket as any) // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export const websocketTransport = new WebSocketTransport({
|
|
59
|
+
url: URL,
|
|
60
|
+
handlers: {
|
|
61
|
+
async open() {
|
|
62
|
+
return
|
|
63
|
+
},
|
|
64
|
+
|
|
65
|
+
message(message: ProviderMessage): ProviderResult<AdapterRequestParams>[] {
|
|
66
|
+
const [base, quote] = message.pair.split('/')
|
|
67
|
+
return [
|
|
68
|
+
{
|
|
69
|
+
params: { base, quote },
|
|
70
|
+
value: message.value,
|
|
71
|
+
},
|
|
72
|
+
]
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
builders: {
|
|
76
|
+
subscribeMessage: (params: AdapterRequestParams) => ({
|
|
77
|
+
request: 'subscribe',
|
|
78
|
+
pair: `${params.base}/${params.quote}`,
|
|
79
|
+
}),
|
|
80
|
+
unsubscribeMessage: (params: AdapterRequestParams) => ({
|
|
81
|
+
request: 'unsubscribe',
|
|
82
|
+
pair: `${params.base}/${params.quote}`,
|
|
83
|
+
}),
|
|
84
|
+
},
|
|
85
|
+
})
|
|
86
|
+
|
|
87
|
+
export const webSocketEndpoint: AdapterEndpoint = {
|
|
88
|
+
name: 'test',
|
|
89
|
+
transport: websocketTransport,
|
|
90
|
+
inputParameters,
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
const CACHE_MAX_AGE = 1000
|
|
94
|
+
|
|
95
|
+
const adapter: Adapter = {
|
|
96
|
+
name: 'test',
|
|
97
|
+
defaultEndpoint: 'test',
|
|
98
|
+
endpoints: [webSocketEndpoint],
|
|
99
|
+
envDefaultOverrides: {
|
|
100
|
+
CACHE_MAX_AGE,
|
|
101
|
+
},
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
test('connects to websocket, subscribes, gets message, unsubscribes', async (t) => {
|
|
105
|
+
const clock = FakeTimers.install()
|
|
106
|
+
|
|
107
|
+
// Disable retries to make the testing flow easier
|
|
108
|
+
process.env['CACHE_POLLING_MAX_RETRIES'] = '0'
|
|
109
|
+
|
|
110
|
+
const base = 'ETH'
|
|
111
|
+
const quote = 'DOGE'
|
|
112
|
+
const price = 251324
|
|
113
|
+
|
|
114
|
+
// Mock WS
|
|
115
|
+
mockWebSocketProvider(WebSocketClassProvider)
|
|
116
|
+
const mockWsServer = new Server(URL, { mock: false })
|
|
117
|
+
mockWsServer.on('connection', (socket) => {
|
|
118
|
+
let counter = 0
|
|
119
|
+
const parseMessage = () => {
|
|
120
|
+
if (counter++ === 0) {
|
|
121
|
+
socket.send(
|
|
122
|
+
JSON.stringify({
|
|
123
|
+
pair: `${base}/${quote}`,
|
|
124
|
+
value: price,
|
|
125
|
+
}),
|
|
126
|
+
)
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
socket.on('message', parseMessage)
|
|
130
|
+
})
|
|
131
|
+
|
|
132
|
+
// Create mocked cache so we can listen when values are set
|
|
133
|
+
// This is a more reliable method than expecting precise clock timings
|
|
134
|
+
const mockCache = new MockCache()
|
|
135
|
+
|
|
136
|
+
// Start up adapter
|
|
137
|
+
const server = await expose(adapter, {
|
|
138
|
+
cache: mockCache,
|
|
139
|
+
})
|
|
140
|
+
const address = `http://localhost:${(server?.address() as AddressInfo)?.port}`
|
|
141
|
+
|
|
142
|
+
const makeRequest = () =>
|
|
143
|
+
axios.post(address, {
|
|
144
|
+
data: {
|
|
145
|
+
base,
|
|
146
|
+
quote,
|
|
147
|
+
},
|
|
148
|
+
})
|
|
149
|
+
|
|
150
|
+
// Expect the first response to time out
|
|
151
|
+
// The polling behavior is tested in the cache tests, so this is easier here.
|
|
152
|
+
// Start the request:
|
|
153
|
+
const errorPromise: Promise<AxiosError | undefined> = t.throwsAsync(makeRequest)
|
|
154
|
+
// Advance enough time for the initial request async flow
|
|
155
|
+
clock.tickAsync(10)
|
|
156
|
+
// Wait for the failed cache get -> instant 504
|
|
157
|
+
const error = await errorPromise
|
|
158
|
+
t.is(error?.response?.status, 504)
|
|
159
|
+
|
|
160
|
+
// Advance clock so that the batch warmer executes once again and wait for the cache to be set
|
|
161
|
+
const cacheValueSetPromise = mockCache.waitForNextSet()
|
|
162
|
+
await clock.tickAsync(DEFAULT_SHARED_MS_BETWEEN_REQUESTS + 10)
|
|
163
|
+
await cacheValueSetPromise
|
|
164
|
+
|
|
165
|
+
// Second request should find the response in the cache
|
|
166
|
+
const response = await makeRequest()
|
|
167
|
+
|
|
168
|
+
t.is(response.status, 200)
|
|
169
|
+
t.deepEqual(response.data, {
|
|
170
|
+
data: null,
|
|
171
|
+
result: price,
|
|
172
|
+
statusCode: 200,
|
|
173
|
+
})
|
|
174
|
+
|
|
175
|
+
// Wait until the cache expires, and the subscription is out
|
|
176
|
+
await clock.tickAsync(Math.ceil(CACHE_MAX_AGE / DEFAULT_WS_TTL) * DEFAULT_WS_TTL + 1)
|
|
177
|
+
|
|
178
|
+
// Now that the cache is out and the subscription no longer there, this should time out
|
|
179
|
+
const error2: AxiosError | undefined = await t.throwsAsync(makeRequest)
|
|
180
|
+
t.is(error2?.response?.status, 504)
|
|
181
|
+
|
|
182
|
+
clock.uninstall()
|
|
183
|
+
})
|
package/test/util.ts
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { InstalledClock } from '@sinonjs/fake-timers'
|
|
2
|
+
import { AdapterDependencies } from '../src/adapter'
|
|
3
|
+
import { LocalCache } from '../src/cache'
|
|
4
|
+
import { SettingsMap } from '../src/config'
|
|
5
|
+
import { Transport } from '../src/transports'
|
|
6
|
+
import { AdapterRequest, AdapterResponse } from '../src/util'
|
|
7
|
+
|
|
8
|
+
export class NopTransport implements Transport<null, null, SettingsMap> {
|
|
9
|
+
async initialize(dependencies: AdapterDependencies): Promise<void> {
|
|
10
|
+
return
|
|
11
|
+
}
|
|
12
|
+
async hasBeenSetUp(): Promise<boolean> {
|
|
13
|
+
return false
|
|
14
|
+
}
|
|
15
|
+
async setup(req: AdapterRequest<unknown>): Promise<void | AdapterResponse<null>> {
|
|
16
|
+
return
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
type Resolve<T> = (value: T) => void
|
|
21
|
+
export const deferredPromise = <T>(): [Promise<T>, Resolve<T>] => {
|
|
22
|
+
let resolve!: Resolve<T>
|
|
23
|
+
const promise = new Promise<T>((r) => {
|
|
24
|
+
resolve = r
|
|
25
|
+
})
|
|
26
|
+
return [promise, resolve]
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export class MockCache extends LocalCache {
|
|
30
|
+
private awaitingPromiseResolve?: (value: unknown) => void
|
|
31
|
+
|
|
32
|
+
waitForNextSet() {
|
|
33
|
+
// eslint-disable-next-line no-promise-executor-return
|
|
34
|
+
return new Promise((resolve) => (this.awaitingPromiseResolve = resolve))
|
|
35
|
+
}
|
|
36
|
+
override async set(key: string, value: unknown, ttl: number): Promise<void> {
|
|
37
|
+
super.set(key, value, ttl)
|
|
38
|
+
if (this.awaitingPromiseResolve) {
|
|
39
|
+
this.awaitingPromiseResolve(value)
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export async function runPeriodicAsyncBackgroundExecution(
|
|
45
|
+
clock: InstalledClock,
|
|
46
|
+
{
|
|
47
|
+
interval,
|
|
48
|
+
times,
|
|
49
|
+
stepValidation,
|
|
50
|
+
}: {
|
|
51
|
+
interval: number
|
|
52
|
+
times: number
|
|
53
|
+
stepValidation: (iteration: number) => boolean
|
|
54
|
+
},
|
|
55
|
+
) {
|
|
56
|
+
for (let i = 0; i < times; i++) {
|
|
57
|
+
// Tick once for the interval
|
|
58
|
+
await clock.tickAsync(interval)
|
|
59
|
+
|
|
60
|
+
// Then use auxiliary method to ensure that the background process, if it
|
|
61
|
+
// spawns new timers, gets executed to completion
|
|
62
|
+
await runAllUntil(clock, () => stepValidation(i))
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
async function runAllUntil(clock: InstalledClock, isComplete: () => boolean): Promise<void> {
|
|
67
|
+
while (!isComplete()) {
|
|
68
|
+
await clock.nextAsync()
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export async function runAllUntilTime(clock: InstalledClock, time: number): Promise<void> {
|
|
73
|
+
const targetTime = clock.now + time
|
|
74
|
+
while (clock.now < targetTime) {
|
|
75
|
+
await clock.nextAsync()
|
|
76
|
+
}
|
|
77
|
+
}
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import untypedTest, { TestFn } from 'ava'
|
|
2
|
+
import axios, { AxiosError } from 'axios'
|
|
3
|
+
import { AddressInfo } from 'net'
|
|
4
|
+
import { expose } from '../src'
|
|
5
|
+
import { Adapter, AdapterEndpoint } from '../src/adapter'
|
|
6
|
+
import { AdapterResponse } from '../src/util'
|
|
7
|
+
import { NopTransport } from './util'
|
|
8
|
+
|
|
9
|
+
const test = untypedTest as TestFn<{
|
|
10
|
+
serverAddress: string
|
|
11
|
+
adapterEndpoint: AdapterEndpoint
|
|
12
|
+
}>
|
|
13
|
+
|
|
14
|
+
test.beforeEach(async (t) => {
|
|
15
|
+
const adapter: Adapter = {
|
|
16
|
+
name: 'test',
|
|
17
|
+
endpoints: [
|
|
18
|
+
{
|
|
19
|
+
name: 'test',
|
|
20
|
+
inputParameters: {},
|
|
21
|
+
transport: new (class extends NopTransport {
|
|
22
|
+
override async setup(): Promise<void | AdapterResponse<null>> {
|
|
23
|
+
return {
|
|
24
|
+
data: null,
|
|
25
|
+
statusCode: 200,
|
|
26
|
+
result: null,
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
})(),
|
|
30
|
+
},
|
|
31
|
+
],
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
t.context.adapterEndpoint = adapter.endpoints[0]
|
|
35
|
+
const server = await expose(adapter)
|
|
36
|
+
if (!server) {
|
|
37
|
+
throw 'Server did not start'
|
|
38
|
+
}
|
|
39
|
+
t.context.serverAddress = `http://localhost:${(server.address() as AddressInfo).port}`
|
|
40
|
+
})
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* NOTE: The tests here are run serially, because to avoid setting up and tearing down the adapter
|
|
44
|
+
* for each one, we're just modifying the inputParameters and sending a new request every time
|
|
45
|
+
*/
|
|
46
|
+
test.serial('any content-type other than application/json throws 400', async (t) => {
|
|
47
|
+
t.context.adapterEndpoint.inputParameters = {}
|
|
48
|
+
|
|
49
|
+
const error: AxiosError | undefined = await t.throwsAsync(() =>
|
|
50
|
+
axios.post(`${t.context.serverAddress}`, 'test string', {
|
|
51
|
+
headers: {
|
|
52
|
+
'Content-Type': 'text/plain',
|
|
53
|
+
},
|
|
54
|
+
}),
|
|
55
|
+
)
|
|
56
|
+
t.is(error?.response?.status, 400)
|
|
57
|
+
})
|
|
58
|
+
|
|
59
|
+
test.serial('no body in request throws 400', async (t) => {
|
|
60
|
+
t.context.adapterEndpoint.inputParameters = {}
|
|
61
|
+
|
|
62
|
+
const error: AxiosError | undefined = await t.throwsAsync(() =>
|
|
63
|
+
axios.post(`${t.context.serverAddress}`, '', {
|
|
64
|
+
headers: {
|
|
65
|
+
'Content-Type': 'application/json',
|
|
66
|
+
},
|
|
67
|
+
}),
|
|
68
|
+
)
|
|
69
|
+
t.is(error?.response?.status, 400)
|
|
70
|
+
})
|
|
71
|
+
|
|
72
|
+
test.serial('invalid endpoint name throws 404', async (t) => {
|
|
73
|
+
t.context.adapterEndpoint.inputParameters = {}
|
|
74
|
+
|
|
75
|
+
const error: AxiosError | undefined = await t.throwsAsync(() =>
|
|
76
|
+
axios.post(`${t.context.serverAddress}`, {
|
|
77
|
+
endpoint: 'random',
|
|
78
|
+
}),
|
|
79
|
+
)
|
|
80
|
+
t.is(error?.response?.status, 404)
|
|
81
|
+
})
|
|
82
|
+
|
|
83
|
+
test.serial('no endpoint without default throws 400', async (t) => {
|
|
84
|
+
t.context.adapterEndpoint.inputParameters = {}
|
|
85
|
+
|
|
86
|
+
const error: AxiosError | undefined = await t.throwsAsync(() =>
|
|
87
|
+
axios.post(`${t.context.serverAddress}`, {
|
|
88
|
+
data: {},
|
|
89
|
+
}),
|
|
90
|
+
)
|
|
91
|
+
t.is(error?.response?.status, 400)
|
|
92
|
+
})
|
|
93
|
+
|
|
94
|
+
test.serial('endpoint in data object', async (t) => {
|
|
95
|
+
t.context.adapterEndpoint.inputParameters = {}
|
|
96
|
+
|
|
97
|
+
const response = await axios.post(`${t.context.serverAddress}`, {
|
|
98
|
+
data: { endpoint: 'test' },
|
|
99
|
+
})
|
|
100
|
+
t.is(response.status, 200)
|
|
101
|
+
})
|
|
102
|
+
|
|
103
|
+
test.serial('no params returns 200', async (t) => {
|
|
104
|
+
t.context.adapterEndpoint.inputParameters = {}
|
|
105
|
+
|
|
106
|
+
const response = await axios.post(`${t.context.serverAddress}`, {
|
|
107
|
+
data: {},
|
|
108
|
+
endpoint: 'test',
|
|
109
|
+
})
|
|
110
|
+
t.is(response.status, 200)
|
|
111
|
+
})
|
|
112
|
+
|
|
113
|
+
test.serial('missing required param throws 400', async (t) => {
|
|
114
|
+
t.context.adapterEndpoint.inputParameters = {
|
|
115
|
+
base: {
|
|
116
|
+
type: 'string',
|
|
117
|
+
required: true,
|
|
118
|
+
},
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
const error: AxiosError | undefined = await t.throwsAsync(() =>
|
|
122
|
+
axios.post(`${t.context.serverAddress}`, {
|
|
123
|
+
data: {},
|
|
124
|
+
}),
|
|
125
|
+
)
|
|
126
|
+
t.is(error?.response?.status, 400)
|
|
127
|
+
})
|
|
128
|
+
|
|
129
|
+
test.serial('wrongly typed param throws 400', async (t) => {
|
|
130
|
+
t.context.adapterEndpoint.inputParameters = {
|
|
131
|
+
base: {
|
|
132
|
+
type: 'string',
|
|
133
|
+
required: true,
|
|
134
|
+
},
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
const error: AxiosError | undefined = await t.throwsAsync(() =>
|
|
138
|
+
axios.post(`${t.context.serverAddress}`, {
|
|
139
|
+
data: {
|
|
140
|
+
base: 123,
|
|
141
|
+
},
|
|
142
|
+
endpoint: 'test',
|
|
143
|
+
}),
|
|
144
|
+
)
|
|
145
|
+
t.is(error?.response?.status, 400)
|
|
146
|
+
})
|
|
147
|
+
|
|
148
|
+
test.serial('correctly typed param returns 200', async (t) => {
|
|
149
|
+
t.context.adapterEndpoint.inputParameters = {
|
|
150
|
+
base: {
|
|
151
|
+
type: 'string',
|
|
152
|
+
required: true,
|
|
153
|
+
},
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
const response = await axios.post(`${t.context.serverAddress}`, {
|
|
157
|
+
data: {
|
|
158
|
+
base: 'asd',
|
|
159
|
+
},
|
|
160
|
+
endpoint: 'test',
|
|
161
|
+
})
|
|
162
|
+
t.is(response.status, 200)
|
|
163
|
+
})
|
|
164
|
+
|
|
165
|
+
test.serial('omitted optional param returns 200', async (t) => {
|
|
166
|
+
t.context.adapterEndpoint.inputParameters = {
|
|
167
|
+
base: {
|
|
168
|
+
type: 'string',
|
|
169
|
+
required: false,
|
|
170
|
+
},
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
const response = await axios.post(`${t.context.serverAddress}`, {
|
|
174
|
+
data: {},
|
|
175
|
+
endpoint: 'test',
|
|
176
|
+
})
|
|
177
|
+
t.is(response.status, 200)
|
|
178
|
+
})
|
package/test-payload.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
const fromVariables = ['ETH', 'BTC']
|
|
2
|
+
|
|
3
|
+
const toVariables = ['USD', 'JPY']
|
|
4
|
+
|
|
5
|
+
function generateTestPayload() {
|
|
6
|
+
const payload = {
|
|
7
|
+
requests: [],
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
for (const from of fromVariables) {
|
|
11
|
+
for (const to of toVariables) {
|
|
12
|
+
payload.requests.push({
|
|
13
|
+
from,
|
|
14
|
+
to,
|
|
15
|
+
})
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return JSON.stringify(payload)
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
module.exports = generateTestPayload()
|
package/test.sh
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# for i in {1..100}; do
|
|
2
|
+
# if (( $i % 50 == 0 )); then
|
|
3
|
+
# echo "sent $i"
|
|
4
|
+
# fi
|
|
5
|
+
# curl -XPOST http://localhost:8080 -s \
|
|
6
|
+
# -H 'Content-Type: application/json' \
|
|
7
|
+
# -d '{"endpoint":"test", "data": {"base": "ethereum", "quote": "usd"}}' > /tmp/null &
|
|
8
|
+
# sleep 0.1
|
|
9
|
+
# done
|
|
10
|
+
|
|
11
|
+
# wait
|
|
12
|
+
|
|
13
|
+
# echo "done"
|
|
14
|
+
|
|
15
|
+
curl -XPOST http://localhost:8080 -s \
|
|
16
|
+
-H 'Content-Type: application/json' \
|
|
17
|
+
-d '{"endpoint":"batch", "data": {"base": "ethereum", "quote": "usd"}}' > /tmp/null &
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
wait
|
package/test2.sh
ADDED
package/tsconfig.json
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"outDir": "dist",
|
|
4
|
+
"rootDir": ".",
|
|
5
|
+
"target": "es2020",
|
|
6
|
+
"esModuleInterop": true,
|
|
7
|
+
"moduleResolution": "node",
|
|
8
|
+
"module": "CommonJS",
|
|
9
|
+
"resolveJsonModule": true,
|
|
10
|
+
|
|
11
|
+
// Type checking
|
|
12
|
+
"allowUnreachableCode": false,
|
|
13
|
+
"allowUnusedLabels": false,
|
|
14
|
+
"alwaysStrict": true,
|
|
15
|
+
"noImplicitAny": true,
|
|
16
|
+
"noImplicitOverride": true,
|
|
17
|
+
"noImplicitReturns": false,
|
|
18
|
+
"noImplicitThis": true,
|
|
19
|
+
"noPropertyAccessFromIndexSignature": true,
|
|
20
|
+
"noUnusedLocals": true,
|
|
21
|
+
"strict": true,
|
|
22
|
+
"declaration": true // Emit a d.ts file
|
|
23
|
+
},
|
|
24
|
+
"include": ["./src/**/*"]
|
|
25
|
+
}
|
package/typedoc.json
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
const path = require('path')
|
|
2
|
+
|
|
3
|
+
module.exports = {
|
|
4
|
+
entry: './src/index.ts',
|
|
5
|
+
|
|
6
|
+
devtool: 'inline-source-map',
|
|
7
|
+
module: {
|
|
8
|
+
rules: [
|
|
9
|
+
{
|
|
10
|
+
test: /\.tsx?$/,
|
|
11
|
+
use: 'ts-loader',
|
|
12
|
+
exclude: /node_modules/,
|
|
13
|
+
},
|
|
14
|
+
],
|
|
15
|
+
},
|
|
16
|
+
resolve: {
|
|
17
|
+
extensions: ['.tsx', '.ts', '.js'],
|
|
18
|
+
},
|
|
19
|
+
output: {
|
|
20
|
+
filename: 'bundle.js',
|
|
21
|
+
path: path.resolve(__dirname, 'dist'),
|
|
22
|
+
},
|
|
23
|
+
}
|
|
Binary file
|
package/package/adapter.d.ts
DELETED
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
import { AdapterConfig, BaseAdapterConfig, SettingsMap } from './config';
|
|
2
|
-
import { AdapterRateLimitTier } from './rate-limiting';
|
|
3
|
-
import { AdapterDependencies, Transport } from './transports';
|
|
4
|
-
import { InputParameters } from './validation/input-params';
|
|
5
|
-
/**
|
|
6
|
-
* Structure to describe rate limits specs for the Adapter
|
|
7
|
-
*/
|
|
8
|
-
interface AdapterRateLimitingConfig {
|
|
9
|
-
/** Adapter rate limits, gotten from the specific tier requested */
|
|
10
|
-
tiers: Record<string, AdapterRateLimitTier>;
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* Main structure of an External Adapter
|
|
14
|
-
*/
|
|
15
|
-
export interface Adapter {
|
|
16
|
-
/** Name of the adapter */
|
|
17
|
-
name: string;
|
|
18
|
-
/** If present, the string that will be used for requests with no specified endpoint */
|
|
19
|
-
defaultEndpoint?: string;
|
|
20
|
-
/** List of [[AdapterEndpoint]]s in the adapter */
|
|
21
|
-
endpoints: AdapterEndpoint[];
|
|
22
|
-
/** Map of overrides to the default config values for an Adapter */
|
|
23
|
-
envDefaultOverrides?: Partial<BaseAdapterConfig>;
|
|
24
|
-
/** List of custom env vars for this particular adapter (e.g. RPC_URL) */
|
|
25
|
-
customSettings?: SettingsMap;
|
|
26
|
-
/** Configuration relevant to outbound (EA --\> DP) communication rate limiting */
|
|
27
|
-
rateLimiting?: AdapterRateLimitingConfig;
|
|
28
|
-
/** Overrides for converting the 'base' parameter that are hardcoded into the adapter. */
|
|
29
|
-
overrides?: Record<string, string>;
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* Structure to describe rate limits specs for a specific adapter endpoint
|
|
33
|
-
*/
|
|
34
|
-
export interface EndpointRateLimitingConfig {
|
|
35
|
-
/**
|
|
36
|
-
* How much of the total limit for the adapter will be assigned to this specific endpoint.
|
|
37
|
-
* Should be a non-zero positive number up to 100.
|
|
38
|
-
* Endpoints in the same adapter without a specific allocation will divide the remaining limits equally.
|
|
39
|
-
*/
|
|
40
|
-
allocationPercentage: number;
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* Structure to describe a specific endpoint in an [[Adapter]]
|
|
44
|
-
*/
|
|
45
|
-
export interface AdapterEndpoint {
|
|
46
|
-
/** Name that will be used to match input params to this endpoint (case insensitive) */
|
|
47
|
-
name: string;
|
|
48
|
-
/** List of alternative endpoint names that will resolve to this same transport (case insensitive) */
|
|
49
|
-
aliases?: string[];
|
|
50
|
-
/** Transport that will be used to handle data processing and communication for this endpoint */
|
|
51
|
-
transport: Transport<any, any, any>;
|
|
52
|
-
/** Specification of what the body of a request hitting this endpoint should look like (used for validation) */
|
|
53
|
-
inputParameters: InputParameters;
|
|
54
|
-
/** Specific details related to the rate limiting for this endpoint in particular */
|
|
55
|
-
rateLimiting?: EndpointRateLimitingConfig;
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* Structure to describe an adapter that has been initialized
|
|
59
|
-
*/
|
|
60
|
-
export interface InitializedAdapter extends Adapter {
|
|
61
|
-
/** Object containing alias translations for all endpoints */
|
|
62
|
-
endpointsMap: Record<string, AdapterEndpoint>;
|
|
63
|
-
/** Initialized dependencies that the adapter will use */
|
|
64
|
-
dependencies: AdapterDependencies;
|
|
65
|
-
/** Configuration params for various adapter properties */
|
|
66
|
-
config: AdapterConfig;
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* This function will process dependencies for an adapter, such as caches or rate limiters,
|
|
70
|
-
* in order to inject them into transports and other relevant places later in the lifecycle.
|
|
71
|
-
*
|
|
72
|
-
* @param config - the configuration for this adapter
|
|
73
|
-
* @param inputDependencies - a partial obj of initialized dependencies to override the created ones
|
|
74
|
-
* @param rateLimitingConfig - details from the adapter regarding rate limiting
|
|
75
|
-
* @returns a set of AdapterDependencies all initialized
|
|
76
|
-
*/
|
|
77
|
-
export declare const initializeDependencies: (adapter: Adapter, config: AdapterConfig, inputDependencies?: Partial<AdapterDependencies> | undefined) => AdapterDependencies;
|
|
78
|
-
/**
|
|
79
|
-
* Initializes all of the [[Transport]]s in the adapter, passing along any [[AdapterDependencies]] and [[AdapterConfig]].
|
|
80
|
-
* Additionally, it builds a map out of all the endpoint names and aliases (checking for duplicates).
|
|
81
|
-
*
|
|
82
|
-
* @param adapter - an instance of an Adapter
|
|
83
|
-
* @param dependencies - dependencies that the adapter will need at initialization
|
|
84
|
-
* @param config - configuration variables already processed and validated
|
|
85
|
-
* @returns - the adapter with all transports initialized and aliases map built
|
|
86
|
-
*/
|
|
87
|
-
export declare const initializeAdapter: (adapter: Adapter, config: AdapterConfig, dependencies?: Partial<AdapterDependencies> | undefined) => Promise<InitializedAdapter>;
|
|
88
|
-
export {};
|