@chainlink/external-adapter-framework 0.0.6 → 0.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/adapter.d.ts +88 -0
- package/adapter.js +112 -0
- package/background-executor.d.ts +11 -0
- package/background-executor.js +45 -0
- package/cache/factory.d.ts +6 -0
- package/cache/factory.js +57 -0
- package/cache/index.d.ts +90 -0
- package/cache/index.js +169 -0
- package/cache/local.d.ts +23 -0
- package/cache/local.js +83 -0
- package/cache/metrics.d.ts +27 -0
- package/cache/metrics.js +120 -0
- package/cache/redis.d.ts +16 -0
- package/cache/redis.js +100 -0
- package/chainlink-external-adapter-framework-v0.0.8.tgz +0 -0
- package/config/index.d.ts +195 -0
- package/config/index.js +365 -0
- package/config/provider-limits.d.ts +31 -0
- package/config/provider-limits.js +75 -0
- package/examples/coingecko/batch-warming.d.ts +2 -0
- package/examples/coingecko/batch-warming.js +52 -0
- package/examples/coingecko/index.d.ts +2 -0
- package/examples/coingecko/index.js +10 -0
- package/examples/coingecko/rest.d.ts +2 -0
- package/examples/coingecko/rest.js +50 -0
- package/examples/ncfx/config/index.d.ts +12 -0
- package/examples/ncfx/config/index.js +15 -0
- package/examples/ncfx/index.d.ts +2 -0
- package/examples/ncfx/index.js +10 -0
- package/examples/ncfx/websocket.d.ts +36 -0
- package/examples/ncfx/websocket.js +72 -0
- package/index.d.ts +12 -0
- package/index.js +92 -0
- package/metrics/constants.d.ts +16 -0
- package/metrics/constants.js +25 -0
- package/metrics/index.d.ts +15 -0
- package/metrics/index.js +123 -0
- package/metrics/util.d.ts +3 -0
- package/metrics/util.js +9 -0
- package/package/adapter.d.ts +88 -0
- package/package/adapter.js +112 -0
- package/package/background-executor.d.ts +11 -0
- package/package/background-executor.js +45 -0
- package/package/cache/factory.d.ts +6 -0
- package/package/cache/factory.js +57 -0
- package/package/cache/index.d.ts +90 -0
- package/package/cache/index.js +169 -0
- package/package/cache/local.d.ts +23 -0
- package/package/cache/local.js +83 -0
- package/package/cache/metrics.d.ts +27 -0
- package/package/cache/metrics.js +120 -0
- package/package/cache/redis.d.ts +16 -0
- package/package/cache/redis.js +100 -0
- package/package/config/index.d.ts +195 -0
- package/package/config/index.js +365 -0
- package/package/config/provider-limits.d.ts +31 -0
- package/package/config/provider-limits.js +75 -0
- package/package/examples/coingecko/batch-warming.d.ts +2 -0
- package/package/examples/coingecko/batch-warming.js +52 -0
- package/package/examples/coingecko/index.d.ts +2 -0
- package/package/examples/coingecko/index.js +10 -0
- package/package/examples/coingecko/rest.d.ts +2 -0
- package/package/examples/coingecko/rest.js +50 -0
- package/package/examples/ncfx/config/index.d.ts +12 -0
- package/package/examples/ncfx/config/index.js +15 -0
- package/package/examples/ncfx/index.d.ts +2 -0
- package/package/examples/ncfx/index.js +10 -0
- package/package/examples/ncfx/websocket.d.ts +36 -0
- package/package/examples/ncfx/websocket.js +72 -0
- package/package/index.d.ts +12 -0
- package/package/index.js +92 -0
- package/package/metrics/constants.d.ts +16 -0
- package/package/metrics/constants.js +25 -0
- package/package/metrics/index.d.ts +15 -0
- package/package/metrics/index.js +123 -0
- package/package/metrics/util.d.ts +3 -0
- package/package/metrics/util.js +9 -0
- package/package/package.json +69 -0
- package/package/rate-limiting/background/fixed-frequency.d.ts +10 -0
- package/package/rate-limiting/background/fixed-frequency.js +37 -0
- package/package/rate-limiting/index.d.ts +54 -0
- package/package/rate-limiting/index.js +63 -0
- package/package/rate-limiting/metrics.d.ts +3 -0
- package/package/rate-limiting/metrics.js +44 -0
- package/package/rate-limiting/request/simple-counting.d.ts +20 -0
- package/package/rate-limiting/request/simple-counting.js +62 -0
- package/package/test.d.ts +1 -0
- package/package/test.js +6 -0
- package/package/transports/batch-warming.d.ts +34 -0
- package/package/transports/batch-warming.js +101 -0
- package/package/transports/index.d.ts +87 -0
- package/package/transports/index.js +87 -0
- package/package/transports/metrics.d.ts +21 -0
- package/package/transports/metrics.js +105 -0
- package/package/transports/rest.d.ts +43 -0
- package/package/transports/rest.js +129 -0
- package/package/transports/util.d.ts +8 -0
- package/package/transports/util.js +85 -0
- package/package/transports/websocket.d.ts +80 -0
- package/package/transports/websocket.js +169 -0
- package/package/util/expiring-sorted-set.d.ts +21 -0
- package/package/util/expiring-sorted-set.js +47 -0
- package/package/util/index.d.ts +11 -0
- package/package/util/index.js +35 -0
- package/package/util/logger.d.ts +42 -0
- package/package/util/logger.js +62 -0
- package/package/util/request.d.ts +55 -0
- package/package/util/request.js +2 -0
- package/package/validation/error.d.ts +50 -0
- package/package/validation/error.js +79 -0
- package/package/validation/index.d.ts +5 -0
- package/package/validation/index.js +86 -0
- package/package/validation/input-params.d.ts +15 -0
- package/package/validation/input-params.js +30 -0
- package/package/validation/override-functions.d.ts +3 -0
- package/package/validation/override-functions.js +40 -0
- package/package/validation/preset-tokens.json +23 -0
- package/package/validation/validator.d.ts +47 -0
- package/package/validation/validator.js +303 -0
- package/package.json +1 -1
- package/rate-limiting/background/fixed-frequency.d.ts +10 -0
- package/rate-limiting/background/fixed-frequency.js +37 -0
- package/rate-limiting/index.d.ts +54 -0
- package/rate-limiting/index.js +63 -0
- package/rate-limiting/metrics.d.ts +3 -0
- package/rate-limiting/metrics.js +44 -0
- package/rate-limiting/request/simple-counting.d.ts +20 -0
- package/rate-limiting/request/simple-counting.js +62 -0
- package/test.d.ts +1 -0
- package/test.js +6 -0
- package/transports/batch-warming.d.ts +34 -0
- package/transports/batch-warming.js +101 -0
- package/transports/index.d.ts +87 -0
- package/transports/index.js +87 -0
- package/transports/metrics.d.ts +21 -0
- package/transports/metrics.js +105 -0
- package/transports/rest.d.ts +43 -0
- package/transports/rest.js +129 -0
- package/transports/util.d.ts +8 -0
- package/transports/util.js +85 -0
- package/transports/websocket.d.ts +80 -0
- package/transports/websocket.js +169 -0
- package/util/expiring-sorted-set.d.ts +21 -0
- package/util/expiring-sorted-set.js +47 -0
- package/util/index.d.ts +11 -0
- package/util/index.js +35 -0
- package/util/logger.d.ts +42 -0
- package/util/logger.js +62 -0
- package/util/request.d.ts +55 -0
- package/util/request.js +2 -0
- package/validation/error.d.ts +50 -0
- package/validation/error.js +79 -0
- package/validation/index.d.ts +5 -0
- package/validation/index.js +86 -0
- package/validation/input-params.d.ts +15 -0
- package/validation/input-params.js +30 -0
- package/validation/override-functions.d.ts +3 -0
- package/validation/override-functions.js +40 -0
- package/validation/preset-tokens.json +23 -0
- package/validation/validator.d.ts +47 -0
- package/validation/validator.js +303 -0
- package/.c8rc.json +0 -3
- package/.eslintignore +0 -9
- package/.eslintrc.js +0 -96
- package/.github/README.MD +0 -17
- package/.github/actions/setup/action.yaml +0 -13
- package/.github/workflows/main.yaml +0 -39
- package/.github/workflows/publish.yaml +0 -17
- package/.prettierignore +0 -13
- package/.yarnrc +0 -0
- package/README.md +0 -103
- package/docker-compose.yaml +0 -35
- package/src/adapter.ts +0 -236
- package/src/background-executor.ts +0 -53
- package/src/cache/factory.ts +0 -28
- package/src/cache/index.ts +0 -236
- package/src/cache/local.ts +0 -73
- package/src/cache/metrics.ts +0 -112
- package/src/cache/redis.ts +0 -93
- package/src/config/index.ts +0 -501
- package/src/config/provider-limits.ts +0 -130
- package/src/examples/coingecko/batch-warming.ts +0 -79
- package/src/examples/coingecko/index.ts +0 -9
- package/src/examples/coingecko/rest.ts +0 -77
- package/src/examples/ncfx/config/index.ts +0 -12
- package/src/examples/ncfx/index.ts +0 -9
- package/src/examples/ncfx/websocket.ts +0 -100
- package/src/index.ts +0 -106
- package/src/metrics/constants.ts +0 -23
- package/src/metrics/index.ts +0 -116
- package/src/metrics/util.ts +0 -11
- package/src/rate-limiting/background/fixed-frequency.ts +0 -47
- package/src/rate-limiting/index.ts +0 -100
- package/src/rate-limiting/metrics.ts +0 -18
- package/src/rate-limiting/request/simple-counting.ts +0 -76
- package/src/test.ts +0 -5
- package/src/transports/batch-warming.ts +0 -121
- package/src/transports/index.ts +0 -173
- package/src/transports/metrics.ts +0 -95
- package/src/transports/rest.ts +0 -161
- package/src/transports/util.ts +0 -63
- package/src/transports/websocket.ts +0 -238
- package/src/util/expiring-sorted-set.ts +0 -52
- package/src/util/index.ts +0 -20
- package/src/util/logger.ts +0 -69
- package/src/util/request.ts +0 -115
- package/src/validation/error.ts +0 -116
- package/src/validation/index.ts +0 -101
- package/src/validation/input-params.ts +0 -45
- package/src/validation/override-functions.ts +0 -44
- package/src/validation/preset-tokens.json +0 -23
- package/src/validation/validator.ts +0 -384
- package/test/adapter.test.ts +0 -27
- package/test/background-executor.test.ts +0 -109
- package/test/cache/cache-key.test.ts +0 -96
- package/test/cache/helper.ts +0 -101
- package/test/cache/local.test.ts +0 -54
- package/test/cache/redis.test.ts +0 -89
- package/test/correlation.test.ts +0 -114
- package/test/index.test.ts +0 -37
- package/test/metrics/feed-id.test.ts +0 -33
- package/test/metrics/helper.ts +0 -14
- package/test/metrics/labels.test.ts +0 -36
- package/test/metrics/metrics.test.ts +0 -267
- package/test/metrics/redis-metrics.test.ts +0 -113
- package/test/metrics/warmer-metrics.test.ts +0 -192
- package/test/metrics/ws-metrics.test.ts +0 -225
- package/test/rate-limit-config.test.ts +0 -243
- package/test/transports/batch.test.ts +0 -465
- package/test/transports/rest.test.ts +0 -242
- package/test/transports/websocket.test.ts +0 -183
- package/test/tsconfig.json +0 -5
- package/test/util.ts +0 -76
- package/test/validation.test.ts +0 -169
- package/test.sh +0 -20
- package/tsconfig.json +0 -24
- package/typedoc.json +0 -6
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getWSLimits = exports.getRateLimit = exports.getHTTPLimit = exports.DEFAULT_WS_SUBSCRIPTIONS = exports.DEFAULT_WS_CONNECTIONS = exports.BURST_UNDEFINED_QUOTA_MULTIPLE = exports.DEFAULT_MINUTE_RATE_LIMIT = void 0;
|
|
4
|
+
const util_1 = require("../util");
|
|
5
|
+
exports.DEFAULT_MINUTE_RATE_LIMIT = 60;
|
|
6
|
+
exports.BURST_UNDEFINED_QUOTA_MULTIPLE = 2;
|
|
7
|
+
exports.DEFAULT_WS_CONNECTIONS = 2;
|
|
8
|
+
exports.DEFAULT_WS_SUBSCRIPTIONS = 10;
|
|
9
|
+
const logger = (0, util_1.makeLogger)('ProviderLimits');
|
|
10
|
+
const getHTTPLimit = (provider, limits, tier, timeframe) => {
|
|
11
|
+
const providerLimit = getProviderLimits(provider, limits, tier, 'http');
|
|
12
|
+
return providerLimit?.[timeframe] || 0;
|
|
13
|
+
};
|
|
14
|
+
exports.getHTTPLimit = getHTTPLimit;
|
|
15
|
+
const getRateLimit = (provider, limits, tier) => {
|
|
16
|
+
const providerLimit = getProviderLimits(provider, limits, tier, 'http');
|
|
17
|
+
return calculateRateLimit(providerLimit);
|
|
18
|
+
};
|
|
19
|
+
exports.getRateLimit = getRateLimit;
|
|
20
|
+
const getWSLimits = (provider, limits, tier) => {
|
|
21
|
+
const providerLimit = getProviderLimits(provider, limits, tier, 'ws');
|
|
22
|
+
return calculateWSLimits(providerLimit);
|
|
23
|
+
};
|
|
24
|
+
exports.getWSLimits = getWSLimits;
|
|
25
|
+
const getProviderLimits = (provider, limits, tier, protocol) => {
|
|
26
|
+
const providerConfig = parseLimits(limits);
|
|
27
|
+
if (!providerConfig) {
|
|
28
|
+
throw new Error(`Rate Limit: Provider: "${provider}" doesn't match any provider spec in limits.json`);
|
|
29
|
+
}
|
|
30
|
+
const protocolConfig = providerConfig[protocol];
|
|
31
|
+
if (!protocolConfig) {
|
|
32
|
+
throw new Error(`Rate Limit: "${provider}" doesn't have any configuration for ${protocol} in limits.json`);
|
|
33
|
+
}
|
|
34
|
+
let limitsConfig = protocolConfig[tier.toLowerCase()];
|
|
35
|
+
if (!limitsConfig) {
|
|
36
|
+
logger.debug(`Rate Limit: "${provider} does not have tier ${tier} defined. Falling back to lowest tier"`);
|
|
37
|
+
limitsConfig = Object.values(protocolConfig)?.[0];
|
|
38
|
+
}
|
|
39
|
+
if (!limitsConfig) {
|
|
40
|
+
throw new Error(`Rate Limit: Provider: "${provider}" has no tiers defined for ${protocol} in limits.json`);
|
|
41
|
+
}
|
|
42
|
+
return limitsConfig;
|
|
43
|
+
};
|
|
44
|
+
const parseLimits = (limits) => {
|
|
45
|
+
const _mapObject = (fn) => (o) => Object.fromEntries(Object.entries(o).map(fn));
|
|
46
|
+
const _formatProtocol = _mapObject((entry) => {
|
|
47
|
+
const [tierName, rest] = entry;
|
|
48
|
+
return [tierName.toLowerCase(), { ...rest }];
|
|
49
|
+
});
|
|
50
|
+
const _formatProvider = (ls) => {
|
|
51
|
+
const http = _formatProtocol(ls.http);
|
|
52
|
+
const ws = _formatProtocol(ls?.ws);
|
|
53
|
+
return { http, ws };
|
|
54
|
+
};
|
|
55
|
+
return _formatProvider(limits);
|
|
56
|
+
};
|
|
57
|
+
const calculateWSLimits = (providerLimit) => {
|
|
58
|
+
return {
|
|
59
|
+
connections: providerLimit.connections,
|
|
60
|
+
subscriptions: providerLimit.subscriptions,
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
const calculateRateLimit = (providerLimit) => {
|
|
64
|
+
let quota = providerLimit.rateLimit1m;
|
|
65
|
+
if (!quota && providerLimit?.rateLimit1h) {
|
|
66
|
+
quota = providerLimit?.rateLimit1h / 60;
|
|
67
|
+
}
|
|
68
|
+
else if (!quota && providerLimit?.rateLimit1s) {
|
|
69
|
+
quota = providerLimit?.rateLimit1s * 60;
|
|
70
|
+
}
|
|
71
|
+
return {
|
|
72
|
+
second: providerLimit?.rateLimit1s || (quota / 60) * exports.BURST_UNDEFINED_QUOTA_MULTIPLE,
|
|
73
|
+
minute: quota,
|
|
74
|
+
};
|
|
75
|
+
};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.batchEndpoint = void 0;
|
|
4
|
+
const batch_warming_1 = require("../../transports/batch-warming");
|
|
5
|
+
const DEFAULT_URL = 'https://pro-api.coingecko.com/api/v3';
|
|
6
|
+
const inputParameters = {
|
|
7
|
+
coinid: {
|
|
8
|
+
description: 'The CoinGecko id or array of ids of the coin(s) to query (Note: because of current limitations to use a dummy base will need to be supplied)',
|
|
9
|
+
required: false,
|
|
10
|
+
},
|
|
11
|
+
base: {
|
|
12
|
+
aliases: ['from', 'coin'],
|
|
13
|
+
description: 'The symbol or array of symbols of the currency to query',
|
|
14
|
+
required: true,
|
|
15
|
+
},
|
|
16
|
+
quote: {
|
|
17
|
+
aliases: ['to', 'market'],
|
|
18
|
+
description: 'The symbol of the currency to convert to',
|
|
19
|
+
required: true,
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
const batchEndpointTransport = new batch_warming_1.BatchWarmingTransport({
|
|
23
|
+
prepareRequest: (params, context) => {
|
|
24
|
+
return {
|
|
25
|
+
baseURL: DEFAULT_URL,
|
|
26
|
+
url: '/simple/price',
|
|
27
|
+
method: 'GET',
|
|
28
|
+
params: {
|
|
29
|
+
ids: [...new Set(params.map((p) => p.base))].join(','),
|
|
30
|
+
vs_currencies: [...new Set(params.map((p) => p.quote))].join(','),
|
|
31
|
+
x_cg_pro_api_key: context.adapterConfig.API_KEY,
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
},
|
|
35
|
+
parseResponse: (res) => {
|
|
36
|
+
const entries = [];
|
|
37
|
+
for (const [base, entry] of Object.entries(res.data)) {
|
|
38
|
+
for (const [quote, price] of Object.entries(entry)) {
|
|
39
|
+
entries.push({
|
|
40
|
+
params: { base, quote },
|
|
41
|
+
value: price,
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return entries;
|
|
46
|
+
},
|
|
47
|
+
});
|
|
48
|
+
exports.batchEndpoint = {
|
|
49
|
+
name: 'batch',
|
|
50
|
+
transport: batchEndpointTransport,
|
|
51
|
+
inputParameters,
|
|
52
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.adapter = void 0;
|
|
4
|
+
const batch_warming_1 = require("./batch-warming");
|
|
5
|
+
const rest_1 = require("./rest");
|
|
6
|
+
exports.adapter = {
|
|
7
|
+
name: 'coingecko',
|
|
8
|
+
defaultEndpoint: 'batch',
|
|
9
|
+
endpoints: [rest_1.restEndpoint, batch_warming_1.batchEndpoint],
|
|
10
|
+
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.restEndpoint = void 0;
|
|
4
|
+
const transports_1 = require("../../transports");
|
|
5
|
+
const DEFAULT_URL = 'https://api.coingecko.com/api/v3';
|
|
6
|
+
const inputParameters = {
|
|
7
|
+
coinid: {
|
|
8
|
+
description: 'The CoinGecko id or array of ids of the coin(s) to query (Note: because of current limitations to use a dummy base will need to be supplied)',
|
|
9
|
+
required: false,
|
|
10
|
+
},
|
|
11
|
+
base: {
|
|
12
|
+
aliases: ['from', 'coin'],
|
|
13
|
+
description: 'The symbol or array of symbols of the currency to query',
|
|
14
|
+
required: true,
|
|
15
|
+
},
|
|
16
|
+
quote: {
|
|
17
|
+
aliases: ['to', 'market'],
|
|
18
|
+
description: 'The symbol of the currency to convert to',
|
|
19
|
+
required: true,
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
const restEndpointTransport = new transports_1.RestTransport({
|
|
23
|
+
prepareRequest: (req) => {
|
|
24
|
+
return {
|
|
25
|
+
baseURL: DEFAULT_URL,
|
|
26
|
+
url: '/simple/price',
|
|
27
|
+
method: 'GET',
|
|
28
|
+
params: {
|
|
29
|
+
ids: req.requestContext.data.base,
|
|
30
|
+
vs_currencies: req.requestContext.data.quote,
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
},
|
|
34
|
+
parseResponse: (req, res) => {
|
|
35
|
+
return {
|
|
36
|
+
data: res.data,
|
|
37
|
+
statusCode: 200,
|
|
38
|
+
result: res.data[req.requestContext.data.base]?.[req.requestContext.data.quote],
|
|
39
|
+
};
|
|
40
|
+
},
|
|
41
|
+
options: {
|
|
42
|
+
coalescing: true,
|
|
43
|
+
},
|
|
44
|
+
});
|
|
45
|
+
exports.restEndpoint = {
|
|
46
|
+
name: 'rest',
|
|
47
|
+
aliases: ['qwe'],
|
|
48
|
+
transport: restEndpointTransport,
|
|
49
|
+
inputParameters,
|
|
50
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare const customSettings: {
|
|
2
|
+
readonly USERNAME: {
|
|
3
|
+
readonly description: "Username for the NCFX API";
|
|
4
|
+
readonly type: "string";
|
|
5
|
+
readonly required: true;
|
|
6
|
+
};
|
|
7
|
+
readonly PASSWORD: {
|
|
8
|
+
readonly description: "Password for the NCFX API";
|
|
9
|
+
readonly type: "string";
|
|
10
|
+
readonly required: true;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.customSettings = void 0;
|
|
4
|
+
exports.customSettings = {
|
|
5
|
+
USERNAME: {
|
|
6
|
+
description: 'Username for the NCFX API',
|
|
7
|
+
type: 'string',
|
|
8
|
+
required: true,
|
|
9
|
+
},
|
|
10
|
+
PASSWORD: {
|
|
11
|
+
description: 'Password for the NCFX API',
|
|
12
|
+
type: 'string',
|
|
13
|
+
required: true,
|
|
14
|
+
},
|
|
15
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.adapter = void 0;
|
|
4
|
+
const config_1 = require("./config");
|
|
5
|
+
const websocket_1 = require("./websocket");
|
|
6
|
+
exports.adapter = {
|
|
7
|
+
name: 'ncfx',
|
|
8
|
+
endpoints: [websocket_1.webSocketEndpoint],
|
|
9
|
+
customSettings: config_1.customSettings,
|
|
10
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { AdapterEndpoint } from '../../adapter';
|
|
2
|
+
import { WebSocketTransport } from '../../transports/websocket';
|
|
3
|
+
import { InputParameters } from '../../validation';
|
|
4
|
+
interface AdapterRequestParams {
|
|
5
|
+
base: string;
|
|
6
|
+
quote: string;
|
|
7
|
+
}
|
|
8
|
+
export declare const inputParameters: InputParameters;
|
|
9
|
+
interface ProviderMessage {
|
|
10
|
+
timestamp: string;
|
|
11
|
+
currencyPair: string;
|
|
12
|
+
bid: number;
|
|
13
|
+
offer: number;
|
|
14
|
+
mid: number;
|
|
15
|
+
changes: [
|
|
16
|
+
{
|
|
17
|
+
period: string;
|
|
18
|
+
change: number;
|
|
19
|
+
percentage: number;
|
|
20
|
+
}
|
|
21
|
+
];
|
|
22
|
+
}
|
|
23
|
+
export declare const websocketTransport: WebSocketTransport<AdapterRequestParams, ProviderMessage[], {
|
|
24
|
+
readonly USERNAME: {
|
|
25
|
+
readonly description: "Username for the NCFX API";
|
|
26
|
+
readonly type: "string";
|
|
27
|
+
readonly required: true;
|
|
28
|
+
};
|
|
29
|
+
readonly PASSWORD: {
|
|
30
|
+
readonly description: "Password for the NCFX API";
|
|
31
|
+
readonly type: "string";
|
|
32
|
+
readonly required: true;
|
|
33
|
+
};
|
|
34
|
+
}>;
|
|
35
|
+
export declare const webSocketEndpoint: AdapterEndpoint;
|
|
36
|
+
export {};
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.webSocketEndpoint = exports.websocketTransport = exports.inputParameters = void 0;
|
|
4
|
+
const websocket_1 = require("../../transports/websocket");
|
|
5
|
+
const util_1 = require("../../util");
|
|
6
|
+
exports.inputParameters = {
|
|
7
|
+
base: {
|
|
8
|
+
aliases: ['from', 'coin'],
|
|
9
|
+
description: 'The symbol of the currency to query',
|
|
10
|
+
required: true,
|
|
11
|
+
},
|
|
12
|
+
quote: {
|
|
13
|
+
aliases: ['to', 'market'],
|
|
14
|
+
description: 'The symbol of the currency to convert to',
|
|
15
|
+
required: true,
|
|
16
|
+
},
|
|
17
|
+
};
|
|
18
|
+
const logger = (0, util_1.makeLogger)('NcfxWebSocketTransport');
|
|
19
|
+
exports.websocketTransport = new websocket_1.WebSocketTransport({
|
|
20
|
+
url: 'wss://feed.newchangefx.com/cryptodata',
|
|
21
|
+
handlers: {
|
|
22
|
+
open(connection, context) {
|
|
23
|
+
return new Promise((resolve, reject) => {
|
|
24
|
+
// Set up listener
|
|
25
|
+
connection.on('message', (data) => {
|
|
26
|
+
const parsed = JSON.parse(data.toString());
|
|
27
|
+
if (parsed.Message?.startsWith('Logged in as user')) {
|
|
28
|
+
logger.info('Got logged in response, connection is ready');
|
|
29
|
+
resolve();
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
reject(new Error('Unexpected message after WS connection open'));
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
// Send login payload
|
|
36
|
+
connection.send(JSON.stringify({
|
|
37
|
+
request: 'login',
|
|
38
|
+
username: context.adapterConfig.USERNAME,
|
|
39
|
+
password: context.adapterConfig.PASSWORD,
|
|
40
|
+
}));
|
|
41
|
+
});
|
|
42
|
+
},
|
|
43
|
+
message(message) {
|
|
44
|
+
if (!Array.isArray(message)) {
|
|
45
|
+
logger.debug('WS message is not array, skipping');
|
|
46
|
+
return [];
|
|
47
|
+
}
|
|
48
|
+
return message.map((m) => {
|
|
49
|
+
const [base, quote] = m.currencyPair.split('/');
|
|
50
|
+
return {
|
|
51
|
+
params: { base, quote },
|
|
52
|
+
value: m.offer,
|
|
53
|
+
};
|
|
54
|
+
});
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
builders: {
|
|
58
|
+
subscribeMessage: (params) => ({
|
|
59
|
+
request: 'subscribe',
|
|
60
|
+
ccy: `${params.base}/${params.quote}`,
|
|
61
|
+
}),
|
|
62
|
+
unsubscribeMessage: (params) => ({
|
|
63
|
+
request: 'unsubscribe',
|
|
64
|
+
ccy: `${params.base}/${params.quote}`,
|
|
65
|
+
}),
|
|
66
|
+
},
|
|
67
|
+
});
|
|
68
|
+
exports.webSocketEndpoint = {
|
|
69
|
+
name: 'websocket',
|
|
70
|
+
transport: exports.websocketTransport,
|
|
71
|
+
inputParameters: exports.inputParameters,
|
|
72
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Server } from 'http';
|
|
2
|
+
import { Adapter } from './adapter';
|
|
3
|
+
import { AdapterDependencies } from './transports';
|
|
4
|
+
/**
|
|
5
|
+
* Main function for the framework.
|
|
6
|
+
* Initializes config and dependencies, uses those to initialize Transports, and starts listening for requests.
|
|
7
|
+
*
|
|
8
|
+
* @param adapter - an object describing an External Adapter
|
|
9
|
+
* @param dependencies - an optional object with adapter dependencies to inject
|
|
10
|
+
* @returns a Promise that resolves to the http.Server listening for connections
|
|
11
|
+
*/
|
|
12
|
+
export declare const expose: (adapter: Adapter, dependencies?: Partial<AdapterDependencies> | undefined) => Promise<Server | undefined>;
|
package/package/index.js
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.expose = void 0;
|
|
7
|
+
const fastify_1 = __importDefault(require("fastify"));
|
|
8
|
+
const path_1 = require("path");
|
|
9
|
+
const adapter_1 = require("./adapter");
|
|
10
|
+
const background_executor_1 = require("./background-executor");
|
|
11
|
+
const cache_1 = require("./cache");
|
|
12
|
+
const config_1 = require("./config");
|
|
13
|
+
const metrics_1 = require("./metrics");
|
|
14
|
+
const transports_1 = require("./transports");
|
|
15
|
+
const util_1 = require("./util");
|
|
16
|
+
const validation_1 = require("./validation");
|
|
17
|
+
const logger = (0, util_1.makeLogger)('Main');
|
|
18
|
+
const VERSION = process.env['npm_package_version'];
|
|
19
|
+
/**
|
|
20
|
+
* Main function for the framework.
|
|
21
|
+
* Initializes config and dependencies, uses those to initialize Transports, and starts listening for requests.
|
|
22
|
+
*
|
|
23
|
+
* @param adapter - an object describing an External Adapter
|
|
24
|
+
* @param dependencies - an optional object with adapter dependencies to inject
|
|
25
|
+
* @returns a Promise that resolves to the http.Server listening for connections
|
|
26
|
+
*/
|
|
27
|
+
const expose = async (adapter, dependencies) => {
|
|
28
|
+
const config = (0, config_1.buildAdapterConfig)({
|
|
29
|
+
overrides: adapter.envDefaultOverrides,
|
|
30
|
+
customSettings: adapter.customSettings,
|
|
31
|
+
});
|
|
32
|
+
// Initialize adapter (create dependencies, inject them, build endpoint map, etc.)
|
|
33
|
+
const initializedAdapter = await (0, adapter_1.initializeAdapter)(adapter, config, dependencies);
|
|
34
|
+
let server = undefined;
|
|
35
|
+
if (config.METRICS_ENABLED && config.EXPERIMENTAL_METRICS_ENABLED) {
|
|
36
|
+
(0, metrics_1.setupMetricsServer)(adapter.name, config);
|
|
37
|
+
}
|
|
38
|
+
if (config.EA_MODE === 'reader' || config.EA_MODE === 'reader-writer') {
|
|
39
|
+
// Main REST API server to handle incoming requests
|
|
40
|
+
const app = await buildRestApi(config, initializedAdapter);
|
|
41
|
+
// Start listening for incoming requests
|
|
42
|
+
try {
|
|
43
|
+
await app.listen(config.EA_PORT, config.EA_HOST);
|
|
44
|
+
}
|
|
45
|
+
catch (err) {
|
|
46
|
+
logger.fatal(`There was an error when starting the EA server: ${err}`);
|
|
47
|
+
process.exit();
|
|
48
|
+
}
|
|
49
|
+
logger.info(`Listening on port ${app.server.address().port}`);
|
|
50
|
+
server = app.server;
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
logger.info('REST API is disabled; this instance will not process incoming requests.');
|
|
54
|
+
}
|
|
55
|
+
if (config.EA_MODE === 'writer' || config.EA_MODE === 'reader-writer') {
|
|
56
|
+
// Start background loop that will take care of calling any async Transports
|
|
57
|
+
logger.info('Starting background execution loop');
|
|
58
|
+
(0, background_executor_1.callBackgroundExecutes)(initializedAdapter, server);
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
logger.info('Background executor is disabled; this instance will not perform async background executes.');
|
|
62
|
+
}
|
|
63
|
+
return server;
|
|
64
|
+
};
|
|
65
|
+
exports.expose = expose;
|
|
66
|
+
async function buildRestApi(config, initializedAdapter) {
|
|
67
|
+
const app = (0, fastify_1.default)();
|
|
68
|
+
// Add healthcheck endpoint before middlewares to bypass them
|
|
69
|
+
app.get((0, path_1.join)(config.BASE_URL, 'health'), (req, res) => {
|
|
70
|
+
res.status(200).send({ message: 'OK', version: VERSION });
|
|
71
|
+
});
|
|
72
|
+
// Use global error handling
|
|
73
|
+
app.setErrorHandler(validation_1.errorCatchingMiddleware);
|
|
74
|
+
const transportHandler = await (0, transports_1.buildTransportHandler)(initializedAdapter);
|
|
75
|
+
app.register(async (router) => {
|
|
76
|
+
// Set up "middlewares" (hooks in fastify)
|
|
77
|
+
router.addHook('preHandler', (0, validation_1.validatorMiddleware)(initializedAdapter));
|
|
78
|
+
router.addHook('preHandler', (0, cache_1.buildCacheMiddleware)(initializedAdapter));
|
|
79
|
+
if (config['CORRELATION_ID_ENABLED']) {
|
|
80
|
+
router.addHook('onRequest', util_1.loggingContextMiddleware);
|
|
81
|
+
}
|
|
82
|
+
router.route({
|
|
83
|
+
url: config.BASE_URL,
|
|
84
|
+
method: 'POST',
|
|
85
|
+
handler: transportHandler,
|
|
86
|
+
}); // Pass config maybe? cleaner that multiple instances / dependencies
|
|
87
|
+
if (config.METRICS_ENABLED && config.EXPERIMENTAL_METRICS_ENABLED) {
|
|
88
|
+
router.addHook('onResponse', metrics_1.buildMetricsMiddleware);
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
return app;
|
|
92
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export declare enum HttpRequestType {
|
|
2
|
+
CACHE_HIT = "cacheHit",
|
|
3
|
+
DATA_PROVIDER_HIT = "dataProviderHit",
|
|
4
|
+
ADAPTER_ERROR = "adapterError",
|
|
5
|
+
INPUT_ERROR = "inputError",
|
|
6
|
+
RATE_LIMIT_ERROR = "rateLimitError",
|
|
7
|
+
DP_ERROR = "dataProviderError",
|
|
8
|
+
TIMEOUT_ERROR = "timeoutError",
|
|
9
|
+
CONNECTION_ERROR = "connectionError",
|
|
10
|
+
CUSTOM_ERROR = "customError"
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Maxiumum number of characters that a feedId can contain.
|
|
14
|
+
*/
|
|
15
|
+
export declare const MAX_FEED_ID_LENGTH = 300;
|
|
16
|
+
export declare const requestDurationBuckets: number[];
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.requestDurationBuckets = exports.MAX_FEED_ID_LENGTH = exports.HttpRequestType = void 0;
|
|
4
|
+
var HttpRequestType;
|
|
5
|
+
(function (HttpRequestType) {
|
|
6
|
+
HttpRequestType["CACHE_HIT"] = "cacheHit";
|
|
7
|
+
HttpRequestType["DATA_PROVIDER_HIT"] = "dataProviderHit";
|
|
8
|
+
HttpRequestType["ADAPTER_ERROR"] = "adapterError";
|
|
9
|
+
HttpRequestType["INPUT_ERROR"] = "inputError";
|
|
10
|
+
HttpRequestType["RATE_LIMIT_ERROR"] = "rateLimitError";
|
|
11
|
+
// BURST_LIMIT_ERROR = 'burstLimitError',
|
|
12
|
+
// BACKOFF_ERROR = 'backoffError',
|
|
13
|
+
HttpRequestType["DP_ERROR"] = "dataProviderError";
|
|
14
|
+
HttpRequestType["TIMEOUT_ERROR"] = "timeoutError";
|
|
15
|
+
HttpRequestType["CONNECTION_ERROR"] = "connectionError";
|
|
16
|
+
// RES_EMPTY_ERROR = 'responseEmptyError',
|
|
17
|
+
// RES_INVALID_ERROR = 'responseInvalidError',
|
|
18
|
+
HttpRequestType["CUSTOM_ERROR"] = "customError";
|
|
19
|
+
})(HttpRequestType = exports.HttpRequestType || (exports.HttpRequestType = {}));
|
|
20
|
+
/**
|
|
21
|
+
* Maxiumum number of characters that a feedId can contain.
|
|
22
|
+
*/
|
|
23
|
+
exports.MAX_FEED_ID_LENGTH = 300;
|
|
24
|
+
// We should tune these as we collect data, this is the default bucket distribution that prom comes with
|
|
25
|
+
exports.requestDurationBuckets = [0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5, 5, 10];
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import * as client from 'prom-client';
|
|
2
|
+
import { AdapterRequest } from '../util';
|
|
3
|
+
import { AdapterConfig } from '../config';
|
|
4
|
+
import { FastifyReply, HookHandlerDoneFunction } from 'fastify';
|
|
5
|
+
export declare function setupMetricsServer(name: string, config: AdapterConfig): void;
|
|
6
|
+
export declare const setupMetrics: (name: string, config: AdapterConfig) => void;
|
|
7
|
+
/**
|
|
8
|
+
* Builds metrics middleware that records end to end EA response times
|
|
9
|
+
* and count of requests
|
|
10
|
+
*
|
|
11
|
+
* @returns the cache middleware function
|
|
12
|
+
*/
|
|
13
|
+
export declare const buildMetricsMiddleware: (req: AdapterRequest, res: FastifyReply, done: HookHandlerDoneFunction) => void;
|
|
14
|
+
export declare const httpRequestsTotal: client.Counter<"type" | "method" | "feed_id" | "status_code" | "provider_status_code" | "retry" | "is_cache_warming">;
|
|
15
|
+
export declare const httpRequestDurationSeconds: client.Histogram<string>;
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.httpRequestDurationSeconds = exports.httpRequestsTotal = exports.buildMetricsMiddleware = exports.setupMetrics = exports.setupMetricsServer = void 0;
|
|
30
|
+
const client = __importStar(require("prom-client"));
|
|
31
|
+
const constants_1 = require("./constants");
|
|
32
|
+
const util_1 = require("../util");
|
|
33
|
+
const fastify_1 = __importDefault(require("fastify"));
|
|
34
|
+
const path_1 = require("path");
|
|
35
|
+
const error_1 = require("../validation/error");
|
|
36
|
+
const logger = (0, util_1.makeLogger)('Metrics');
|
|
37
|
+
function setupMetricsServer(name, config) {
|
|
38
|
+
const metricsApp = (0, fastify_1.default)({
|
|
39
|
+
logger: false,
|
|
40
|
+
});
|
|
41
|
+
const metricsPort = config.METRICS_PORT;
|
|
42
|
+
const endpoint = config.METRICS_USE_BASE_URL ? (0, path_1.join)(config.BASE_URL, 'metrics') : '/metrics';
|
|
43
|
+
const eaHost = config.EA_HOST;
|
|
44
|
+
(0, exports.setupMetrics)(name, config);
|
|
45
|
+
metricsApp.get(endpoint, async (_, res) => {
|
|
46
|
+
res.type('txt');
|
|
47
|
+
res.send(await client.register.metrics());
|
|
48
|
+
});
|
|
49
|
+
metricsApp.listen(metricsPort, eaHost, () => logger.info(`Monitoring listening on port ${metricsPort}!`));
|
|
50
|
+
}
|
|
51
|
+
exports.setupMetricsServer = setupMetricsServer;
|
|
52
|
+
const setupMetrics = (name, config) => {
|
|
53
|
+
client.collectDefaultMetrics();
|
|
54
|
+
client.register.setDefaultLabels({
|
|
55
|
+
app_name: config.METRICS_NAME || name || 'N/A',
|
|
56
|
+
app_version: config['npm_package_version'],
|
|
57
|
+
});
|
|
58
|
+
};
|
|
59
|
+
exports.setupMetrics = setupMetrics;
|
|
60
|
+
/**
|
|
61
|
+
* Builds metrics middleware that records end to end EA response times
|
|
62
|
+
* and count of requests
|
|
63
|
+
*
|
|
64
|
+
* @returns the cache middleware function
|
|
65
|
+
*/
|
|
66
|
+
const buildMetricsMiddleware = (req, res, done) => {
|
|
67
|
+
const feedId = req.requestContext.meta?.metrics?.feedId || 'N/A';
|
|
68
|
+
const labels = buildHttpRequestMetricsLabel(feedId, req.requestContext.meta?.error, req.requestContext.meta?.metrics?.cacheHit);
|
|
69
|
+
// Record number of requests sent to EA
|
|
70
|
+
exports.httpRequestsTotal.labels(labels).inc();
|
|
71
|
+
// Record response time of request through entire EA
|
|
72
|
+
exports.httpRequestDurationSeconds.observe(res.getResponseTime());
|
|
73
|
+
logger.debug(`Response time for ${feedId}: ${res.getResponseTime()}ms`);
|
|
74
|
+
done();
|
|
75
|
+
};
|
|
76
|
+
exports.buildMetricsMiddleware = buildMetricsMiddleware;
|
|
77
|
+
const buildHttpRequestMetricsLabel = (feedId, error, cacheHit) => {
|
|
78
|
+
const labels = {};
|
|
79
|
+
labels.method = 'POST';
|
|
80
|
+
labels.feed_id = feedId;
|
|
81
|
+
if (error instanceof error_1.AdapterError) {
|
|
82
|
+
// If error present and an instace of AdapterError, build label from error info
|
|
83
|
+
labels.type = error?.metricsLabel || constants_1.HttpRequestType.ADAPTER_ERROR;
|
|
84
|
+
labels.status_code = error?.statusCode;
|
|
85
|
+
labels.provider_status_code = error?.providerStatusCode;
|
|
86
|
+
}
|
|
87
|
+
else if (error instanceof Error) {
|
|
88
|
+
// If error present and not instance of generic Error, unexpected failure occurred
|
|
89
|
+
// TODO: Build label with 500 error and withold dp status? Status sent as 200 in error handler
|
|
90
|
+
labels.type = constants_1.HttpRequestType.ADAPTER_ERROR;
|
|
91
|
+
labels.status_code = 500;
|
|
92
|
+
}
|
|
93
|
+
else {
|
|
94
|
+
// If no error present, request went as expected
|
|
95
|
+
labels.status_code = 200;
|
|
96
|
+
if (cacheHit) {
|
|
97
|
+
labels.type = constants_1.HttpRequestType.CACHE_HIT;
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
labels.type = constants_1.HttpRequestType.DATA_PROVIDER_HIT;
|
|
101
|
+
labels.provider_status_code = 200;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
return labels;
|
|
105
|
+
};
|
|
106
|
+
exports.httpRequestsTotal = new client.Counter({
|
|
107
|
+
name: 'http_requests_total',
|
|
108
|
+
help: 'The number of http requests this external adapter has serviced for its entire uptime',
|
|
109
|
+
labelNames: [
|
|
110
|
+
'method',
|
|
111
|
+
'status_code',
|
|
112
|
+
'retry',
|
|
113
|
+
'type',
|
|
114
|
+
'is_cache_warming',
|
|
115
|
+
'feed_id',
|
|
116
|
+
'provider_status_code',
|
|
117
|
+
],
|
|
118
|
+
});
|
|
119
|
+
exports.httpRequestDurationSeconds = new client.Histogram({
|
|
120
|
+
name: 'http_request_duration_seconds',
|
|
121
|
+
help: 'A histogram bucket of the distribution of http request durations',
|
|
122
|
+
buckets: constants_1.requestDurationBuckets,
|
|
123
|
+
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getMetricsMeta = void 0;
|
|
4
|
+
const cache_1 = require("../cache");
|
|
5
|
+
const getMetricsMeta = (endpoint, data) => {
|
|
6
|
+
const feedId = (0, cache_1.calculateFeedId)(endpoint, data);
|
|
7
|
+
return { feedId };
|
|
8
|
+
};
|
|
9
|
+
exports.getMetricsMeta = getMetricsMeta;
|