@chainlink/external-adapter-framework 0.5.2 → 0.5.4
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 +6 -10
- package/adapter/basic.js +7 -10
- package/adapter/basic.js.map +1 -1
- package/adapter/endpoint.d.ts +6 -6
- package/adapter/endpoint.js +0 -1
- package/adapter/endpoint.js.map +1 -1
- package/adapter/price.d.ts +8 -10
- package/adapter/price.js +5 -8
- package/adapter/price.js.map +1 -1
- package/adapter/types.d.ts +13 -19
- package/background-executor.js +4 -19
- package/background-executor.js.map +1 -1
- package/cache/index.d.ts +6 -6
- package/cache/redis.d.ts +3 -0
- package/cache/redis.js +12 -19
- package/cache/redis.js.map +1 -1
- package/config/index.d.ts +0 -1
- package/config/index.js +7 -13
- package/config/index.js.map +1 -1
- package/examples/bank-frick/accounts.d.ts +24 -17
- package/examples/bank-frick/accounts.js +9 -22
- package/examples/bank-frick/accounts.js.map +1 -1
- package/examples/bank-frick/index.d.ts +15 -1
- package/examples/bank-frick/index.js +1 -1
- package/examples/coingecko/src/crypto-utils.d.ts +1 -15
- package/examples/coingecko/src/crypto-utils.js.map +1 -1
- package/examples/coingecko/src/endpoint/coins.d.ts +3 -20
- 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.map +1 -1
- package/examples/coingecko/src/endpoint/crypto-volume.d.ts +2 -2
- package/examples/coingecko/src/endpoint/crypto-volume.js.map +1 -1
- package/examples/coingecko/src/endpoint/crypto.d.ts +1 -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.map +1 -1
- package/examples/coingecko/src/endpoint/global-marketcap.d.ts +2 -2
- package/examples/coingecko/src/endpoint/global-marketcap.js.map +1 -1
- package/examples/coingecko/src/global-utils.d.ts +3 -18
- package/examples/coingecko/src/global-utils.js.map +1 -1
- package/examples/coingecko/src/index.js +1 -1
- package/examples/coingecko-old/batch-warming.d.ts +7 -0
- package/examples/coingecko-old/batch-warming.js +54 -0
- package/examples/coingecko-old/batch-warming.js.map +1 -0
- package/examples/coingecko-old/index.d.ts +2 -0
- package/examples/coingecko-old/index.js +12 -0
- package/examples/coingecko-old/index.js.map +1 -0
- package/examples/coingecko-old/rest.d.ts +12 -0
- package/examples/coingecko-old/rest.js +55 -0
- package/examples/coingecko-old/rest.js.map +1 -0
- package/examples/cryptocompare/src/endpoints/crypto.d.ts +2 -14
- package/examples/cryptocompare/src/endpoints/crypto.js.map +1 -1
- package/examples/cryptocompare/src/index.js +1 -1
- package/examples/genesis/index.js +1 -1
- package/examples/genesis/sseStream.d.ts +2 -13
- package/examples/genesis/sseStream.js.map +1 -1
- package/examples/ncfx/config/index.d.ts +12 -0
- package/examples/ncfx/config/index.js +16 -0
- package/examples/ncfx/config/index.js.map +1 -0
- package/examples/ncfx/index.d.ts +13 -0
- package/examples/ncfx/index.js +12 -0
- package/examples/ncfx/index.js.map +1 -0
- package/examples/ncfx/websocket.d.ts +47 -0
- package/examples/ncfx/websocket.js +74 -0
- package/examples/ncfx/websocket.js.map +1 -0
- package/metrics/util.d.ts +5 -5
- package/metrics/util.js.map +1 -1
- package/package.json +5 -3
- package/rate-limiting/background/fixed-frequency.d.ts +3 -2
- 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 +3 -2
- package/rate-limiting/request/simple-counting.js.map +1 -1
- package/transports/batch-warming.d.ts +13 -31
- package/transports/batch-warming.js +4 -4
- package/transports/batch-warming.js.map +1 -1
- package/transports/index.d.ts +13 -50
- package/transports/index.js.map +1 -1
- package/transports/metrics.d.ts +2 -2
- package/transports/metrics.js +2 -2
- package/transports/metrics.js.map +1 -1
- package/transports/rest.d.ts +13 -30
- package/transports/rest.js +3 -1
- package/transports/rest.js.map +1 -1
- package/transports/routing.d.ts +12 -10
- package/transports/routing.js +3 -1
- package/transports/routing.js.map +1 -1
- package/transports/sse.d.ts +18 -39
- package/transports/sse.js +1 -6
- package/transports/sse.js.map +1 -1
- package/transports/websocket.d.ts +23 -39
- package/transports/websocket.js +4 -5
- package/transports/websocket.js.map +1 -1
- package/util/request.d.ts +10 -46
- package/validation/index.js +15 -16
- package/validation/index.js.map +1 -1
- package/validation/override-functions.d.ts +3 -0
- package/validation/override-functions.js +41 -0
- package/validation/override-functions.js.map +1 -0
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,16 +1,14 @@
|
|
|
1
1
|
import { SettingsMap, BaseAdapterConfig, AdapterConfig } from '../config';
|
|
2
|
-
import { AdapterRequest, AdapterResponse
|
|
2
|
+
import { AdapterRequest, AdapterResponse } from '../util';
|
|
3
3
|
import { AdapterEndpoint } from './endpoint';
|
|
4
|
-
import { AdapterDependencies, AdapterParams, AdapterRateLimitingConfig, CustomAdapterSettings,
|
|
4
|
+
import { AdapterDependencies, AdapterParams, AdapterRateLimitingConfig, CustomAdapterSettings, RequestTransform } from './types';
|
|
5
5
|
/**
|
|
6
6
|
* Main class to represent an External Adapter
|
|
7
7
|
*/
|
|
8
8
|
export declare class Adapter<CustomSettings extends CustomAdapterSettings = SettingsMap> implements Omit<AdapterParams<CustomSettings>, 'bootstrap'> {
|
|
9
|
-
name:
|
|
9
|
+
name: string;
|
|
10
10
|
defaultEndpoint?: string | undefined;
|
|
11
|
-
endpoints: AdapterEndpoint<
|
|
12
|
-
CustomSettings: CustomSettings;
|
|
13
|
-
}>>[];
|
|
11
|
+
endpoints: AdapterEndpoint<unknown, unknown, CustomSettings>[];
|
|
14
12
|
envDefaultOverrides?: Partial<BaseAdapterConfig> | undefined;
|
|
15
13
|
customSettings?: SettingsMap | undefined;
|
|
16
14
|
rateLimiting?: AdapterRateLimitingConfig | undefined;
|
|
@@ -18,9 +16,7 @@ export declare class Adapter<CustomSettings extends CustomAdapterSettings = Sett
|
|
|
18
16
|
requestTransforms?: RequestTransform[];
|
|
19
17
|
initialized: boolean;
|
|
20
18
|
/** Object containing alias translations for all endpoints */
|
|
21
|
-
endpointsMap: Record<string, AdapterEndpoint<
|
|
22
|
-
CustomSettings: CustomSettings;
|
|
23
|
-
}>>>;
|
|
19
|
+
endpointsMap: Record<string, AdapterEndpoint<unknown, unknown, CustomSettings>>;
|
|
24
20
|
/** Initialized dependencies that the adapter will use */
|
|
25
21
|
dependencies: AdapterDependencies;
|
|
26
22
|
/** Configuration params for various adapter properties */
|
|
@@ -71,7 +67,7 @@ export declare class Adapter<CustomSettings extends CustomAdapterSettings = Sett
|
|
|
71
67
|
* @param req - the current adapter request
|
|
72
68
|
* @returns the modified (or new) request
|
|
73
69
|
*/
|
|
74
|
-
symbolOverrider(req: AdapterRequest): AdapterRequest<import("../util").
|
|
70
|
+
symbolOverrider(req: AdapterRequest): AdapterRequest<import("../util").AdapterRequestData>;
|
|
75
71
|
/**
|
|
76
72
|
* Takes the incoming request and applies all request transforms in the adapter
|
|
77
73
|
*
|
package/adapter/basic.js
CHANGED
|
@@ -71,8 +71,6 @@ class Adapter {
|
|
|
71
71
|
if (this.initialized) {
|
|
72
72
|
throw new Error('This adapter has already been initialized!');
|
|
73
73
|
}
|
|
74
|
-
// Building configs during initialization to avoid validation errors during construction
|
|
75
|
-
(0, config_1.validateAdapterConfig)(this.config, this.customSettings);
|
|
76
74
|
if (this.bootstrap) {
|
|
77
75
|
await this.bootstrap(this);
|
|
78
76
|
}
|
|
@@ -223,16 +221,15 @@ class Adapter {
|
|
|
223
221
|
* @returns the modified (or new) request
|
|
224
222
|
*/
|
|
225
223
|
symbolOverrider(req) {
|
|
226
|
-
const
|
|
227
|
-
const requestOverrides = rawRequestBody.data?.overrides?.[this.name.toLowerCase()];
|
|
224
|
+
const requestOverrides = req.requestContext.data?.['overrides']?.[this.name];
|
|
228
225
|
const base = req.requestContext.data['base'];
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
req.requestContext.data['base'] = requestOverrides[base];
|
|
226
|
+
// Perform overrides specified in the request payload
|
|
227
|
+
if (requestOverrides) {
|
|
228
|
+
req.requestContext.data['base'] = requestOverrides[base] ?? base;
|
|
232
229
|
}
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
req.requestContext.data['base'] = this.overrides[base];
|
|
230
|
+
// Perform hardcoded adapter overrides
|
|
231
|
+
if (this.overrides) {
|
|
232
|
+
req.requestContext.data['base'] = this.overrides[base] ?? base;
|
|
236
233
|
}
|
|
237
234
|
return req;
|
|
238
235
|
}
|
package/adapter/basic.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"basic.js","sourceRoot":"","sources":["../../../src/adapter/basic.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,sDAA2B;AAC3B,oCAAyF;AACzF,+DAAgD;AAChD,
|
|
1
|
+
{"version":3,"file":"basic.js","sourceRoot":"","sources":["../../../src/adapter/basic.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,sDAA2B;AAC3B,oCAAyF;AACzF,+DAAgD;AAChD,sCAMkB;AAClB,wEAAyD;AACzD,oDAIyB;AACzB,kCAA6F;AAC7F,6EAAuE;AAUvE,+CAAyD;AAEzD,MAAM,MAAM,GAAG,IAAA,iBAAU,EAAC,SAAS,CAAC,CAAA;AAEpC;;GAEG;AACH,MAAa,OAAO;IA4BlB,YAAY,MAAqC;QAfjD,uBAAuB;QACvB,gBAAW,GAAG,KAAK,CAAA;QAEnB,6DAA6D;QAC7D,iBAAY,GAAsE,EAAE,CAAA;QAYlF,mBAAmB;QACnB,IAAI,CAAC,IAAI,GAAG,MAAM,CAAC,IAAI,CAAA;QACvB,IAAI,CAAC,eAAe,GAAG,MAAM,CAAC,eAAe,EAAE,WAAW,EAAE,CAAA;QAC5D,IAAI,CAAC,SAAS,GAAG,MAAM,CAAC,SAAS,CAAA;QACjC,IAAI,CAAC,mBAAmB,GAAG,MAAM,CAAC,mBAAmB,CAAA;QACrD,IAAI,CAAC,cAAc,GAAG,MAAM,CAAC,cAAc,CAAA;QAC3C,IAAI,CAAC,YAAY,GAAG,MAAM,CAAC,YAAY,CAAA;QACvC,IAAI,CAAC,SAAS,GAAG,MAAM,CAAC,SAAS,CAAA;QACjC,IAAI,CAAC,iBAAiB,GAAG,CAAC,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,iBAAiB,IAAI,EAAE,CAAC,C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B;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;AApYD,0BAoYC"}
|
package/adapter/endpoint.d.ts
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { SettingsMap } from '../config';
|
|
2
|
+
import { Transport } from '../transports';
|
|
2
3
|
import { InputParameters } from '../validation';
|
|
4
|
+
import { AdapterEndpointParams, EndpointRateLimitingConfig } from './types';
|
|
3
5
|
import { InputValidator } from '../validation/input-validator';
|
|
4
|
-
import { AdapterEndpointParams, EndpointGenerics, EndpointRateLimitingConfig } from './types';
|
|
5
6
|
/**
|
|
6
7
|
* Main class to represent an endpoint within an External Adapter
|
|
7
8
|
*/
|
|
8
|
-
export declare class AdapterEndpoint<
|
|
9
|
+
export declare class AdapterEndpoint<Params, Result, CustomSettings extends SettingsMap> implements AdapterEndpointParams<Params, Result, CustomSettings> {
|
|
9
10
|
name: string;
|
|
10
11
|
aliases?: string[] | undefined;
|
|
11
|
-
transport: Transport<
|
|
12
|
+
transport: Transport<Params, Result, CustomSettings>;
|
|
12
13
|
inputParameters: InputParameters;
|
|
13
14
|
rateLimiting?: EndpointRateLimitingConfig | undefined;
|
|
14
15
|
validator: InputValidator;
|
|
15
|
-
|
|
16
|
-
constructor(params: AdapterEndpointParams<T>);
|
|
16
|
+
constructor(params: AdapterEndpointParams<Params, Result, CustomSettings>);
|
|
17
17
|
}
|
package/adapter/endpoint.js
CHANGED
|
@@ -13,7 +13,6 @@ 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;
|
|
17
16
|
}
|
|
18
17
|
}
|
|
19
18
|
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":";;;AAIA,mEAA8D;AAE9D;;GAEG;AACH,MAAa,eAAe;IAU1B,YAAY,MAA6D;QACvE,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;IAC3D,CAAC;CACF;AAlBD,0CAkBC"}
|
package/adapter/price.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { SettingsMap } from '../config';
|
|
2
|
-
import { AdapterRequest, AdapterRequestContext, AdapterResponse
|
|
2
|
+
import { AdapterRequest, AdapterRequestContext, AdapterResponse } from '../util';
|
|
3
3
|
import { AdapterEndpoint } from './endpoint';
|
|
4
|
-
import { Adapter, AdapterEndpointParams, AdapterParams
|
|
4
|
+
import { Adapter, AdapterEndpointParams, AdapterParams } from './index';
|
|
5
5
|
/**
|
|
6
6
|
* Type for the base input parameter config that any [[PriceEndpoint]] must extend
|
|
7
7
|
*/
|
|
@@ -10,13 +10,13 @@ export declare type PriceEndpointInputParameters = {
|
|
|
10
10
|
aliases: readonly ['from', 'coin', ...string[]];
|
|
11
11
|
type: 'string';
|
|
12
12
|
description: 'The symbol of symbols of the currency to query';
|
|
13
|
-
required:
|
|
13
|
+
required: false;
|
|
14
14
|
};
|
|
15
15
|
quote: {
|
|
16
16
|
aliases: readonly ['to', 'market', ...string[]];
|
|
17
17
|
type: 'string';
|
|
18
18
|
description: 'The symbol of the currency to convert to';
|
|
19
|
-
required:
|
|
19
|
+
required: true;
|
|
20
20
|
};
|
|
21
21
|
};
|
|
22
22
|
/**
|
|
@@ -50,12 +50,12 @@ declare type IncludesMap = Record<string, Record<string, IncludeDetails>>;
|
|
|
50
50
|
* A PriceEndpoint is a specific type of AdapterEndpoint. Meant to comply with standard practices for
|
|
51
51
|
* Data Feeds, its InputParameters must extend the basic ones (base/quote).
|
|
52
52
|
*/
|
|
53
|
-
export declare class PriceEndpoint<
|
|
54
|
-
constructor(params: AdapterEndpointParams<
|
|
53
|
+
export declare class PriceEndpoint<Params extends PriceEndpointParams, ProviderResponseBody, CustomSettings extends SettingsMap> extends AdapterEndpoint<Params, ProviderResponseBody, CustomSettings> {
|
|
54
|
+
constructor(params: AdapterEndpointParams<Params, ProviderResponseBody, CustomSettings> & {
|
|
55
55
|
inputParameters: PriceEndpointInputParameters;
|
|
56
56
|
});
|
|
57
57
|
}
|
|
58
|
-
declare type PriceAdapterRequest<T
|
|
58
|
+
declare type PriceAdapterRequest<T> = AdapterRequest<T> & {
|
|
59
59
|
requestContext: AdapterRequestContext<T> & {
|
|
60
60
|
priceMeta: {
|
|
61
61
|
inverse: boolean;
|
|
@@ -70,8 +70,6 @@ export declare class PriceAdapter<CustomSettings extends SettingsMap> extends Ad
|
|
|
70
70
|
constructor(params: AdapterParams<CustomSettings> & {
|
|
71
71
|
includes?: IncludesFile;
|
|
72
72
|
});
|
|
73
|
-
handleRequest(req: PriceAdapterRequest<
|
|
74
|
-
Params: PriceEndpointParams;
|
|
75
|
-
}>, replySent: Promise<unknown>): Promise<AdapterResponse>;
|
|
73
|
+
handleRequest(req: PriceAdapterRequest<PriceEndpointParams>, replySent: Promise<unknown>): Promise<AdapterResponse>;
|
|
76
74
|
}
|
|
77
75
|
export {};
|
package/adapter/price.js
CHANGED
|
@@ -11,7 +11,7 @@ exports.priceEndpointInputParameters = {
|
|
|
11
11
|
aliases: ['from', 'coin'],
|
|
12
12
|
type: 'string',
|
|
13
13
|
description: 'The symbol of symbols of the currency to query',
|
|
14
|
-
required:
|
|
14
|
+
required: false,
|
|
15
15
|
},
|
|
16
16
|
quote: {
|
|
17
17
|
aliases: ['to', 'market'],
|
|
@@ -71,14 +71,11 @@ class PriceAdapter extends index_1.Adapter {
|
|
|
71
71
|
}
|
|
72
72
|
async handleRequest(req, replySent) {
|
|
73
73
|
const response = await super.handleRequest(req, replySent);
|
|
74
|
-
if (this.includesMap
|
|
74
|
+
if (this.includesMap) {
|
|
75
75
|
// We need to search in the reverse order (quote -> base) because the request transform will have inverted the pair
|
|
76
|
-
const
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
const data = response.data;
|
|
80
|
-
if (data?.result) {
|
|
81
|
-
data.result = inverseResult;
|
|
76
|
+
const includes = this.includesMap[req.requestContext.data.quote]?.[req.requestContext.data.base];
|
|
77
|
+
if (includes && includes.inverse) {
|
|
78
|
+
response.result = 1 / response.result;
|
|
82
79
|
}
|
|
83
80
|
}
|
|
84
81
|
return response;
|
package/adapter/price.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"price.js","sourceRoot":"","sources":["../../../src/adapter/price.ts"],"names":[],"mappings":";;;AAEA,yCAA4C;AAC5C,
|
|
1
|
+
{"version":3,"file":"price.js","sourceRoot":"","sources":["../../../src/adapter/price.ts"],"names":[],"mappings":";;;AAEA,yCAA4C;AAC5C,mCAAuE;AAoBvE;;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,KAAK;KAChB;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,MAAa,aAIX,SAAQ,0BAA6D;IACrE,YACE,MAEC;QAED,KAAK,CAAC,MAAM,CAAC,CAAA;IACf,CAAC;CACF;AAZD,sCAYC;AAED,MAAM,gBAAgB,GAAG,CAAC,YAA0B,EAAE,EAAE;IACtD,MAAM,WAAW,GAAgB,EAAE,CAAA;IAEnC,KAAK,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,QAAQ,EAAE,IAAI,YAAY,EAAE;QACjD,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE;YACtB,WAAW,CAAC,IAAI,CAAC,GAAG,EAAE,CAAA;SACvB;QACD,WAAW,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAA;KACpC;IAED,OAAO,WAAW,CAAA;AACpB,CAAC,CAAA;AAUD;;GAEG;AACH,MAAa,YAAiD,SAAQ,eAAuB;IAG3F,YACE,MAEC;QAED,yDAAyD;QACzD,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,YAAY,a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AAC,GAAG,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;YACjF,IAAI,QAAQ,IAAI,QAAQ,CAAC,OAAO,EAAE;gBAChC,QAAQ,CAAC,MAAM,GAAG,CAAC,GAAI,QAAQ,CAAC,MAAiB,CAAA;aAClD;SACF;QAED,OAAO,QAAQ,CAAA;IACjB,CAAC;CACF;AA1DD,oCA0DC"}
|
package/adapter/types.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import type EventSource from 'eventsource';
|
|
2
1
|
import Redis from 'ioredis';
|
|
3
|
-
import {
|
|
4
|
-
import { AdapterConfig, BaseAdapterConfig
|
|
5
|
-
import {
|
|
6
|
-
import { Transport
|
|
2
|
+
import { AdapterEndpoint } from './endpoint';
|
|
3
|
+
import { CustomSettingsType, SettingsMap, AdapterConfig, BaseAdapterConfig } from '../config';
|
|
4
|
+
import { RequestRateLimiter, BackgroundExecuteRateLimiter, AdapterRateLimitTier } from '../rate-limiting';
|
|
5
|
+
import { Transport } from '../transports';
|
|
7
6
|
import { AdapterRequest, SubscriptionSetFactory } from '../util';
|
|
8
7
|
import { InputParameters } from '../validation';
|
|
8
|
+
import { Cache } from '../cache';
|
|
9
|
+
import type EventSource from 'eventsource';
|
|
9
10
|
import { Adapter } from './basic';
|
|
10
|
-
import { AdapterEndpoint } from './endpoint';
|
|
11
11
|
export declare type CustomAdapterSettings = SettingsMap & NegatedAdapterSettings;
|
|
12
12
|
declare type NegatedAdapterSettings = {
|
|
13
13
|
[K in keyof BaseAdapterConfig]?: never;
|
|
@@ -33,11 +33,11 @@ export interface AdapterDependencies {
|
|
|
33
33
|
* Context that will be used on background executions of a Transport.
|
|
34
34
|
* For example, the endpointName used to log statements or generate Cache keys.
|
|
35
35
|
*/
|
|
36
|
-
export interface AdapterContext<
|
|
36
|
+
export interface AdapterContext<CustomSettings extends CustomSettingsType<CustomSettings> = SettingsMap> {
|
|
37
37
|
/** Endpoint instance within the adapter that the Transport is related to */
|
|
38
|
-
adapterEndpoint: AdapterEndpoint<
|
|
38
|
+
adapterEndpoint: AdapterEndpoint<unknown, unknown, CustomSettings>;
|
|
39
39
|
/** Initialized config for the adapter that the Transport can access */
|
|
40
|
-
adapterConfig: AdapterConfig<
|
|
40
|
+
adapterConfig: AdapterConfig<CustomSettings>;
|
|
41
41
|
}
|
|
42
42
|
/**
|
|
43
43
|
* Structure to describe rate limits specs for the Adapter
|
|
@@ -63,7 +63,7 @@ export declare type Overrides = {
|
|
|
63
63
|
*/
|
|
64
64
|
export interface AdapterParams<CustomSettings extends SettingsMap> {
|
|
65
65
|
/** Name of the adapter */
|
|
66
|
-
name:
|
|
66
|
+
name: string;
|
|
67
67
|
/** If present, the string that will be used for requests with no specified endpoint */
|
|
68
68
|
defaultEndpoint?: string;
|
|
69
69
|
/**
|
|
@@ -75,7 +75,7 @@ export interface AdapterParams<CustomSettings extends SettingsMap> {
|
|
|
75
75
|
* We also can't use generics, because if we had more than one transport with different requests (very likely)
|
|
76
76
|
* then those new types wouldn't match with each other.
|
|
77
77
|
*/
|
|
78
|
-
endpoints: AdapterEndpoint<any>[];
|
|
78
|
+
endpoints: AdapterEndpoint<any, any, CustomSettings>[];
|
|
79
79
|
/** Map of overrides to the default config values for an Adapter */
|
|
80
80
|
envDefaultOverrides?: Partial<BaseAdapterConfig>;
|
|
81
81
|
/** List of custom env vars for this particular adapter (e.g. RPC_URL) */
|
|
@@ -100,25 +100,19 @@ export interface EndpointRateLimitingConfig {
|
|
|
100
100
|
*/
|
|
101
101
|
allocationPercentage: number;
|
|
102
102
|
}
|
|
103
|
-
/**
|
|
104
|
-
* Helper type structure that contains the different types passed to the generic parameters of an AdapterEndpoint
|
|
105
|
-
*/
|
|
106
|
-
export declare type EndpointGenerics = TransportGenerics;
|
|
107
103
|
/**
|
|
108
104
|
* Structure to describe a specific endpoint in an [[Adapter]]
|
|
109
105
|
*/
|
|
110
|
-
export interface AdapterEndpointParams<
|
|
106
|
+
export interface AdapterEndpointParams<Params, Result, CustomSettings extends SettingsMap> {
|
|
111
107
|
/** Name that will be used to match input params to this endpoint (case insensitive) */
|
|
112
108
|
name: string;
|
|
113
109
|
/** List of alternative endpoint names that will resolve to this same transport (case insensitive) */
|
|
114
110
|
aliases?: string[];
|
|
115
111
|
/** Transport that will be used to handle data processing and communication for this endpoint */
|
|
116
|
-
transport: Transport<
|
|
112
|
+
transport: Transport<Params, Result, CustomSettings>;
|
|
117
113
|
/** Specification of what the body of a request hitting this endpoint should look like (used for validation) */
|
|
118
114
|
inputParameters: InputParameters;
|
|
119
115
|
/** Specific details related to the rate limiting for this endpoint in particular */
|
|
120
116
|
rateLimiting?: EndpointRateLimitingConfig;
|
|
121
|
-
/** Custom function that generates cache keys */
|
|
122
|
-
cacheKeyGenerator?: (data: Record<string, unknown>) => string;
|
|
123
117
|
}
|
|
124
118
|
export {};
|
package/background-executor.js
CHANGED
|
@@ -24,8 +24,8 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
26
|
exports.callBackgroundExecutes = void 0;
|
|
27
|
-
const metrics = __importStar(require("./metrics"));
|
|
28
27
|
const util_1 = require("./util");
|
|
28
|
+
const metrics = __importStar(require("./metrics"));
|
|
29
29
|
const logger = (0, util_1.makeLogger)('BackgroundExecutor');
|
|
30
30
|
/**
|
|
31
31
|
* Very simple background loop that will call the [[Transport.backgroundExecute]] functions in all Transports.
|
|
@@ -47,12 +47,11 @@ async function callBackgroundExecutes(adapter, apiShutdownPromise) {
|
|
|
47
47
|
clearTimeout(timeoutsMap[endpointName]);
|
|
48
48
|
}
|
|
49
49
|
});
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
const backgroundExecute = transport.backgroundExecute?.bind(transport);
|
|
50
|
+
for (const endpoint of adapter.endpoints) {
|
|
51
|
+
const backgroundExecute = endpoint.transport.backgroundExecute?.bind(endpoint.transport);
|
|
53
52
|
if (!backgroundExecute) {
|
|
54
53
|
logger.debug(`Endpoint "${endpoint.name}" has no background execute, skipping...`);
|
|
55
|
-
|
|
54
|
+
continue;
|
|
56
55
|
}
|
|
57
56
|
const context = {
|
|
58
57
|
adapterEndpoint: endpoint,
|
|
@@ -77,20 +76,6 @@ async function callBackgroundExecutes(adapter, apiShutdownPromise) {
|
|
|
77
76
|
};
|
|
78
77
|
// Start recursive async calls
|
|
79
78
|
handler();
|
|
80
|
-
};
|
|
81
|
-
for (const endpoint of adapter.endpoints) {
|
|
82
|
-
const { transport } = endpoint;
|
|
83
|
-
// Check if transport is a MetaTransport by casting and checking a known property (transports)
|
|
84
|
-
const castMeta = transport;
|
|
85
|
-
if (castMeta.transports) {
|
|
86
|
-
logger.debug(`Encountered MetaTransport ${transport.constructor.name}, calling backgroundExecute on all transports`);
|
|
87
|
-
for (const nestedTransport of Object.values(castMeta.transports)) {
|
|
88
|
-
callBackgroundExecute(endpoint, nestedTransport);
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
else {
|
|
92
|
-
callBackgroundExecute(endpoint, transport);
|
|
93
|
-
}
|
|
94
79
|
}
|
|
95
80
|
}
|
|
96
81
|
exports.callBackgroundExecutes = callBackgroundExecutes;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"background-executor.js","sourceRoot":"","sources":["../../src/background-executor.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AACA,mDAAoC;AAEpC,
|
|
1
|
+
{"version":3,"file":"background-executor.js","sourceRoot":"","sources":["../../src/background-executor.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AACA,iCAAmC;AACnC,mDAAoC;AAEpC,MAAM,MAAM,GAAG,IAAA,iBAAU,EAAC,oBAAoB,CAAC,CAAA;AAE/C;;;;;;GAMG;AACI,KAAK,UAAU,sBAAsB,CAAC,OAAgB,EAAE,kBAAkC;IAC/F,uFAAuF;IACvF,4FAA4F;IAC5F,IAAI,YAAY,GAAG,KAAK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GAAG,CAAC,CAAA;YAC1E,MAAM,UAAU,GAAG,MAAM,iBAAiB,CAAC,OAAO,CAAC,CAAA;YACnD,MAAM,CAAC,KAAK,CACV,6CAA6C,QAAQ,CAAC,IAAI,mBAAmB,UAAU,IAAI,CAC5F,CAAA;YAED,YAAY,EAAE,CAAA;YACd,WAAW,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,UAAU,CAAC,OAAO,EAAE,UAAU,CAAC,CAAA;QAC9D,CAAC,CAAA;QAED,8BAA8B;QAC9B,OAAO,EAAE,CAAA;KACV;AACH,CAAC;AAvDD,wDAuDC"}
|
package/cache/index.d.ts
CHANGED
|
@@ -49,13 +49,13 @@ export interface Cache<T = unknown> {
|
|
|
49
49
|
*/
|
|
50
50
|
delete: (key: string) => Promise<void>;
|
|
51
51
|
}
|
|
52
|
-
export declare const calculateCacheKey: <
|
|
53
|
-
adapterEndpoint: AdapterEndpoint<
|
|
54
|
-
adapterConfig: AdapterConfig<
|
|
52
|
+
export declare const calculateCacheKey: <Params, Result, CustomSettings extends SettingsMap>({ adapterEndpoint, adapterConfig, }: {
|
|
53
|
+
adapterEndpoint: AdapterEndpoint<Params, Result, CustomSettings>;
|
|
54
|
+
adapterConfig: AdapterConfig<CustomSettings>;
|
|
55
55
|
}, data: unknown) => string;
|
|
56
|
-
export declare const calculateFeedId: <
|
|
57
|
-
adapterEndpoint: AdapterEndpoint<
|
|
58
|
-
adapterConfig: AdapterConfig<
|
|
56
|
+
export declare const calculateFeedId: <Params, Result, CustomSettings extends SettingsMap>({ adapterEndpoint, adapterConfig, }: {
|
|
57
|
+
adapterEndpoint: AdapterEndpoint<Params, Result, CustomSettings>;
|
|
58
|
+
adapterConfig: AdapterConfig<CustomSettings>;
|
|
59
59
|
}, data: unknown) => string;
|
|
60
60
|
/**
|
|
61
61
|
* Calculates a unique key from the provided data.
|
package/cache/redis.d.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import Redis from 'ioredis';
|
|
2
2
|
import { Cache, CacheEntry } from './index';
|
|
3
|
+
import { CMD_SENT_STATUS } from './metrics';
|
|
4
|
+
import * as cacheMetrics from './metrics';
|
|
5
|
+
export declare const recordRedisCommandMetric: (status: cacheMetrics.CMD_SENT_STATUS, functionName: string) => void;
|
|
3
6
|
/**
|
|
4
7
|
* Redis implementation of a Cache. It uses a simple js Object, storing entries with both
|
|
5
8
|
* a value and an expiration timestamp. Expired entries are deleted on reads (i.e. no background gc/upkeep).
|
package/cache/redis.js
CHANGED
|
@@ -23,10 +23,17 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.RedisCache = void 0;
|
|
26
|
+
exports.RedisCache = exports.recordRedisCommandMetric = void 0;
|
|
27
27
|
const util_1 = require("../util");
|
|
28
|
+
const metrics_1 = require("./metrics");
|
|
28
29
|
const cacheMetrics = __importStar(require("./metrics"));
|
|
29
30
|
const logger = (0, util_1.makeLogger)('RedisCache');
|
|
31
|
+
const recordRedisCommandMetric = (status, functionName) => {
|
|
32
|
+
cacheMetrics.redisCommandsSentCount
|
|
33
|
+
.labels({ status: cacheMetrics.CMD_SENT_STATUS[status], function_name: functionName })
|
|
34
|
+
.inc();
|
|
35
|
+
};
|
|
36
|
+
exports.recordRedisCommandMetric = recordRedisCommandMetric;
|
|
30
37
|
/**
|
|
31
38
|
* Redis implementation of a Cache. It uses a simple js Object, storing entries with both
|
|
32
39
|
* a value and an expiration timestamp. Expired entries are deleted on reads (i.e. no background gc/upkeep).
|
|
@@ -40,10 +47,6 @@ class RedisCache {
|
|
|
40
47
|
async get(key) {
|
|
41
48
|
logger.trace(`Getting key ${key}`);
|
|
42
49
|
const value = await this.client.get(key);
|
|
43
|
-
// Record get command sent to Redis
|
|
44
|
-
cacheMetrics.redisCommandsSentCount
|
|
45
|
-
.labels({ status: cacheMetrics.CMD_SENT_STATUS.SUCCESS, function_name: 'get' })
|
|
46
|
-
.inc();
|
|
47
50
|
if (!value) {
|
|
48
51
|
logger.debug(`No entry in redis cache for key "${key}", returning undefined`);
|
|
49
52
|
return undefined;
|
|
@@ -53,25 +56,17 @@ class RedisCache {
|
|
|
53
56
|
async delete(key) {
|
|
54
57
|
logger.trace(`Deleting key ${key}`);
|
|
55
58
|
await this.client.del(key);
|
|
56
|
-
// Record delete command sent to Redis
|
|
57
|
-
cacheMetrics.redisCommandsSentCount
|
|
58
|
-
.labels({ status: cacheMetrics.CMD_SENT_STATUS.SUCCESS, function_name: 'delete' })
|
|
59
|
-
.inc();
|
|
60
59
|
}
|
|
61
60
|
async set(key, value, ttl) {
|
|
62
61
|
logger.trace(`Setting key ${key}`);
|
|
63
|
-
|
|
64
|
-
// Only record metrics if feed Id is present, otherwise assuming value is not adapter response to record
|
|
62
|
+
// Only record metrics if feed id is present, otherwise assuming value is not adapter response to record
|
|
65
63
|
const feedId = value.meta?.metrics?.feedId;
|
|
66
64
|
if (feedId) {
|
|
67
65
|
// Record cache set count, max age, and staleness (set to 0 for cache set)
|
|
68
66
|
const label = cacheMetrics.cacheMetricsLabel(key, feedId, cacheMetrics.CacheTypes.Redis);
|
|
69
67
|
cacheMetrics.cacheSet(label, ttl);
|
|
70
68
|
}
|
|
71
|
-
|
|
72
|
-
cacheMetrics.redisCommandsSentCount
|
|
73
|
-
.labels({ status: cacheMetrics.CMD_SENT_STATUS.SUCCESS, function_name: 'set' })
|
|
74
|
-
.inc();
|
|
69
|
+
await this.client.set(key, JSON.stringify(value), 'PX', ttl);
|
|
75
70
|
}
|
|
76
71
|
async setMany(entries, ttl) {
|
|
77
72
|
logger.trace(`Setting a bunch of keys`);
|
|
@@ -83,7 +78,7 @@ class RedisCache {
|
|
|
83
78
|
await chain.exec();
|
|
84
79
|
// Loop again, but this time to record these in metrics
|
|
85
80
|
for (const entry of entries) {
|
|
86
|
-
// Only record metrics if feed
|
|
81
|
+
// Only record metrics if feed id is present, otherwise assuming value is not adapter response to record
|
|
87
82
|
const feedId = entry.value.meta?.metrics?.feedId;
|
|
88
83
|
if (feedId) {
|
|
89
84
|
// Record cache set count, max age, and staleness (set to 0 for cache set)
|
|
@@ -92,9 +87,7 @@ class RedisCache {
|
|
|
92
87
|
}
|
|
93
88
|
}
|
|
94
89
|
// Record setMany command sent to Redis
|
|
95
|
-
|
|
96
|
-
.labels({ status: cacheMetrics.CMD_SENT_STATUS.SUCCESS, function_name: 'exec' })
|
|
97
|
-
.inc();
|
|
90
|
+
(0, exports.recordRedisCommandMetric)(metrics_1.CMD_SENT_STATUS.SUCCESS, 'exec');
|
|
98
91
|
}
|
|
99
92
|
}
|
|
100
93
|
exports.RedisCache = RedisCache;
|
package/cache/redis.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"redis.js","sourceRoot":"","sources":["../../../src/cache/redis.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AACA,kCAAqD;AAErD,wDAAyC;AAEzC,MAAM,MAAM,GAAG,IAAA,iBAAU,EAAC,YAAY,CAAC,CAAA;
|
|
1
|
+
{"version":3,"file":"redis.js","sourceRoot":"","sources":["../../../src/cache/redis.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AACA,kCAAqD;AAErD,uCAA2C;AAC3C,wDAAyC;AAEzC,MAAM,MAAM,GAAG,IAAA,iBAAU,EAAC,YAAY,CAAC,CAAA;AAEhC,MAAM,wBAAwB,GAAG,CACtC,MAAoC,EACpC,YAAoB,EACd,EAAE;IACR,YAAY,CAAC,sBAAsB;SAChC,MAAM,CAAC,EAAE,MAAM,EAAE,YAAY,CAAC,eAAe,CAAC,MAAM,CAAC,EAAE,aAAa,EAAE,YAAY,EAAE,CAAC;SACrF,GAAG,EAAE,CAAA;AACV,CAAC,CAAA;AAPY,QAAA,wBAAwB,4BAOpC;AAED;;;;;GAKG;AACH,MAAa,UAAU;IACrB,YAAoB,MAAa;QAAb,WAAM,GAAN,MA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B,CAAC,CAAA;QAEvC,yCAAyC;QACzC,IAAI,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAA;QAC/B,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE;YAC3B,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,IAAI,EAAE,GAAG,CAAC,CAAA;SACrE;QAED,MAAM,KAAK,CAAC,IAAI,EAAE,CAAA;QAElB,uDAAuD;QACvD,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE;YAC3B,wGAAwG;YACxG,MAAM,MAAM,GAAI,KAAK,CAAC,KAAoC,CAAC,IAAI,EAAE,OAAO,EAAE,MAAM,CAAA;YAChF,IAAI,MAAM,EAAE;gBACV,0EAA0E;gBAC1E,MAAM,KAAK,GAAG,YAAY,CAAC,iBAAiB,CAC1C,KAAK,CAAC,GAAG,EACT,MAAM,EACN,YAAY,CAAC,UAAU,CAAC,KAAK,CAC9B,CAAA;gBACD,YAAY,CAAC,QAAQ,CAAC,KAAK,EAAE,GAAG,CAAC,CAAA;aAClC;SACF;QAED,uCAAuC;QACvC,IAAA,gCAAwB,EAAC,yBAAe,CAAC,OAAO,EAAE,MAAM,CAAC,CAAA;IAC3D,CAAC;CACF;AA9DD,gCA8DC"}
|
package/config/index.d.ts
CHANGED
|
@@ -217,7 +217,6 @@ export declare const buildAdapterConfig: <CustomSettings extends CustomSettingsT
|
|
|
217
217
|
overrides?: Partial<BaseAdapterConfig> | undefined;
|
|
218
218
|
customSettings?: SettingsMap | undefined;
|
|
219
219
|
}) => AdapterConfig<CustomSettings>;
|
|
220
|
-
export declare const validateAdapterConfig: <CustomSettings extends CustomSettingsType<CustomSettings> = EmptySettings>(adapterConfig: AdapterConfig<CustomSettings>, customSettings?: SettingsMap) => void;
|
|
221
220
|
declare type SettingValueType = string | number | boolean;
|
|
222
221
|
declare type SettingType<C extends Setting> = C['type'] extends 'string' ? string : C['type'] extends 'number' ? number : C['type'] extends 'boolean' ? boolean : C['type'] extends 'enum' ? C['options'] extends readonly string[] ? C['options'][number] : never : never;
|
|
223
222
|
declare type BaseSettingsType = typeof BaseSettings;
|