@chainlink/external-adapter-framework 0.9.0 → 0.10.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/README.md +67 -0
- package/adapter/basic.d.ts +51 -7
- package/adapter/basic.js +184 -4
- package/adapter/basic.js.map +1 -1
- package/adapter/endpoint.d.ts +6 -6
- package/adapter/endpoint.js +1 -0
- package/adapter/endpoint.js.map +1 -1
- package/adapter/price.d.ts +38 -8
- package/adapter/price.js +43 -1
- package/adapter/price.js.map +1 -1
- package/adapter/types.d.ts +40 -15
- package/background-executor.js +21 -5
- package/background-executor.js.map +1 -1
- package/cache/index.d.ts +11 -17
- package/cache/index.js +9 -51
- package/cache/index.js.map +1 -1
- package/config/index.d.ts +28 -11
- package/config/index.js +63 -46
- package/config/index.js.map +1 -1
- package/examples/bank-frick/accounts.d.ts +17 -25
- package/examples/bank-frick/accounts.js +23 -13
- package/examples/bank-frick/accounts.js.map +1 -1
- package/examples/bank-frick/config/index.d.ts +5 -0
- package/examples/bank-frick/config/index.js +5 -0
- package/examples/bank-frick/config/index.js.map +1 -1
- package/examples/bank-frick/index.d.ts +1 -15
- package/examples/bank-frick/index.js +1 -1
- package/examples/coingecko/src/config/index.d.ts +7 -0
- package/examples/coingecko/src/config/index.js +8 -1
- package/examples/coingecko/src/config/index.js.map +1 -1
- package/examples/coingecko/src/crypto-utils.d.ts +19 -4
- package/examples/coingecko/src/crypto-utils.js +1 -2
- package/examples/coingecko/src/crypto-utils.js.map +1 -1
- package/examples/coingecko/src/endpoint/coins.d.ts +20 -3
- package/examples/coingecko/src/endpoint/coins.js +2 -2
- package/examples/coingecko/src/endpoint/coins.js.map +1 -1
- package/examples/coingecko/src/endpoint/crypto-marketcap.d.ts +2 -2
- package/examples/coingecko/src/endpoint/crypto-marketcap.js +2 -2
- package/examples/coingecko/src/endpoint/crypto-marketcap.js.map +1 -1
- package/examples/coingecko/src/endpoint/crypto-volume.d.ts +2 -2
- package/examples/coingecko/src/endpoint/crypto-volume.js +2 -2
- package/examples/coingecko/src/endpoint/crypto-volume.js.map +1 -1
- package/examples/coingecko/src/endpoint/crypto.d.ts +2 -4
- package/examples/coingecko/src/endpoint/crypto.js +2 -2
- package/examples/coingecko/src/endpoint/crypto.js.map +1 -1
- package/examples/coingecko/src/endpoint/dominance.d.ts +2 -2
- package/examples/coingecko/src/endpoint/dominance.js +2 -2
- package/examples/coingecko/src/endpoint/dominance.js.map +1 -1
- package/examples/coingecko/src/endpoint/global-marketcap.d.ts +2 -2
- package/examples/coingecko/src/endpoint/global-marketcap.js +2 -2
- package/examples/coingecko/src/endpoint/global-marketcap.js.map +1 -1
- package/examples/coingecko/src/global-utils.d.ts +18 -3
- package/examples/coingecko/src/global-utils.js.map +1 -1
- package/examples/coingecko/src/index.js +3 -1
- package/examples/coingecko/src/index.js.map +1 -1
- package/examples/cryptocompare/src/config/index.d.ts +7 -0
- package/examples/cryptocompare/src/config/index.js +8 -1
- package/examples/cryptocompare/src/config/index.js.map +1 -1
- package/examples/cryptocompare/src/endpoints/crypto.d.ts +14 -2
- package/examples/cryptocompare/src/endpoints/crypto.js.map +1 -1
- package/examples/cryptocompare/src/index.js +3 -1
- package/examples/cryptocompare/src/index.js.map +1 -1
- package/examples/genesis/config/index.d.ts +5 -0
- package/examples/genesis/config/index.js +5 -0
- package/examples/genesis/config/index.js.map +1 -1
- package/examples/genesis/index.js +1 -1
- package/examples/genesis/sseStream.d.ts +13 -2
- package/examples/genesis/sseStream.js +4 -1
- package/examples/genesis/sseStream.js.map +1 -1
- package/index.d.ts +2 -1
- package/index.js +4 -6
- package/index.js.map +1 -1
- package/metrics/index.d.ts +2 -0
- package/metrics/index.js +5 -4
- package/metrics/index.js.map +1 -1
- package/metrics/util.d.ts +5 -5
- package/metrics/util.js +2 -2
- package/metrics/util.js.map +1 -1
- package/package.json +8 -10
- package/rate-limiting/background/fixed-frequency.d.ts +2 -3
- package/rate-limiting/background/fixed-frequency.js.map +1 -1
- package/rate-limiting/index.d.ts +4 -4
- package/rate-limiting/index.js +1 -1
- package/rate-limiting/index.js.map +1 -1
- package/rate-limiting/request/simple-counting.d.ts +2 -3
- package/rate-limiting/request/simple-counting.js.map +1 -1
- package/transports/batch-warming.d.ts +40 -18
- package/transports/batch-warming.js +45 -18
- package/transports/batch-warming.js.map +1 -1
- package/transports/index.d.ts +65 -31
- package/transports/index.js +2 -59
- package/transports/index.js.map +1 -1
- package/transports/metrics.d.ts +3 -3
- package/transports/metrics.js +2 -2
- package/transports/metrics.js.map +1 -1
- package/transports/rest.d.ts +42 -30
- package/transports/rest.js +25 -30
- package/transports/rest.js.map +1 -1
- package/transports/routing.d.ts +22 -0
- package/transports/routing.js +60 -0
- package/transports/routing.js.map +1 -0
- package/transports/sse.d.ts +40 -20
- package/transports/sse.js +10 -8
- package/transports/sse.js.map +1 -1
- package/transports/util.d.ts +3 -1
- package/transports/util.js +69 -39
- package/transports/util.js.map +1 -1
- package/transports/websocket.d.ts +41 -26
- package/transports/websocket.js +16 -19
- package/transports/websocket.js.map +1 -1
- package/util/logger.d.ts +2 -0
- package/util/logger.js +4 -7
- package/util/logger.js.map +1 -1
- package/util/request.d.ts +46 -10
- package/util/subscription-set/subscription-set.d.ts +1 -1
- package/util/subscription-set/subscription-set.js +1 -1
- package/util/subscription-set/subscription-set.js.map +1 -1
- package/util/test-payload-loader.d.ts +1 -0
- package/util/test-payload-loader.js +2 -1
- package/util/test-payload-loader.js.map +1 -1
- package/validation/error.d.ts +1 -3
- package/validation/error.js +2 -4
- package/validation/error.js.map +1 -1
- package/validation/index.js +28 -18
- package/validation/index.js.map +1 -1
- package/validation/input-params.d.ts +0 -1
- package/validation/input-params.js +0 -28
- package/validation/input-params.js.map +1 -1
- package/validation/input-validator.js +1 -2
- package/validation/input-validator.js.map +1 -1
- package/examples/coingecko-old/batch-warming.d.ts +0 -7
- package/examples/coingecko-old/batch-warming.js +0 -54
- package/examples/coingecko-old/batch-warming.js.map +0 -1
- package/examples/coingecko-old/index.d.ts +0 -2
- package/examples/coingecko-old/index.js +0 -12
- package/examples/coingecko-old/index.js.map +0 -1
- package/examples/coingecko-old/rest.d.ts +0 -12
- package/examples/coingecko-old/rest.js +0 -55
- package/examples/coingecko-old/rest.js.map +0 -1
- package/examples/ncfx/config/index.d.ts +0 -12
- package/examples/ncfx/config/index.js +0 -16
- package/examples/ncfx/config/index.js.map +0 -1
- package/examples/ncfx/index.d.ts +0 -13
- package/examples/ncfx/index.js +0 -12
- package/examples/ncfx/index.js.map +0 -1
- package/examples/ncfx/websocket.d.ts +0 -47
- package/examples/ncfx/websocket.js +0 -74
- package/examples/ncfx/websocket.js.map +0 -1
- package/validation/override-functions.d.ts +0 -3
- package/validation/override-functions.js +0 -41
- package/validation/override-functions.js.map +0 -1
package/README.md
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
# EA Framework v3
|
|
2
|
+
|
|
3
|
+
> **Warning**
|
|
4
|
+
> This framework is in a Beta state, and under active development. While many of the features from version 2 are present, they have not been tested extensively enough to mark this as production ready. You can find v2 in the [External Adapters Monorepo](https://github.com/smartcontractkit/external-adapters-js)
|
|
5
|
+
|
|
6
|
+
Framework to create External adapters, microservices that serve as middleware to facilitate connections between Chainlink Nodes and Data Providers (DP).
|
|
7
|
+
|
|
8
|
+
## Requirements
|
|
9
|
+
|
|
10
|
+
- Node.js 16+
|
|
11
|
+
- Yarn
|
|
12
|
+
|
|
13
|
+
### Optional development tools
|
|
14
|
+
|
|
15
|
+
If available, consider setting up your development environment with:
|
|
16
|
+
|
|
17
|
+
- ESLint
|
|
18
|
+
- Prettier
|
|
19
|
+
|
|
20
|
+
Note that both of the above are not necessary, but PRs submitted to the repo will be blocked from merging unless they comply with the linting and formatting rules.
|
|
21
|
+
|
|
22
|
+
## Setup
|
|
23
|
+
|
|
24
|
+
```sh
|
|
25
|
+
yarn # Install yarn dependencies
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Guides & Docs
|
|
29
|
+
|
|
30
|
+
- [Basics](./docs/basics.md)
|
|
31
|
+
- Porting a v2 EA to v3
|
|
32
|
+
- Creating a new v3 EA
|
|
33
|
+
- Transports
|
|
34
|
+
- Basic
|
|
35
|
+
- REST
|
|
36
|
+
- WebSocket
|
|
37
|
+
- SSE
|
|
38
|
+
- Meta
|
|
39
|
+
- Routing
|
|
40
|
+
|
|
41
|
+
## Testing
|
|
42
|
+
|
|
43
|
+
The EA framework is tested by a suite of integration tests located [here](./test).
|
|
44
|
+
|
|
45
|
+
```
|
|
46
|
+
yarn test
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Publishing releases
|
|
50
|
+
|
|
51
|
+
### Automatic
|
|
52
|
+
|
|
53
|
+
The normal flow for publishing a release is through a series o GitHub actions that are triggered when a PR is closed by merging with the base branch. Full details about our workflows can be found in [./.github/WORKFLOW-README.MD]. A summary of our publish workflow follows:
|
|
54
|
+
|
|
55
|
+
1. Close a PR containing your changes
|
|
56
|
+
2. If the PR was merged and if it contains a version label instruction (patch, minor, major, none), a new PR will be created that contains the result of running `npm version LABEL` on master with the original PR author assigned as a reviewer.
|
|
57
|
+
3. A link to the newly created version bump PR will be added to your original PR. Click on that link, and approve it to be merged.
|
|
58
|
+
4. Close the version bump PR. If merged, the package will be published to npm.
|
|
59
|
+
5. When the publish workflow finishes, a comment will be added to the version bump PR that tells you if it ran successfully
|
|
60
|
+
|
|
61
|
+
This adds an extra step (approving a version bump PR) that has to be taken every time a PR is merged. This is annoying, but it is an effective workaround for permissions issues when running against protected branches, and eliminates the need for the PR author to manually update their branch's version by referring to master.
|
|
62
|
+
|
|
63
|
+
### Manual
|
|
64
|
+
|
|
65
|
+
If you need to publish a release manually, you can do so by running `yarn release` at the project root
|
|
66
|
+
|
|
67
|
+
This runs a script that publishes the package from dist/src. If you publish from the root directory, imports will be in the form of: `import {something} from "@chainlink/external-adapter-framework/src/some_directory"`. By publishing the package from dist/src, the "src" part of the import path gets dropped, which looks cleaner: `import {something} from "@chainlink/external-adapter-framework/some_directory"`.
|
package/adapter/basic.d.ts
CHANGED
|
@@ -1,24 +1,33 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AdapterConfig, BaseAdapterConfig, SettingsMap } from '../config';
|
|
2
|
+
import { AdapterRequest, AdapterResponse, Merge } from '../util';
|
|
2
3
|
import { AdapterEndpoint } from './endpoint';
|
|
3
|
-
import { AdapterDependencies, AdapterParams, AdapterRateLimitingConfig, CustomAdapterSettings } from './types';
|
|
4
|
+
import { AdapterDependencies, AdapterParams, AdapterRateLimitingConfig, CustomAdapterSettings, EndpointGenerics, RequestTransform } from './types';
|
|
4
5
|
/**
|
|
5
6
|
* Main class to represent an External Adapter
|
|
6
7
|
*/
|
|
7
|
-
export declare class Adapter<CustomSettings extends CustomAdapterSettings = SettingsMap> implements AdapterParams<CustomSettings> {
|
|
8
|
-
name: string
|
|
8
|
+
export declare class Adapter<CustomSettings extends CustomAdapterSettings = SettingsMap> implements Omit<AdapterParams<CustomSettings>, 'bootstrap'> {
|
|
9
|
+
name: Uppercase<string>;
|
|
9
10
|
defaultEndpoint?: string | undefined;
|
|
10
|
-
endpoints: AdapterEndpoint<
|
|
11
|
+
endpoints: AdapterEndpoint<Merge<EndpointGenerics, {
|
|
12
|
+
CustomSettings: CustomSettings;
|
|
13
|
+
}>>[];
|
|
11
14
|
envDefaultOverrides?: Partial<BaseAdapterConfig> | undefined;
|
|
12
15
|
customSettings?: SettingsMap | undefined;
|
|
13
16
|
rateLimiting?: AdapterRateLimitingConfig | undefined;
|
|
14
17
|
overrides?: Record<string, string> | undefined;
|
|
18
|
+
requestTransforms?: RequestTransform[];
|
|
19
|
+
envVarsPrefix?: string;
|
|
15
20
|
initialized: boolean;
|
|
16
21
|
/** Object containing alias translations for all endpoints */
|
|
17
|
-
endpointsMap: Record<string, AdapterEndpoint<
|
|
22
|
+
endpointsMap: Record<string, AdapterEndpoint<Merge<EndpointGenerics, {
|
|
23
|
+
CustomSettings: CustomSettings;
|
|
24
|
+
}>>>;
|
|
18
25
|
/** Initialized dependencies that the adapter will use */
|
|
19
26
|
dependencies: AdapterDependencies;
|
|
20
27
|
/** Configuration params for various adapter properties */
|
|
21
|
-
config: AdapterConfig
|
|
28
|
+
config: AdapterConfig<CustomSettings>;
|
|
29
|
+
/** Bootstrap function that will run when initializing the adapter */
|
|
30
|
+
private readonly bootstrap?;
|
|
22
31
|
constructor(params: AdapterParams<CustomSettings>);
|
|
23
32
|
/**
|
|
24
33
|
* Initializes all of the [[Transport]]s in the adapter, passing along any [[AdapterDependencies]] and [[AdapterConfig]].
|
|
@@ -41,6 +50,11 @@ export declare class Adapter<CustomSettings extends CustomAdapterSettings = Sett
|
|
|
41
50
|
* using the sensitive flag in the adapter config
|
|
42
51
|
*/
|
|
43
52
|
private buildCensorList;
|
|
53
|
+
/**
|
|
54
|
+
* Logs a warning for certain configs if set to particular values.
|
|
55
|
+
* Used to warn stakeholders of potential risks.
|
|
56
|
+
*/
|
|
57
|
+
private logConfigWarnings;
|
|
44
58
|
/**
|
|
45
59
|
* This function will process dependencies for an adapter, such as caches or rate limiters,
|
|
46
60
|
* in order to inject them into transports and other relevant places later in the lifecycle.
|
|
@@ -49,4 +63,34 @@ export declare class Adapter<CustomSettings extends CustomAdapterSettings = Sett
|
|
|
49
63
|
* @returns a set of AdapterDependencies all initialized
|
|
50
64
|
*/
|
|
51
65
|
initializeDependencies(inputDependencies?: Partial<AdapterDependencies>): AdapterDependencies;
|
|
66
|
+
/**
|
|
67
|
+
* Attempts to find a value from the Cache and return that if found.
|
|
68
|
+
*
|
|
69
|
+
* @param req - the incoming request to this adapter
|
|
70
|
+
* @returns the cached value if exists
|
|
71
|
+
*/
|
|
72
|
+
findResponseInCache(req: AdapterRequest): Promise<AdapterResponse | undefined>;
|
|
73
|
+
/**
|
|
74
|
+
* Default request transform that takes requests and manipulates
|
|
75
|
+
*
|
|
76
|
+
* @param adapter - the current adapter
|
|
77
|
+
* @param req - the current adapter request
|
|
78
|
+
* @returns the modified (or new) request
|
|
79
|
+
*/
|
|
80
|
+
symbolOverrider(req: AdapterRequest): AdapterRequest<import("../util").RequestGenerics>;
|
|
81
|
+
/**
|
|
82
|
+
* Takes the incoming request and applies all request transforms in the adapter
|
|
83
|
+
*
|
|
84
|
+
* @param req - the current adapter request
|
|
85
|
+
* @returns the request after passing through all request transforms
|
|
86
|
+
*/
|
|
87
|
+
runRequestTransforms(req: AdapterRequest): void;
|
|
88
|
+
/**
|
|
89
|
+
* Function to serve as middleware to pass along the AdapterRequest to the appropriate Transport (acc. to the endpoint in the req.)
|
|
90
|
+
*
|
|
91
|
+
* @param req - the incoming request to this adapter
|
|
92
|
+
* @param replySent - a promise that resolves when the reply has already been sent
|
|
93
|
+
* @returns a simple Promise when it's done
|
|
94
|
+
*/
|
|
95
|
+
handleRequest(req: AdapterRequest, replySent: Promise<unknown>): Promise<AdapterResponse>;
|
|
52
96
|
}
|
package/adapter/basic.js
CHANGED
|
@@ -31,9 +31,11 @@ const ioredis_1 = __importDefault(require("ioredis"));
|
|
|
31
31
|
const cache_1 = require("../cache");
|
|
32
32
|
const cacheMetrics = __importStar(require("../cache/metrics"));
|
|
33
33
|
const config_1 = require("../config");
|
|
34
|
+
const transportMetrics = __importStar(require("../transports/metrics"));
|
|
34
35
|
const rate_limiting_1 = require("../rate-limiting");
|
|
35
36
|
const util_1 = require("../util");
|
|
36
37
|
const censor_list_1 = __importDefault(require("../util/censor/censor-list"));
|
|
38
|
+
const error_1 = require("../validation/error");
|
|
37
39
|
const logger = (0, util_1.makeLogger)('Adapter');
|
|
38
40
|
/**
|
|
39
41
|
* Main class to represent an External Adapter
|
|
@@ -52,9 +54,12 @@ class Adapter {
|
|
|
52
54
|
this.customSettings = params.customSettings;
|
|
53
55
|
this.rateLimiting = params.rateLimiting;
|
|
54
56
|
this.overrides = params.overrides;
|
|
57
|
+
this.requestTransforms = [this.symbolOverrider.bind(this), ...(params.requestTransforms || [])];
|
|
58
|
+
this.bootstrap = params.bootstrap;
|
|
55
59
|
this.config = (0, config_1.buildAdapterConfig)({
|
|
56
60
|
overrides: this.envDefaultOverrides,
|
|
57
61
|
customSettings: this.customSettings,
|
|
62
|
+
envVarsPrefix: this.envVarsPrefix,
|
|
58
63
|
});
|
|
59
64
|
this.normalizeEndpointNames();
|
|
60
65
|
this.calculateRateLimitAllocations();
|
|
@@ -67,6 +72,13 @@ class Adapter {
|
|
|
67
72
|
if (this.initialized) {
|
|
68
73
|
throw new Error('This adapter has already been initialized!');
|
|
69
74
|
}
|
|
75
|
+
// Building configs during initialization to avoid validation errors during construction
|
|
76
|
+
(0, config_1.validateAdapterConfig)(this.config, this.customSettings);
|
|
77
|
+
// Log warnings for risks associated with certain configs and values
|
|
78
|
+
this.logConfigWarnings();
|
|
79
|
+
if (this.bootstrap) {
|
|
80
|
+
await this.bootstrap(this);
|
|
81
|
+
}
|
|
70
82
|
this.dependencies = this.initializeDependencies(dependencies);
|
|
71
83
|
for (const endpoint of this.endpoints) {
|
|
72
84
|
// Add aliases to map to use in validation
|
|
@@ -132,7 +144,10 @@ class Adapter {
|
|
|
132
144
|
buildCensorList() {
|
|
133
145
|
const censorList = Object.entries(config_1.BaseSettings)
|
|
134
146
|
.concat(Object.entries(this.customSettings || {}))
|
|
135
|
-
.filter(([name, setting]) => setting &&
|
|
147
|
+
.filter(([name, setting]) => setting &&
|
|
148
|
+
setting.type === 'string' &&
|
|
149
|
+
setting.sensitive &&
|
|
150
|
+
this.config[name])
|
|
136
151
|
.map(([name]) => ({
|
|
137
152
|
key: name,
|
|
138
153
|
// Escaping potential special characters in values before creating regex
|
|
@@ -142,6 +157,19 @@ class Adapter {
|
|
|
142
157
|
}));
|
|
143
158
|
censor_list_1.default.set(censorList);
|
|
144
159
|
}
|
|
160
|
+
/**
|
|
161
|
+
* Logs a warning for certain configs if set to particular values.
|
|
162
|
+
* Used to warn stakeholders of potential risks.
|
|
163
|
+
*/
|
|
164
|
+
logConfigWarnings() {
|
|
165
|
+
if (this.config.LOG_LEVEL.toUpperCase() === 'DEBUG' ||
|
|
166
|
+
this.config.LOG_LEVEL.toUpperCase() === 'TRACE') {
|
|
167
|
+
logger.warn(`LOG_LEVEL has been set to ${this.config.LOG_LEVEL.toUpperCase()}. Setting higher log levels results in increased memory usage and potentially slower performance.`);
|
|
168
|
+
}
|
|
169
|
+
if (this.config.DEBUG === true) {
|
|
170
|
+
logger.warn(`The adapter is running with DEBUG mode on.`);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
145
173
|
/**
|
|
146
174
|
* This function will process dependencies for an adapter, such as caches or rate limiters,
|
|
147
175
|
* in order to inject them into transports and other relevant places later in the lifecycle.
|
|
@@ -153,14 +181,28 @@ class Adapter {
|
|
|
153
181
|
const dependencies = inputDependencies || {};
|
|
154
182
|
if (!dependencies.redisClient) {
|
|
155
183
|
if (this.config.CACHE_TYPE === 'redis') {
|
|
156
|
-
|
|
184
|
+
const maxCooldown = this.config.CACHE_REDIS_MAX_RECONNECT_COOLDOWN;
|
|
185
|
+
const redisOptions = {
|
|
157
186
|
enableAutoPipelining: true,
|
|
158
187
|
host: this.config.CACHE_REDIS_HOST,
|
|
159
188
|
port: this.config.CACHE_REDIS_PORT,
|
|
160
189
|
password: this.config.CACHE_REDIS_PASSWORD,
|
|
161
190
|
path: this.config.CACHE_REDIS_PATH,
|
|
162
191
|
timeout: this.config.CACHE_REDIS_TIMEOUT,
|
|
163
|
-
|
|
192
|
+
retryStrategy(times) {
|
|
193
|
+
cacheMetrics.redisRetriesCount.inc();
|
|
194
|
+
logger.warn(`Redis reconnect attempt #${times}`);
|
|
195
|
+
return Math.min(times * 100, maxCooldown); // Next reconnect attempt time
|
|
196
|
+
},
|
|
197
|
+
connectTimeout: this.config.CACHE_REDIS_CONNECTION_TIMEOUT,
|
|
198
|
+
maxRetriesPerRequest: 30, // Limits the number of retries before the adapter shuts down
|
|
199
|
+
};
|
|
200
|
+
if (this.config.CACHE_REDIS_URL) {
|
|
201
|
+
dependencies.redisClient = new ioredis_1.default(this.config.CACHE_REDIS_URL, redisOptions);
|
|
202
|
+
}
|
|
203
|
+
else {
|
|
204
|
+
dependencies.redisClient = new ioredis_1.default(redisOptions);
|
|
205
|
+
}
|
|
164
206
|
dependencies.redisClient.on('connect', () => {
|
|
165
207
|
cacheMetrics.redisConnectionsOpen.inc();
|
|
166
208
|
});
|
|
@@ -177,10 +219,148 @@ class Adapter {
|
|
|
177
219
|
dependencies.backgroundExecuteRateLimiter = new rate_limiting_1.FixedFrequencyRateLimiter().initialize(this.endpoints, rateLimitingTier);
|
|
178
220
|
}
|
|
179
221
|
if (!dependencies.subscriptionSetFactory) {
|
|
180
|
-
dependencies.subscriptionSetFactory = new util_1.SubscriptionSetFactory(this.config,
|
|
222
|
+
dependencies.subscriptionSetFactory = new util_1.SubscriptionSetFactory(this.config, this.name, dependencies.redisClient);
|
|
181
223
|
}
|
|
182
224
|
return dependencies;
|
|
183
225
|
}
|
|
226
|
+
/**
|
|
227
|
+
* Attempts to find a value from the Cache and return that if found.
|
|
228
|
+
*
|
|
229
|
+
* @param req - the incoming request to this adapter
|
|
230
|
+
* @returns the cached value if exists
|
|
231
|
+
*/
|
|
232
|
+
async findResponseInCache(req) {
|
|
233
|
+
const response = await this.dependencies.cache.get(req.requestContext.cacheKey);
|
|
234
|
+
if (response) {
|
|
235
|
+
if (this.config.METRICS_ENABLED && this.config.EXPERIMENTAL_METRICS_ENABLED) {
|
|
236
|
+
const label = cacheMetrics.cacheMetricsLabel(req.requestContext.cacheKey, req.requestContext.meta?.metrics?.feedId || 'N/A', this.config.CACHE_TYPE);
|
|
237
|
+
// Record cache staleness and cache get count and value
|
|
238
|
+
const staleness = (0, cache_1.calculateStaleness)(response.maxAge, this.config.CACHE_MAX_AGE);
|
|
239
|
+
cacheMetrics.cacheGet(label, response.result, staleness);
|
|
240
|
+
req.requestContext.meta = {
|
|
241
|
+
...req.requestContext.meta,
|
|
242
|
+
metrics: { ...req.requestContext.meta?.metrics, cacheHit: true },
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
return response;
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
/**
|
|
249
|
+
* Default request transform that takes requests and manipulates
|
|
250
|
+
*
|
|
251
|
+
* @param adapter - the current adapter
|
|
252
|
+
* @param req - the current adapter request
|
|
253
|
+
* @returns the modified (or new) request
|
|
254
|
+
*/
|
|
255
|
+
symbolOverrider(req) {
|
|
256
|
+
const rawRequestBody = req.body;
|
|
257
|
+
const requestOverrides = rawRequestBody.data?.overrides?.[this.name.toLowerCase()];
|
|
258
|
+
const base = req.requestContext.data['base'];
|
|
259
|
+
if (requestOverrides?.[base]) {
|
|
260
|
+
// Perform overrides specified in the request payload
|
|
261
|
+
req.requestContext.data['base'] = requestOverrides[base];
|
|
262
|
+
}
|
|
263
|
+
else if (this.overrides?.[base]) {
|
|
264
|
+
// Perform hardcoded adapter overrides
|
|
265
|
+
req.requestContext.data['base'] = this.overrides[base];
|
|
266
|
+
}
|
|
267
|
+
return req;
|
|
268
|
+
}
|
|
269
|
+
/**
|
|
270
|
+
* Takes the incoming request and applies all request transforms in the adapter
|
|
271
|
+
*
|
|
272
|
+
* @param req - the current adapter request
|
|
273
|
+
* @returns the request after passing through all request transforms
|
|
274
|
+
*/
|
|
275
|
+
runRequestTransforms(req) {
|
|
276
|
+
if (!this.requestTransforms) {
|
|
277
|
+
return;
|
|
278
|
+
}
|
|
279
|
+
for (const transform of this.requestTransforms) {
|
|
280
|
+
transform(req);
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
/**
|
|
284
|
+
* Function to serve as middleware to pass along the AdapterRequest to the appropriate Transport (acc. to the endpoint in the req.)
|
|
285
|
+
*
|
|
286
|
+
* @param req - the incoming request to this adapter
|
|
287
|
+
* @param replySent - a promise that resolves when the reply has already been sent
|
|
288
|
+
* @returns a simple Promise when it's done
|
|
289
|
+
*/
|
|
290
|
+
async handleRequest(req, replySent) {
|
|
291
|
+
// Get transport, must be here because it's already checked in the validator
|
|
292
|
+
const transport = this.endpointsMap[req.requestContext.endpointName].transport;
|
|
293
|
+
// First try to find the response in our cache, keep it ready
|
|
294
|
+
const cachedResponse = await this.findResponseInCache(req);
|
|
295
|
+
// Next we fire off the transport's registration of the request if defined, regardless of if we already have a cached response.
|
|
296
|
+
// This is necessary to ensure things like subscription sets are updated each time we get a request
|
|
297
|
+
let requestRegistrationPromise;
|
|
298
|
+
let requestRegistrationError;
|
|
299
|
+
if (transport.registerRequest) {
|
|
300
|
+
const handler = async () => {
|
|
301
|
+
// If we already have a cached response, wait for it to be sent back before continuing with registration
|
|
302
|
+
// This way we respond to incoming requests from the cache as fast as possible
|
|
303
|
+
if (cachedResponse) {
|
|
304
|
+
await replySent;
|
|
305
|
+
}
|
|
306
|
+
try {
|
|
307
|
+
// `await` is required to catch the error, you'll get an unhandled promise rejection otherwise
|
|
308
|
+
// Disable non-null assertion operator because we already checked for the existence of registerRequest
|
|
309
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
310
|
+
return await transport.registerRequest(req, this.config);
|
|
311
|
+
}
|
|
312
|
+
catch (err) {
|
|
313
|
+
logger.error(`Error registering request: ${err}`);
|
|
314
|
+
requestRegistrationError = err;
|
|
315
|
+
}
|
|
316
|
+
};
|
|
317
|
+
// Execute the registration handler without blocking
|
|
318
|
+
logger.debug(`Firing request registration handler${cachedResponse ? ' (cached response already sent)' : ''}`);
|
|
319
|
+
requestRegistrationPromise = handler();
|
|
320
|
+
}
|
|
321
|
+
// Now that we have dealt with request registration, can return the cached response if present
|
|
322
|
+
if (cachedResponse) {
|
|
323
|
+
logger.debug('Found response from cache, sending that');
|
|
324
|
+
return cachedResponse;
|
|
325
|
+
}
|
|
326
|
+
// If there was no cached response, execute the foregroundExecute if defined
|
|
327
|
+
const immediateResponse = transport.foregroundExecute && (await transport.foregroundExecute(req, this.config));
|
|
328
|
+
if (immediateResponse) {
|
|
329
|
+
logger.debug('Got immediate response from transport, sending as response');
|
|
330
|
+
return immediateResponse;
|
|
331
|
+
}
|
|
332
|
+
// Finally, either because there was no synchronous execute or because it returned an empty response,
|
|
333
|
+
// we wait for the cache to be filled (either from background work started in the sync execute, or the backgroundExecute).
|
|
334
|
+
// We can wait for the request registration to have finished here, since we're going to be sleeping for the cache anyways,
|
|
335
|
+
// and it's useful in case the registration throws a promise so that it doesn't go unhandled.
|
|
336
|
+
await requestRegistrationPromise;
|
|
337
|
+
if (requestRegistrationError) {
|
|
338
|
+
throw requestRegistrationError;
|
|
339
|
+
}
|
|
340
|
+
// Observe the idle time taken for polling response
|
|
341
|
+
const metricsTimer = transportMetrics.transportPollingDurationSeconds
|
|
342
|
+
.labels({ endpoint: req.requestContext.endpointName })
|
|
343
|
+
.startTimer();
|
|
344
|
+
logger.debug('Transport is set up, polling cache for response...');
|
|
345
|
+
const response = await (0, cache_1.pollResponseFromCache)(this.dependencies.cache, req.requestContext.cacheKey, {
|
|
346
|
+
maxRetries: this.config.CACHE_POLLING_MAX_RETRIES,
|
|
347
|
+
sleep: this.config.CACHE_POLLING_SLEEP_MS,
|
|
348
|
+
});
|
|
349
|
+
metricsTimer({ succeeded: String(!!response) });
|
|
350
|
+
if (response) {
|
|
351
|
+
logger.debug('Got a response from polling the cache, sending that back');
|
|
352
|
+
return response;
|
|
353
|
+
}
|
|
354
|
+
// Record polling mechanism failure to return response
|
|
355
|
+
transportMetrics.transportPollingFailureCount
|
|
356
|
+
.labels({ endpoint: req.requestContext.endpointName })
|
|
357
|
+
.inc();
|
|
358
|
+
logger.debug('Ran out of polling attempts, returning timeout');
|
|
359
|
+
throw new error_1.AdapterTimeoutError({
|
|
360
|
+
message: 'Timed out waiting for provider result.',
|
|
361
|
+
statusCode: 504,
|
|
362
|
+
});
|
|
363
|
+
}
|
|
184
364
|
}
|
|
185
365
|
exports.Adapter = Adapter;
|
|
186
366
|
//# sourceMappingURL=basic.js.map
|
package/adapter/basic.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"basic.js","sourceRoot":"","sources":["../../../src/adapter/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,IAAI,CAAC,YAAY,CAAC,KAA+B,EACjD,GAAG,CAAC,cAAc,CAAC,QAAQ,EAC3B;YACE,UAAU,EAAE,IAAI,CAAC,MAAM,CAAC,yBAAyB;YACjD,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,sBAAsB;SAC1C,CACF,CAAA;QAED,YAAY,CAAC,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAA;QAE/C,IAAI,QAAQ,EAAE;YACZ,MAAM,CAAC,KAAK,CAAC,0DAA0D,CAAC,CAAA;YACxE,OAAO,QAAQ,CAAA;SAChB;QAED,sDAAsD;QACtD,gBAAgB,CAAC,4BAA4B;aAC1C,MAAM,CAAC,EAAE,QAAQ,EAAE,GAAG,CAAC,cAAc,CAAC,YAAY,EAAE,CAAC;aACrD,GAAG,EAAE,CAAA;QAER,MAAM,CAAC,KAAK,CAAC,gDAAgD,CAAC,CAAA;QAC9D,MAAM,IAAI,2BAAmB,CAAC;YAC5B,OAAO,EAAE,wCAAwC;YACjD,UAAU,EAAE,GAAG;SAChB,CAAC,CAAA;IACJ,CAAC;CACF;AAzbD,0BAybC"}
|
package/adapter/endpoint.d.ts
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Transport } from '../transports';
|
|
1
|
+
import { MetaTransport, Transport } from '../transports';
|
|
3
2
|
import { InputParameters } from '../validation';
|
|
4
|
-
import { AdapterEndpointParams, EndpointRateLimitingConfig } from './types';
|
|
5
3
|
import { InputValidator } from '../validation/input-validator';
|
|
4
|
+
import { AdapterEndpointParams, EndpointGenerics, EndpointRateLimitingConfig } from './types';
|
|
6
5
|
/**
|
|
7
6
|
* Main class to represent an endpoint within an External Adapter
|
|
8
7
|
*/
|
|
9
|
-
export declare class AdapterEndpoint<
|
|
8
|
+
export declare class AdapterEndpoint<T extends EndpointGenerics> implements AdapterEndpointParams<T> {
|
|
10
9
|
name: string;
|
|
11
10
|
aliases?: string[] | undefined;
|
|
12
|
-
transport: Transport<
|
|
11
|
+
transport: Transport<T> | MetaTransport<T>;
|
|
13
12
|
inputParameters: InputParameters;
|
|
14
13
|
rateLimiting?: EndpointRateLimitingConfig | undefined;
|
|
15
14
|
validator: InputValidator;
|
|
16
|
-
|
|
15
|
+
cacheKeyGenerator?: (data: Record<string, unknown>) => string;
|
|
16
|
+
constructor(params: AdapterEndpointParams<T>);
|
|
17
17
|
}
|
package/adapter/endpoint.js
CHANGED
|
@@ -13,6 +13,7 @@ class AdapterEndpoint {
|
|
|
13
13
|
this.inputParameters = params.inputParameters;
|
|
14
14
|
this.rateLimiting = params.rateLimiting;
|
|
15
15
|
this.validator = new input_validator_1.InputValidator(this.inputParameters);
|
|
16
|
+
this.cacheKeyGenerator = params.cacheKeyGenerator;
|
|
16
17
|
}
|
|
17
18
|
}
|
|
18
19
|
exports.AdapterEndpoint = AdapterEndpoint;
|
package/adapter/endpoint.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"endpoint.js","sourceRoot":"","sources":["../../../src/adapter/endpoint.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"endpoint.js","sourceRoot":"","sources":["../../../src/adapter/endpoint.ts"],"names":[],"mappings":";;;AAEA,mEAA8D;AAG9D;;GAEG;AACH,MAAa,eAAe;IAS1B,YAAY,MAAgC;QAC1C,IAAI,CAAC,IAAI,GAAG,MAAM,CAAC,IAAI,CAAA;QACvB,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,OAAO,CAAA;QAC7B,IAAI,CAAC,SAAS,GAAG,MAAM,CAAC,SAAS,CAAA;QACjC,IAAI,CAAC,eAAe,GAAG,MAAM,CAAC,eAAe,CAAA;QAC7C,IAAI,CAAC,YAAY,GAAG,MAAM,CAAC,YAAY,CAAA;QACvC,IAAI,CAAC,SAAS,GAAG,IAAI,gCAAc,CAAC,IAAI,CAAC,eAAe,CAAC,CAAA;QACzD,IAAI,CAAC,iBAAiB,GAAG,MAAM,CAAC,iBAAiB,CAAA;IACnD,CAAC;CACF;AAlBD,0CAkBC"}
|
package/adapter/price.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { Adapter, AdapterEndpointParams, AdapterParams } from './index';
|
|
2
|
-
import { AdapterEndpoint } from './endpoint';
|
|
3
1
|
import { SettingsMap } from '../config';
|
|
2
|
+
import { AdapterRequest, AdapterRequestContext, AdapterResponse, RequestGenerics } from '../util';
|
|
3
|
+
import { AdapterEndpoint } from './endpoint';
|
|
4
|
+
import { Adapter, AdapterEndpointParams, AdapterParams, EndpointGenerics } from './index';
|
|
4
5
|
/**
|
|
5
6
|
* Type for the base input parameter config that any [[PriceEndpoint]] must extend
|
|
6
7
|
*/
|
|
@@ -9,13 +10,13 @@ export declare type PriceEndpointInputParameters = {
|
|
|
9
10
|
aliases: readonly ['from', 'coin', ...string[]];
|
|
10
11
|
type: 'string';
|
|
11
12
|
description: 'The symbol of symbols of the currency to query';
|
|
12
|
-
required:
|
|
13
|
+
required: boolean;
|
|
13
14
|
};
|
|
14
15
|
quote: {
|
|
15
16
|
aliases: readonly ['to', 'market', ...string[]];
|
|
16
17
|
type: 'string';
|
|
17
18
|
description: 'The symbol of the currency to convert to';
|
|
18
|
-
required:
|
|
19
|
+
required: boolean;
|
|
19
20
|
};
|
|
20
21
|
};
|
|
21
22
|
/**
|
|
@@ -25,23 +26,52 @@ export declare const priceEndpointInputParameters: PriceEndpointInputParameters;
|
|
|
25
26
|
/**
|
|
26
27
|
* Type for base input params for a PriceEndpoint
|
|
27
28
|
*/
|
|
28
|
-
declare type PriceEndpointParams = {
|
|
29
|
+
export declare type PriceEndpointParams = {
|
|
29
30
|
base: string;
|
|
30
31
|
quote: string;
|
|
31
32
|
};
|
|
33
|
+
/**
|
|
34
|
+
* Structure of an "includes" file.
|
|
35
|
+
* Include pairs describe an incoming price feed request, and the details specify
|
|
36
|
+
*/
|
|
37
|
+
export declare type IncludesFile = IncludePair[];
|
|
38
|
+
declare type IncludeDetails = {
|
|
39
|
+
from: string;
|
|
40
|
+
to: string;
|
|
41
|
+
inverse: boolean;
|
|
42
|
+
};
|
|
43
|
+
declare type IncludePair = {
|
|
44
|
+
from: string;
|
|
45
|
+
to: string;
|
|
46
|
+
includes: IncludeDetails[];
|
|
47
|
+
};
|
|
48
|
+
declare type IncludesMap = Record<string, Record<string, IncludeDetails>>;
|
|
32
49
|
/**
|
|
33
50
|
* A PriceEndpoint is a specific type of AdapterEndpoint. Meant to comply with standard practices for
|
|
34
51
|
* Data Feeds, its InputParameters must extend the basic ones (base/quote).
|
|
35
52
|
*/
|
|
36
|
-
export declare class PriceEndpoint<
|
|
37
|
-
constructor(params: AdapterEndpointParams<
|
|
53
|
+
export declare class PriceEndpoint<T extends EndpointGenerics> extends AdapterEndpoint<T> {
|
|
54
|
+
constructor(params: AdapterEndpointParams<T> & {
|
|
38
55
|
inputParameters: PriceEndpointInputParameters;
|
|
39
56
|
});
|
|
40
57
|
}
|
|
58
|
+
declare type PriceAdapterRequest<T extends RequestGenerics> = AdapterRequest<T> & {
|
|
59
|
+
requestContext: AdapterRequestContext<T> & {
|
|
60
|
+
priceMeta: {
|
|
61
|
+
inverse: boolean;
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
};
|
|
41
65
|
/**
|
|
42
66
|
* A PriceAdapter is a specific kind of Adapter that includes at least one PriceEnpoint.
|
|
43
67
|
*/
|
|
44
68
|
export declare class PriceAdapter<CustomSettings extends SettingsMap> extends Adapter<CustomSettings> {
|
|
45
|
-
|
|
69
|
+
includesMap?: IncludesMap;
|
|
70
|
+
constructor(params: AdapterParams<CustomSettings> & {
|
|
71
|
+
includes?: IncludesFile;
|
|
72
|
+
});
|
|
73
|
+
handleRequest(req: PriceAdapterRequest<{
|
|
74
|
+
Params: PriceEndpointParams;
|
|
75
|
+
}>, replySent: Promise<unknown>): Promise<AdapterResponse>;
|
|
46
76
|
}
|
|
47
77
|
export {};
|
package/adapter/price.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.PriceAdapter = exports.PriceEndpoint = exports.priceEndpointInputParameters = void 0;
|
|
4
|
-
const index_1 = require("./index");
|
|
5
4
|
const endpoint_1 = require("./endpoint");
|
|
5
|
+
const index_1 = require("./index");
|
|
6
6
|
/**
|
|
7
7
|
* Base input parameter config that any [[PriceEndpoint]] must extend
|
|
8
8
|
*/
|
|
@@ -30,6 +30,16 @@ class PriceEndpoint extends endpoint_1.AdapterEndpoint {
|
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
32
|
exports.PriceEndpoint = PriceEndpoint;
|
|
33
|
+
const buildIncludesMap = (includesFile) => {
|
|
34
|
+
const includesMap = {};
|
|
35
|
+
for (const { from, to, includes } of includesFile) {
|
|
36
|
+
if (!includesMap[from]) {
|
|
37
|
+
includesMap[from] = {};
|
|
38
|
+
}
|
|
39
|
+
includesMap[from][to] = includes[0];
|
|
40
|
+
}
|
|
41
|
+
return includesMap;
|
|
42
|
+
};
|
|
33
43
|
/**
|
|
34
44
|
* A PriceAdapter is a specific kind of Adapter that includes at least one PriceEnpoint.
|
|
35
45
|
*/
|
|
@@ -40,6 +50,38 @@ class PriceAdapter extends index_1.Adapter {
|
|
|
40
50
|
throw new Error(`This PriceAdapter's list of endpoints does not contain a valid PriceEndpoint`);
|
|
41
51
|
}
|
|
42
52
|
super(params);
|
|
53
|
+
if (params.includes) {
|
|
54
|
+
// Build includes map for constant lookups
|
|
55
|
+
this.includesMap = buildIncludesMap(params.includes);
|
|
56
|
+
const requestTransform = (req) => {
|
|
57
|
+
const priceRequest = req;
|
|
58
|
+
const requestData = priceRequest.requestContext.data;
|
|
59
|
+
const includesDetails = this.includesMap?.[requestData.base]?.[requestData.quote];
|
|
60
|
+
if (includesDetails) {
|
|
61
|
+
requestData.base = includesDetails.from || requestData.base;
|
|
62
|
+
requestData.quote = includesDetails.to || requestData.quote;
|
|
63
|
+
}
|
|
64
|
+
const inverse = includesDetails?.inverse || false;
|
|
65
|
+
priceRequest.requestContext.priceMeta = {
|
|
66
|
+
inverse,
|
|
67
|
+
};
|
|
68
|
+
};
|
|
69
|
+
this.requestTransforms?.push(requestTransform);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
async handleRequest(req, replySent) {
|
|
73
|
+
const response = await super.handleRequest(req, replySent);
|
|
74
|
+
if (this.includesMap && req.requestContext.priceMeta.inverse) {
|
|
75
|
+
// We need to search in the reverse order (quote -> base) because the request transform will have inverted the pair
|
|
76
|
+
const inverseResult = 1 / response.result;
|
|
77
|
+
response.result = inverseResult;
|
|
78
|
+
// Check if response data has a result within it
|
|
79
|
+
const data = response.data;
|
|
80
|
+
if (data?.result) {
|
|
81
|
+
data.result = inverseResult;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return response;
|
|
43
85
|
}
|
|
44
86
|
}
|
|
45
87
|
exports.PriceAdapter = PriceAdapter;
|
package/adapter/price.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"price.js","sourceRoot":"","sources":["../../../src/adapter/price.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"price.js","sourceRoot":"","sources":["../../../src/adapter/price.ts"],"names":[],"mappings":";;;AAEA,yCAA4C;AAC5C,mCAAyF;AAoBzF;;GAEG;AACU,QAAA,4BAA4B,GAAiC;IACxE,IAAI,EAAE;QACJ,OAAO,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC;QACzB,IAAI,EAAE,QAAQ;QACd,WAAW,EAAE,gDAAgD;QAC7D,QAAQ,EAAE,IAAI;KACf;IACD,KAAK,EAAE;QACL,OAAO,EAAE,CAAC,IAAI,EAAE,QAAQ,CAAC;QACzB,IAAI,EAAE,QAAQ;QACd,WAAW,EAAE,0CAA0C;QACvD,QAAQ,EAAE,IAAI;KACf;CACF,CAAA;AA2BD;;;GAGG;AACH,M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