@chainlink/external-adapter-framework 0.0.12 → 0.0.14
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 +107 -0
- package/adapter.js +115 -0
- package/{dist/src/package/background-executor.d.ts → background-executor.d.ts} +0 -0
- package/{dist/src/background-executor.js → background-executor.js} +0 -0
- package/{dist/src/cache → cache}/factory.d.ts +0 -0
- package/{dist/src/cache → cache}/factory.js +0 -0
- package/{dist/src/cache → cache}/index.d.ts +8 -8
- package/{dist/src/cache → cache}/index.js +0 -0
- package/{dist/src/cache → cache}/local.d.ts +0 -0
- package/{dist/src/cache → cache}/local.js +0 -0
- package/{dist/src/cache → cache}/metrics.d.ts +0 -0
- package/{dist/src/cache → cache}/metrics.js +0 -0
- package/{dist/src/cache → cache}/redis.d.ts +0 -0
- package/{dist/src/cache → cache}/redis.js +0 -0
- package/{dist/src/chainlink-external-adapter-framework-0.0.6.tgz → chainlink-external-adapter-framework-0.0.6.tgz} +0 -0
- package/{dist/src/config → config}/index.d.ts +0 -5
- package/{dist/src/config → config}/index.js +5 -5
- package/{dist/src/config → config}/provider-limits.d.ts +0 -0
- package/{dist/src/config → config}/provider-limits.js +5 -1
- package/{dist/src/examples → examples}/bank-frick/accounts.d.ts +1 -1
- package/{dist/src/examples → examples}/bank-frick/accounts.js +2 -3
- package/{dist/src/examples → examples}/bank-frick/config/index.d.ts +0 -0
- package/{dist/src/examples → examples}/bank-frick/config/index.js +0 -0
- package/{dist/src/package/examples/coingecko → examples/bank-frick}/index.d.ts +0 -0
- package/{dist/src/examples → examples}/bank-frick/index.js +2 -3
- package/{dist/src/examples → examples}/bank-frick/util.d.ts +0 -0
- package/{dist/src/examples → examples}/bank-frick/util.js +0 -0
- package/{dist/src/package/examples → examples}/coingecko/batch-warming.d.ts +0 -0
- package/{dist/src/package/examples → examples}/coingecko/batch-warming.js +0 -0
- package/{dist/src/package/examples/ncfx → examples/coingecko}/index.d.ts +0 -0
- package/{dist/src/package/examples → examples}/coingecko/index.js +0 -0
- package/{dist/src/package/examples → examples}/coingecko/rest.d.ts +0 -0
- package/{dist/src/package/examples → examples}/coingecko/rest.js +0 -0
- package/{dist/src/examples → examples}/ncfx/config/index.d.ts +0 -0
- package/{dist/src/examples → examples}/ncfx/config/index.js +0 -0
- package/examples/ncfx/index.d.ts +2 -0
- package/{dist/src/package/examples → examples}/ncfx/index.js +0 -0
- package/{dist/src/package/examples → examples}/ncfx/websocket.d.ts +0 -0
- package/{dist/src/package/examples → examples}/ncfx/websocket.js +0 -0
- package/{dist/src/index.d.ts → index.d.ts} +0 -0
- package/{dist/src/index.js → index.js} +18 -13
- package/{dist/src/metrics → metrics}/constants.d.ts +0 -0
- package/{dist/src/metrics → metrics}/constants.js +0 -0
- package/{dist/src/metrics → metrics}/index.d.ts +0 -0
- package/{dist/src/metrics → metrics}/index.js +0 -0
- package/metrics/util.d.ts +7 -0
- package/{dist/src/metrics → metrics}/util.js +0 -0
- package/{dist/src/package → package}/adapter.d.ts +0 -0
- package/{dist/src/package → package}/adapter.js +0 -0
- package/{dist/src → package}/background-executor.d.ts +2 -2
- package/{dist/src/package → package}/background-executor.js +0 -0
- package/{dist/src/package → package}/cache/factory.d.ts +0 -0
- package/{dist/src/package → package}/cache/factory.js +0 -0
- package/{dist/src/package → package}/cache/index.d.ts +0 -0
- package/{dist/src/package → package}/cache/index.js +0 -0
- package/{dist/src/package → package}/cache/local.d.ts +0 -0
- package/{dist/src/package → package}/cache/local.js +0 -0
- package/{dist/src/package → package}/cache/metrics.d.ts +0 -0
- package/{dist/src/package → package}/cache/metrics.js +0 -0
- package/{dist/src/package → package}/cache/redis.d.ts +0 -0
- package/{dist/src/package → package}/cache/redis.js +0 -0
- package/{dist/src/package → package}/config/index.d.ts +0 -0
- package/{dist/src/package → package}/config/index.js +0 -0
- package/{dist/src/package → package}/config/provider-limits.d.ts +0 -0
- package/{dist/src/package → package}/config/provider-limits.js +0 -0
- package/package/examples/coingecko/batch-warming.d.ts +2 -0
- package/{dist/src → package}/examples/coingecko/batch-warming.js +2 -3
- package/package/examples/coingecko/index.d.ts +2 -0
- package/{dist/src → package}/examples/coingecko/index.js +2 -3
- package/package/examples/coingecko/rest.d.ts +2 -0
- package/{dist/src → package}/examples/coingecko/rest.js +2 -3
- package/{dist/src/package → package}/examples/ncfx/config/index.d.ts +0 -0
- package/{dist/src/package → package}/examples/ncfx/config/index.js +0 -0
- package/package/examples/ncfx/index.d.ts +2 -0
- package/{dist/src → package}/examples/ncfx/index.js +2 -3
- package/{dist/src → package}/examples/ncfx/websocket.d.ts +1 -12
- package/{dist/src → package}/examples/ncfx/websocket.js +2 -3
- package/{dist/src/package → package}/index.d.ts +0 -0
- package/{dist/src/package → package}/index.js +0 -0
- package/{dist/src/package → package}/metrics/constants.d.ts +0 -0
- package/{dist/src/package → package}/metrics/constants.js +0 -0
- package/{dist/src/package → package}/metrics/index.d.ts +0 -0
- package/{dist/src/package → package}/metrics/index.js +0 -0
- package/{dist/src/package → package}/metrics/util.d.ts +0 -0
- package/{dist/src/package → package}/metrics/util.js +0 -0
- package/{dist/src → package}/package.json +0 -0
- package/{dist/src/package → package}/rate-limiting/background/fixed-frequency.d.ts +0 -0
- package/{dist/src/package → package}/rate-limiting/background/fixed-frequency.js +0 -0
- package/{dist/src/package → package}/rate-limiting/index.d.ts +0 -0
- package/{dist/src/package → package}/rate-limiting/index.js +0 -0
- package/{dist/src/package → package}/rate-limiting/metrics.d.ts +0 -0
- package/{dist/src/package → package}/rate-limiting/metrics.js +0 -0
- package/{dist/src/package → package}/rate-limiting/request/simple-counting.d.ts +0 -0
- package/{dist/src/package → package}/rate-limiting/request/simple-counting.js +0 -0
- package/{dist/src/package → package}/test.d.ts +0 -0
- package/{dist/src/package → package}/test.js +0 -0
- package/{dist/src/package → package}/transports/batch-warming.d.ts +0 -0
- package/{dist/src/package → package}/transports/batch-warming.js +0 -0
- package/{dist/src/package → package}/transports/index.d.ts +0 -0
- package/{dist/src/package → package}/transports/index.js +0 -0
- package/{dist/src/package → package}/transports/metrics.d.ts +0 -0
- package/{dist/src/package → package}/transports/metrics.js +0 -0
- package/{dist/src/package → package}/transports/rest.d.ts +0 -0
- package/{dist/src/package → package}/transports/rest.js +0 -0
- package/{dist/src/package → package}/transports/util.d.ts +0 -0
- package/{dist/src/package → package}/transports/util.js +0 -0
- package/{dist/src/package → package}/transports/websocket.d.ts +0 -0
- package/{dist/src/package → package}/transports/websocket.js +0 -0
- package/{dist/src/package → package}/util/expiring-sorted-set.d.ts +0 -0
- package/{dist/src/package → package}/util/expiring-sorted-set.js +0 -0
- package/{dist/src/package → package}/util/index.d.ts +0 -0
- package/{dist/src/package → package}/util/index.js +0 -0
- package/{dist/src/package → package}/util/logger.d.ts +0 -0
- package/{dist/src/package → package}/util/logger.js +0 -0
- package/{dist/src/package → package}/util/request.d.ts +0 -0
- package/{dist/src/package → package}/util/request.js +0 -0
- package/{dist/src/package → package}/validation/error.d.ts +0 -0
- package/{dist/src/package → package}/validation/error.js +0 -0
- package/{dist/src/package → package}/validation/index.d.ts +0 -0
- package/{dist/src/package → package}/validation/index.js +0 -0
- package/{dist/src/package → package}/validation/input-params.d.ts +0 -0
- package/{dist/src/package → package}/validation/input-params.js +0 -0
- package/{dist/src/package → package}/validation/override-functions.d.ts +0 -0
- package/{dist/src/package → package}/validation/override-functions.js +0 -0
- package/{dist/src/package → package}/validation/preset-tokens.json +0 -0
- package/{dist/src/package → package}/validation/validator.d.ts +0 -0
- package/{dist/src/package → package}/validation/validator.js +0 -0
- package/package.json +1 -1
- package/{dist/src/rate-limiting → rate-limiting}/background/fixed-frequency.d.ts +1 -2
- package/{dist/src/rate-limiting → rate-limiting}/background/fixed-frequency.js +0 -0
- package/{dist/src/rate-limiting → rate-limiting}/index.d.ts +1 -2
- package/{dist/src/rate-limiting → rate-limiting}/index.js +0 -0
- package/{dist/src/rate-limiting → rate-limiting}/metrics.d.ts +0 -0
- package/{dist/src/rate-limiting → rate-limiting}/metrics.js +0 -0
- package/{dist/src/rate-limiting → rate-limiting}/request/simple-counting.d.ts +1 -2
- package/{dist/src/rate-limiting → rate-limiting}/request/simple-counting.js +0 -0
- package/{dist/src/test.d.ts → test.d.ts} +0 -0
- package/{dist/src/test.js → test.js} +0 -0
- package/{dist/src/transports → transports}/batch-warming.d.ts +0 -0
- package/{dist/src/transports → transports}/batch-warming.js +0 -0
- package/{dist/src/transports → transports}/index.d.ts +2 -2
- package/{dist/src/transports → transports}/index.js +0 -0
- package/{dist/src/transports → transports}/metrics.d.ts +1 -2
- package/{dist/src/transports → transports}/metrics.js +0 -0
- package/{dist/src/transports → transports}/rest.d.ts +0 -0
- package/{dist/src/transports → transports}/rest.js +0 -0
- package/{dist/src/transports → transports}/util.d.ts +0 -0
- package/{dist/src/transports → transports}/util.js +0 -0
- package/{dist/src/transports → transports}/websocket.d.ts +3 -2
- package/{dist/src/transports → transports}/websocket.js +6 -4
- package/{dist/src/util → util}/expiring-sorted-set.d.ts +0 -0
- package/{dist/src/util → util}/expiring-sorted-set.js +0 -0
- package/{dist/src/util → util}/index.d.ts +0 -0
- package/{dist/src/util → util}/index.js +0 -0
- package/{dist/src/util → util}/logger.d.ts +0 -0
- package/{dist/src/util → util}/logger.js +0 -0
- package/{dist/src/util → util}/request.d.ts +2 -2
- package/{dist/src/util → util}/request.js +0 -0
- package/{dist/src/util → util}/subscription-set/expiring-sorted-set.d.ts +0 -0
- package/{dist/src/util → util}/subscription-set/expiring-sorted-set.js +0 -0
- package/{dist/src/util → util}/subscription-set/subscription-set.d.ts +0 -0
- package/{dist/src/util → util}/subscription-set/subscription-set.js +0 -0
- package/{dist/src/util → util}/test-payload-loader.d.ts +0 -0
- package/{dist/src/util → util}/test-payload-loader.js +0 -0
- package/{dist/src/validation → validation}/error.d.ts +2 -2
- package/{dist/src/validation → validation}/error.js +0 -0
- package/{dist/src/validation → validation}/index.d.ts +0 -0
- package/{dist/src/validation → validation}/index.js +0 -0
- package/{dist/src/validation → validation}/input-params.d.ts +0 -0
- package/{dist/src/validation → validation}/input-params.js +0 -0
- package/validation/override-functions.d.ts +3 -0
- package/{dist/src/validation → validation}/override-functions.js +0 -0
- package/{dist/src/validation → validation}/preset-tokens.json +0 -0
- package/{dist/src/validation → validation}/validator.d.ts +0 -0
- package/{dist/src/validation → validation}/validator.js +0 -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 -20
- package/.prettierignore +0 -13
- package/.yarnrc +0 -0
- package/README.md +0 -103
- package/dist/src/adapter.d.ts +0 -135
- package/dist/src/adapter.js +0 -145
- package/dist/src/examples/bank-frick/index.d.ts +0 -2
- package/dist/src/examples/coingecko/batch-warming.d.ts +0 -7
- package/dist/src/examples/coingecko/index.d.ts +0 -2
- package/dist/src/examples/coingecko/rest.d.ts +0 -12
- package/dist/src/examples/ncfx/index.d.ts +0 -13
- package/dist/src/metrics/util.d.ts +0 -7
- package/dist/src/package/package.json +0 -72
- package/dist/src/validation/override-functions.d.ts +0 -3
- package/docker-compose.yaml +0 -35
- package/env.sh +0 -54
- package/env2.sh +0 -55
- package/publish.sh +0 -0
- package/src/adapter.ts +0 -263
- package/src/background-executor.ts +0 -52
- package/src/cache/factory.ts +0 -26
- package/src/cache/index.ts +0 -258
- 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 -517
- package/src/config/provider-limits.ts +0 -130
- package/src/examples/bank-frick/README.MD +0 -10
- package/src/examples/bank-frick/accounts.ts +0 -246
- package/src/examples/bank-frick/config/index.ts +0 -53
- package/src/examples/bank-frick/index.ts +0 -13
- package/src/examples/bank-frick/types.d.ts +0 -38
- package/src/examples/bank-frick/util.ts +0 -55
- package/src/examples/coingecko/batch-warming.ts +0 -78
- 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 -99
- package/src/index.ts +0 -149
- package/src/metrics/constants.ts +0 -23
- package/src/metrics/index.ts +0 -115
- package/src/metrics/util.ts +0 -18
- package/src/rate-limiting/background/fixed-frequency.ts +0 -45
- 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 -122
- package/src/transports/index.ts +0 -152
- package/src/transports/metrics.ts +0 -95
- package/src/transports/rest.ts +0 -164
- package/src/transports/util.ts +0 -63
- package/src/transports/websocket.ts +0 -245
- package/src/util/index.ts +0 -22
- package/src/util/logger.ts +0 -69
- package/src/util/request.ts +0 -117
- package/src/util/subscription-set/expiring-sorted-set.ts +0 -54
- package/src/util/subscription-set/subscription-set.ts +0 -35
- package/src/util/test-payload-loader.ts +0 -87
- package/src/validation/error.ts +0 -116
- package/src/validation/index.ts +0 -110
- 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 -108
- package/test/cache/cache-key.test.ts +0 -114
- package/test/cache/helper.ts +0 -100
- 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 -38
- 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 -242
- package/test/smoke.test.ts +0 -166
- 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 -77
- package/test/validation.test.ts +0 -178
- package/test-payload-fail.json +0 -3
- package/test-payload.js +0 -22
- package/test-payload.json +0 -7
- package/test.sh +0 -20
- package/test2.sh +0 -2
- package/tsconfig.json +0 -25
- package/typedoc.json +0 -6
- package/webpack.config.js +0 -23
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.restEndpoint = void 0;
|
|
4
|
-
const adapter_1 = require("../../adapter");
|
|
5
4
|
const transports_1 = require("../../transports");
|
|
6
5
|
const DEFAULT_URL = 'https://api.coingecko.com/api/v3';
|
|
7
6
|
const inputParameters = {
|
|
@@ -43,9 +42,9 @@ const restEndpointTransport = new transports_1.RestTransport({
|
|
|
43
42
|
coalescing: true,
|
|
44
43
|
},
|
|
45
44
|
});
|
|
46
|
-
exports.restEndpoint =
|
|
45
|
+
exports.restEndpoint = {
|
|
47
46
|
name: 'rest',
|
|
48
47
|
aliases: ['qwe'],
|
|
49
48
|
transport: restEndpointTransport,
|
|
50
49
|
inputParameters,
|
|
51
|
-
}
|
|
50
|
+
};
|
|
File without changes
|
|
File without changes
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.adapter = void 0;
|
|
4
|
-
const adapter_1 = require("../../adapter");
|
|
5
4
|
const config_1 = require("./config");
|
|
6
5
|
const websocket_1 = require("./websocket");
|
|
7
|
-
exports.adapter =
|
|
6
|
+
exports.adapter = {
|
|
8
7
|
name: 'ncfx',
|
|
9
8
|
endpoints: [websocket_1.webSocketEndpoint],
|
|
10
9
|
customSettings: config_1.customSettings,
|
|
11
|
-
}
|
|
10
|
+
};
|
|
@@ -32,16 +32,5 @@ export declare const websocketTransport: WebSocketTransport<AdapterRequestParams
|
|
|
32
32
|
readonly required: true;
|
|
33
33
|
};
|
|
34
34
|
}>;
|
|
35
|
-
export declare const webSocketEndpoint: AdapterEndpoint
|
|
36
|
-
readonly USERNAME: {
|
|
37
|
-
readonly description: "Username for the NCFX API";
|
|
38
|
-
readonly type: "string";
|
|
39
|
-
readonly required: true;
|
|
40
|
-
};
|
|
41
|
-
readonly PASSWORD: {
|
|
42
|
-
readonly description: "Password for the NCFX API";
|
|
43
|
-
readonly type: "string";
|
|
44
|
-
readonly required: true;
|
|
45
|
-
};
|
|
46
|
-
}>;
|
|
35
|
+
export declare const webSocketEndpoint: AdapterEndpoint;
|
|
47
36
|
export {};
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.webSocketEndpoint = exports.websocketTransport = exports.inputParameters = void 0;
|
|
4
|
-
const adapter_1 = require("../../adapter");
|
|
5
4
|
const websocket_1 = require("../../transports/websocket");
|
|
6
5
|
const util_1 = require("../../util");
|
|
7
6
|
exports.inputParameters = {
|
|
@@ -66,8 +65,8 @@ exports.websocketTransport = new websocket_1.WebSocketTransport({
|
|
|
66
65
|
}),
|
|
67
66
|
},
|
|
68
67
|
});
|
|
69
|
-
exports.webSocketEndpoint =
|
|
68
|
+
exports.webSocketEndpoint = {
|
|
70
69
|
name: 'websocket',
|
|
71
70
|
transport: exports.websocketTransport,
|
|
72
71
|
inputParameters: exports.inputParameters,
|
|
73
|
-
}
|
|
72
|
+
};
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/package.json
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { AdapterRateLimitTier, BackgroundExecuteRateLimiter } from '..';
|
|
2
2
|
import { AdapterEndpoint } from '../../adapter';
|
|
3
|
-
import { SettingsMap } from '../../config';
|
|
4
3
|
export declare const DEFAULT_SHARED_MS_BETWEEN_REQUESTS = 5000;
|
|
5
4
|
export declare class FixedFrequencyRateLimiter implements BackgroundExecuteRateLimiter {
|
|
6
5
|
msBetweenRequestsMap: {
|
|
7
6
|
[endpointName: string]: number;
|
|
8
7
|
};
|
|
9
|
-
initialize
|
|
8
|
+
initialize(endpoints: AdapterEndpoint[], limits?: AdapterRateLimitTier): this;
|
|
10
9
|
msUntilNextExecution(endpointName: string): number;
|
|
11
10
|
}
|
|
File without changes
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { AdapterEndpoint } from '../adapter';
|
|
2
|
-
import { SettingsMap } from '../config';
|
|
3
2
|
export * from './request/simple-counting';
|
|
4
3
|
export * from './background/fixed-frequency';
|
|
5
4
|
export interface AdapterRateLimitTier {
|
|
@@ -18,7 +17,7 @@ export interface RateLimiter {
|
|
|
18
17
|
* @param limits - settings for how much throughput to allow for the Adapter
|
|
19
18
|
* @param endpoints - list of adapter endpoints
|
|
20
19
|
*/
|
|
21
|
-
initialize
|
|
20
|
+
initialize(endpoints: AdapterEndpoint[], limits: AdapterRateLimitTier): this;
|
|
22
21
|
}
|
|
23
22
|
/**
|
|
24
23
|
* RequestRateLimiters perform checks agains imminent outbound requests for any transport.
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { AdapterRateLimitTier, RateLimiter } from '..';
|
|
2
2
|
import { AdapterEndpoint } from '../../adapter';
|
|
3
|
-
import { SettingsMap } from '../../config';
|
|
4
3
|
/**
|
|
5
4
|
* This rate limiter is the simplest stateful option.
|
|
6
5
|
* On startup, it'll compare the different thresholds for each tier, calculate them all
|
|
@@ -16,6 +15,6 @@ export declare class SimpleCountingRateLimiter implements RateLimiter {
|
|
|
16
15
|
requestsThisMinute: number;
|
|
17
16
|
perSecondLimit: number;
|
|
18
17
|
perMinuteLimit: number;
|
|
19
|
-
initialize
|
|
18
|
+
initialize(endpoints: AdapterEndpoint[], limits?: AdapterRateLimitTier): this;
|
|
20
19
|
isUnderLimits(): boolean;
|
|
21
20
|
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { FastifyReply } from 'fastify';
|
|
2
|
-
import { AdapterContext, AdapterDependencies,
|
|
2
|
+
import { AdapterContext, AdapterDependencies, InitializedAdapter } from '../adapter';
|
|
3
3
|
import { CacheEntry } from '../cache';
|
|
4
4
|
import { AdapterConfig, SettingsMap } from '../config';
|
|
5
5
|
import { AdapterRequest, AdapterResponse, ProviderResult } from '../util/request';
|
|
@@ -67,4 +67,4 @@ export declare const buildCacheEntriesFromResults: <Params, CustomSettings exten
|
|
|
67
67
|
* @param adapter - main adapter object, already initialized
|
|
68
68
|
* @returns the transport handler middleware function
|
|
69
69
|
*/
|
|
70
|
-
export declare const buildTransportHandler: (adapter:
|
|
70
|
+
export declare const buildTransportHandler: (adapter: InitializedAdapter) => (req: AdapterRequest, reply: FastifyReply) => Promise<never>;
|
|
File without changes
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import * as client from 'prom-client';
|
|
2
2
|
import { AdapterContext } from '../adapter';
|
|
3
|
-
import { SettingsMap } from '../config';
|
|
4
3
|
export declare const dataProviderMetricsLabel: (providerStatusCode?: number, method?: string) => {
|
|
5
4
|
provider_status_code: number | undefined;
|
|
6
5
|
method: string;
|
|
@@ -14,7 +13,7 @@ export declare const messageSubsLabels: (feed_id: string, cache_key: string) =>
|
|
|
14
13
|
feed_id: string;
|
|
15
14
|
subscription_key: string;
|
|
16
15
|
};
|
|
17
|
-
export declare const recordWsMessageMetrics: <AdapterParams
|
|
16
|
+
export declare const recordWsMessageMetrics: <AdapterParams>(context: AdapterContext, subscribes: AdapterParams[], unsubscrices: AdapterParams[]) => void;
|
|
18
17
|
export declare const wsConnectionActive: client.Gauge<"url">;
|
|
19
18
|
export declare const wsConnectionErrors: client.Counter<"message" | "url">;
|
|
20
19
|
export declare const wsSubscriptionActive: client.Gauge<"feed_id" | "connection_url" | "subscription_key">;
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import WebSocket from 'ws';
|
|
2
2
|
import { AdapterContext, AdapterDependencies } from '../adapter';
|
|
3
3
|
import { Cache } from '../cache';
|
|
4
|
-
import {
|
|
4
|
+
import { SettingsMap } from '../config';
|
|
5
5
|
import { BackgroundExecuteRateLimiter } from '../rate-limiting';
|
|
6
6
|
import { SubscriptionSet } from '../util';
|
|
7
7
|
import { AdapterRequest, ProviderResult } from '../util/request';
|
|
8
8
|
import { Transport } from './';
|
|
9
|
+
export declare const DEFAULT_WS_TTL = 10000;
|
|
9
10
|
declare type WebSocketClass = new (url: string, protocols?: string | string[] | undefined) => WebSocket;
|
|
10
11
|
export declare class WebSocketClassProvider {
|
|
11
12
|
static ctor: WebSocketClass;
|
|
@@ -71,7 +72,7 @@ export declare class WebSocketTransport<AdapterParams, ProviderDataMessage, Cust
|
|
|
71
72
|
constructor(config: WebSocketTransportConfig<AdapterParams, ProviderDataMessage, CustomSettings>);
|
|
72
73
|
initialize(dependencies: AdapterDependencies): Promise<void>;
|
|
73
74
|
hasBeenSetUp(req: AdapterRequest<AdapterParams>): Promise<boolean>;
|
|
74
|
-
setup(req: AdapterRequest<AdapterParams
|
|
75
|
+
setup(req: AdapterRequest<AdapterParams>): Promise<void>;
|
|
75
76
|
serializeMessage(payload: unknown): string;
|
|
76
77
|
deserializeMessage(data: WebSocket.Data): ProviderDataMessage;
|
|
77
78
|
establishWsConnection(context: AdapterContext<CustomSettings>): Promise<unknown>;
|
|
@@ -26,11 +26,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
26
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.WebSocketTransport = exports.WebSocketClassProvider = void 0;
|
|
29
|
+
exports.WebSocketTransport = exports.WebSocketClassProvider = exports.DEFAULT_WS_TTL = void 0;
|
|
30
30
|
const ws_1 = __importDefault(require("ws"));
|
|
31
31
|
const util_1 = require("../util");
|
|
32
32
|
const _1 = require("./");
|
|
33
33
|
const transportMetrics = __importStar(require("./metrics"));
|
|
34
|
+
// TODO: Config
|
|
35
|
+
exports.DEFAULT_WS_TTL = 10000;
|
|
34
36
|
const logger = (0, util_1.makeLogger)('WebSocketTransport');
|
|
35
37
|
class WebSocketClassProvider {
|
|
36
38
|
static set(ctor) {
|
|
@@ -64,9 +66,9 @@ class WebSocketTransport {
|
|
|
64
66
|
async hasBeenSetUp(req) {
|
|
65
67
|
return !!(await this.subscriptionSet.get(req.requestContext.cacheKey));
|
|
66
68
|
}
|
|
67
|
-
async setup(req
|
|
69
|
+
async setup(req) {
|
|
68
70
|
logger.debug(`Adding entry to subscription set: [${req.requestContext.cacheKey}] = ${req.requestContext.data}`);
|
|
69
|
-
await this.subscriptionSet.add(req.requestContext.cacheKey, req.requestContext.data,
|
|
71
|
+
await this.subscriptionSet.add(req.requestContext.cacheKey, req.requestContext.data, exports.DEFAULT_WS_TTL);
|
|
70
72
|
}
|
|
71
73
|
// TODO: Maybe we don't do this, and leave the preparation on the adapter's side?
|
|
72
74
|
// TODO: Maybe we store adapter params pre-prepared? That would be more efficient
|
|
@@ -82,7 +84,7 @@ class WebSocketTransport {
|
|
|
82
84
|
const ctor = WebSocketClassProvider.get();
|
|
83
85
|
this.wsConnection = new ctor(this.config.url);
|
|
84
86
|
this.wsConnection.addEventListener('open', async (event) => {
|
|
85
|
-
logger.debug(`Opened websocket connection
|
|
87
|
+
logger.debug(`Opened websocket connection.`);
|
|
86
88
|
await this.config.handlers.open(this.wsConnection, context);
|
|
87
89
|
logger.debug('Successfully executed connection opened handler');
|
|
88
90
|
// Record active ws connections by incrementing count on open
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { FastifyReply, FastifyRequest, HookHandlerDoneFunction } from 'fastify';
|
|
2
|
-
import {
|
|
2
|
+
import { InitializedAdapter } from '../adapter';
|
|
3
3
|
import { AdapterError } from '../validation/error';
|
|
4
4
|
declare module 'fastify' {
|
|
5
5
|
interface FastifyRequest {
|
|
@@ -54,4 +54,4 @@ export declare type AdapterResponse<T = unknown> = {
|
|
|
54
54
|
providerStatusCode?: number;
|
|
55
55
|
};
|
|
56
56
|
export declare type Middleware = ((req: AdapterRequest, reply: FastifyReply, done: HookHandlerDoneFunction) => FastifyReply | void) | ((req: AdapterRequest, reply: FastifyReply) => Promise<FastifyReply | void>);
|
|
57
|
-
export declare type AdapterMiddlewareBuilder = (adapter:
|
|
57
|
+
export declare type AdapterMiddlewareBuilder = (adapter: InitializedAdapter) => Middleware;
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -18,9 +18,9 @@ export declare class AdapterError extends Error {
|
|
|
18
18
|
jobRunID: string;
|
|
19
19
|
status: string;
|
|
20
20
|
statusCode: number;
|
|
21
|
-
cause:
|
|
21
|
+
cause: any;
|
|
22
22
|
url?: string;
|
|
23
|
-
errorResponse:
|
|
23
|
+
errorResponse: any;
|
|
24
24
|
feedID?: string;
|
|
25
25
|
providerStatusCode?: number;
|
|
26
26
|
metricsLabel?: HttpRequestType;
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/.c8rc.json
DELETED
package/.eslintignore
DELETED
package/.eslintrc.js
DELETED
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
// https://github.com/typescript-eslint/typescript-eslint/blob/master/docs/getting-started/linting/README.md
|
|
2
|
-
module.exports = {
|
|
3
|
-
root: true,
|
|
4
|
-
parser: '@typescript-eslint/parser',
|
|
5
|
-
plugins: ['@typescript-eslint', 'eslint-plugin-tsdoc'],
|
|
6
|
-
extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended', 'prettier'],
|
|
7
|
-
rules: {
|
|
8
|
-
'tsdoc/syntax': 'warn',
|
|
9
|
-
|
|
10
|
-
// Problems
|
|
11
|
-
'array-callback-return': [
|
|
12
|
-
'error',
|
|
13
|
-
{
|
|
14
|
-
allowImplicit: false,
|
|
15
|
-
checkForEach: true,
|
|
16
|
-
},
|
|
17
|
-
],
|
|
18
|
-
'no-constant-binary-expression': 'error',
|
|
19
|
-
'no-constructor-return': 'error',
|
|
20
|
-
'no-duplicate-imports': 'error',
|
|
21
|
-
'no-promise-executor-return': 'error',
|
|
22
|
-
'no-self-compare': 'error',
|
|
23
|
-
'no-template-curly-in-string': 'error',
|
|
24
|
-
'no-unmodified-loop-condition': 'error',
|
|
25
|
-
'no-unreachable-loop': 'error',
|
|
26
|
-
'no-unused-private-class-members': 'error',
|
|
27
|
-
'require-atomic-updates': 'error',
|
|
28
|
-
|
|
29
|
-
// Suggestions
|
|
30
|
-
'capitalized-comments': ['error', 'always', { ignoreConsecutiveComments: true }],
|
|
31
|
-
complexity: ['error', 25], // TODO: Should be lower (15?), but validator has complex methods
|
|
32
|
-
curly: 'error',
|
|
33
|
-
'default-case-last': 'error',
|
|
34
|
-
'default-param-last': 'error',
|
|
35
|
-
eqeqeq: ['error', 'smart'],
|
|
36
|
-
'func-names': 'error',
|
|
37
|
-
'func-style': ['error', 'declaration', { allowArrowFunctions: true }],
|
|
38
|
-
'grouped-accessor-pairs': ['error', 'getBeforeSet'],
|
|
39
|
-
'max-depth': ['error', 4], // TODO: Should be lower (3), but validator has complex methods
|
|
40
|
-
'max-nested-callbacks': ['error', 2],
|
|
41
|
-
'max-params': ['error', 4], // TODO: Should be lower (3), but validator has complex methods,
|
|
42
|
-
'new-cap': ['error', { newIsCapExceptions: ['ctor'] }],
|
|
43
|
-
'no-caller': 'error',
|
|
44
|
-
'no-confusing-arrow': [
|
|
45
|
-
'error',
|
|
46
|
-
{
|
|
47
|
-
allowParens: true,
|
|
48
|
-
},
|
|
49
|
-
],
|
|
50
|
-
'no-console': ['warn'], // We want this to debug, but the check workflow should accept no warns
|
|
51
|
-
'no-div-regex': 'error',
|
|
52
|
-
'no-eval': 'error',
|
|
53
|
-
'no-extend-native': 'error',
|
|
54
|
-
'no-extra-bind': 'error',
|
|
55
|
-
'no-extra-label': 'error',
|
|
56
|
-
'no-extra-semi': 'error',
|
|
57
|
-
'no-floating-decimal': 'error',
|
|
58
|
-
'no-implied-eval': 'error',
|
|
59
|
-
'no-invalid-this': 'error',
|
|
60
|
-
'no-labels': 'error',
|
|
61
|
-
'no-lonely-if': 'error',
|
|
62
|
-
'no-multi-assign': 'error',
|
|
63
|
-
'no-multi-str': 'error',
|
|
64
|
-
'no-nested-ternary': 'error',
|
|
65
|
-
'no-new': 'error',
|
|
66
|
-
'no-new-func': 'error',
|
|
67
|
-
'no-new-object': 'error',
|
|
68
|
-
'no-new-wrappers': 'error',
|
|
69
|
-
'no-param-reassign': 'error',
|
|
70
|
-
'no-proto': 'error',
|
|
71
|
-
'no-return-assign': 'error',
|
|
72
|
-
'no-return-await': 'error',
|
|
73
|
-
'no-sequences': 'error',
|
|
74
|
-
'no-shadow': 'off',
|
|
75
|
-
'@typescript-eslint/no-shadow': 'error', // https://stackoverflow.com/questions/63961803/eslint-says-all-enums-in-typescript-app-are-already-declared-in-the-upper-scope
|
|
76
|
-
'no-unneeded-ternary': 'error',
|
|
77
|
-
'no-useless-call': 'error',
|
|
78
|
-
'no-useless-computed-key': 'error',
|
|
79
|
-
'no-useless-concat': 'error',
|
|
80
|
-
'no-useless-rename': 'error',
|
|
81
|
-
'no-var': 'error',
|
|
82
|
-
'operator-assignment': ['error', 'always'],
|
|
83
|
-
'prefer-arrow-callback': 'error',
|
|
84
|
-
'prefer-const': 'error',
|
|
85
|
-
'prefer-exponentiation-operator': 'error',
|
|
86
|
-
'prefer-object-spread': 'error',
|
|
87
|
-
'prefer-promise-reject-errors': 'error',
|
|
88
|
-
'prefer-regex-literals': 'error',
|
|
89
|
-
'prefer-rest-params': 'error',
|
|
90
|
-
'prefer-spread': 'error',
|
|
91
|
-
'prefer-template': 'error',
|
|
92
|
-
'spaced-comment': ['error', 'always'],
|
|
93
|
-
'symbol-description': 'error',
|
|
94
|
-
yoda: 'error',
|
|
95
|
-
},
|
|
96
|
-
}
|