@chainlink/external-adapter-framework 0.0.69 → 0.1.0

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.
Files changed (99) hide show
  1. package/adapter/basic.d.ts +34 -2
  2. package/adapter/basic.js +113 -1
  3. package/adapter/basic.js.map +1 -1
  4. package/adapter/price.d.ts +33 -5
  5. package/adapter/price.js +41 -2
  6. package/adapter/price.js.map +1 -1
  7. package/adapter/types.d.ts +15 -1
  8. package/cache/index.d.ts +3 -10
  9. package/cache/index.js +4 -46
  10. package/cache/index.js.map +1 -1
  11. package/cache/redis.d.ts +1 -8
  12. package/cache/redis.js +22 -39
  13. package/cache/redis.js.map +1 -1
  14. package/config/index.d.ts +1 -1
  15. package/config/index.js +0 -1
  16. package/config/index.js.map +1 -1
  17. package/examples/bank-frick/accounts.d.ts +1 -1
  18. package/examples/bank-frick/accounts.js.map +1 -1
  19. package/examples/bank-frick/config/index.d.ts +1 -1
  20. package/examples/coingecko/src/crypto-utils.d.ts +5 -5
  21. package/examples/coingecko/src/crypto-utils.js +1 -2
  22. package/examples/coingecko/src/crypto-utils.js.map +1 -1
  23. package/examples/coingecko/src/endpoint/coins.js.map +1 -1
  24. package/examples/coingecko/src/endpoint/crypto-marketcap.d.ts +1 -1
  25. package/examples/coingecko/src/endpoint/crypto-marketcap.js.map +1 -1
  26. package/examples/coingecko/src/endpoint/crypto-volume.d.ts +1 -1
  27. package/examples/coingecko/src/endpoint/crypto-volume.js.map +1 -1
  28. package/examples/coingecko/src/endpoint/crypto.d.ts +1 -4
  29. package/examples/coingecko/src/endpoint/crypto.js.map +1 -1
  30. package/examples/coingecko/src/endpoint/dominance.d.ts +1 -1
  31. package/examples/coingecko/src/endpoint/dominance.js.map +1 -1
  32. package/examples/coingecko/src/endpoint/global-marketcap.d.ts +1 -1
  33. package/examples/coingecko/src/endpoint/global-marketcap.js.map +1 -1
  34. package/examples/coingecko/src/global-utils.d.ts +3 -3
  35. package/examples/coingecko/src/global-utils.js.map +1 -1
  36. package/examples/coingecko/src/index.d.ts +1 -1
  37. package/examples/coingecko-old/batch-warming.d.ts +1 -1
  38. package/examples/coingecko-old/rest.js.map +1 -1
  39. package/examples/cryptocompare/src/endpoints/crypto.d.ts +1 -1
  40. package/examples/cryptocompare/src/index.d.ts +1 -1
  41. package/examples/genesis/sseStream.d.ts +2 -2
  42. package/examples/genesis/sseStream.js +15 -8
  43. package/examples/genesis/sseStream.js.map +1 -1
  44. package/examples/ncfx/websocket.d.ts +1 -1
  45. package/index.d.ts +3 -1
  46. package/index.js +4 -6
  47. package/index.js.map +1 -1
  48. package/metrics/index.js +1 -1
  49. package/metrics/index.js.map +1 -1
  50. package/package.json +3 -2
  51. package/rate-limiting/index.d.ts +2 -2
  52. package/transports/batch-warming.d.ts +5 -5
  53. package/transports/batch-warming.js +3 -3
  54. package/transports/batch-warming.js.map +1 -1
  55. package/transports/index.d.ts +9 -16
  56. package/transports/index.js +2 -59
  57. package/transports/index.js.map +1 -1
  58. package/transports/metrics.d.ts +1 -1
  59. package/transports/rest.d.ts +4 -2
  60. package/transports/rest.js +2 -1
  61. package/transports/rest.js.map +1 -1
  62. package/transports/sse.d.ts +5 -5
  63. package/transports/sse.js +1 -2
  64. package/transports/sse.js.map +1 -1
  65. package/transports/websocket.d.ts +5 -5
  66. package/transports/websocket.js +2 -2
  67. package/transports/websocket.js.map +1 -1
  68. package/util/logger.d.ts +2 -0
  69. package/util/logger.js +44 -4
  70. package/util/logger.js.map +1 -1
  71. package/validation/index.js +6 -13
  72. package/validation/index.js.map +1 -1
  73. package/validation/input-params.d.ts +0 -1
  74. package/validation/input-params.js +0 -28
  75. package/validation/input-params.js.map +1 -1
  76. package/validation/input-validator.js +1 -2
  77. package/validation/input-validator.js.map +1 -1
  78. package/adapter.d.ts +0 -156
  79. package/adapter.js +0 -200
  80. package/adapter.js.map +0 -1
  81. package/examples/coingecko/batch-warming.d.ts +0 -7
  82. package/examples/coingecko/batch-warming.js +0 -54
  83. package/examples/coingecko/batch-warming.js.map +0 -1
  84. package/examples/coingecko/index.d.ts +0 -2
  85. package/examples/coingecko/index.js +0 -12
  86. package/examples/coingecko/index.js.map +0 -1
  87. package/examples/coingecko/rest.d.ts +0 -12
  88. package/examples/coingecko/rest.js +0 -55
  89. package/examples/coingecko/rest.js.map +0 -1
  90. package/examples/coingecko/src/cryptoUtils.d.ts +0 -31
  91. package/examples/coingecko/src/cryptoUtils.js +0 -60
  92. package/examples/coingecko/src/globalUtils.d.ts +0 -27
  93. package/examples/coingecko/src/globalUtils.js +0 -46
  94. package/validation/override-functions.d.ts +0 -3
  95. package/validation/override-functions.js +0 -41
  96. package/validation/override-functions.js.map +0 -1
  97. package/validation/preset-tokens.json +0 -23
  98. package/validation/validator.d.ts +0 -47
  99. package/validation/validator.js +0 -303
package/util/logger.js CHANGED
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.loggingContextMiddleware = exports.makeLogger = exports.asyncLocalStorage = void 0;
6
+ exports.loggingContextMiddleware = exports.makeLogger = exports.colorFactory = exports.COLORS = exports.asyncLocalStorage = void 0;
7
7
  const pino_1 = __importDefault(require("pino"));
8
8
  const config_1 = require("../config");
9
9
  const crypto_1 = require("crypto");
@@ -15,8 +15,8 @@ const debugTransport = {
15
15
  options: {
16
16
  levelFirst: true,
17
17
  levelLabel: 'level',
18
- ignore: 'layer,pid,hostname,correlationId',
19
- messageFormat: '[{correlationId}][{layer}] {msg}',
18
+ ignore: 'layer,pid,hostname,correlationId,color',
19
+ messageFormat: `\x1b[0m[{correlationId}] {color}[{layer}]\x1b[0m {msg}`,
20
20
  translateTime: 'yyyy-mm-dd HH:MM:ss.l',
21
21
  },
22
22
  };
@@ -43,6 +43,41 @@ const baseLogger = (0, pino_1.default)({
43
43
  ? debugTransport
44
44
  : undefined,
45
45
  });
46
+ exports.COLORS = [
47
+ '\u001b[31;1m',
48
+ '\u001b[32m',
49
+ '\u001b[33m',
50
+ '\u001b[34m',
51
+ '\u001b[35m',
52
+ '\u001b[36m',
53
+ '\u001b[38;2;121;85;72m',
54
+ '\u001b[92m',
55
+ '\u001b[93m',
56
+ '\u001b[94m',
57
+ '\u001b[95m',
58
+ '\u001b[96m',
59
+ '\u001b[38;5;202m',
60
+ '\u001b[38;5;31m',
61
+ '\u001b[38;5;130m',
62
+ '\u001b[38;2;255;122;92m',
63
+ '\u001b[38;2;46;125;50m',
64
+ '\u001b[38;2;129;168;37m',
65
+ '\u001b[38;2;175;180;43m',
66
+ '\u001b[91m',
67
+ '\u001b[38;2;63;81;181m',
68
+ ];
69
+ const colorFactory = (colors) => {
70
+ let index = -1;
71
+ return () => {
72
+ index++;
73
+ if (index > colors.length - 1) {
74
+ index = 0;
75
+ }
76
+ return colors[index];
77
+ };
78
+ };
79
+ exports.colorFactory = colorFactory;
80
+ const getNextColor = (0, exports.colorFactory)(exports.COLORS);
46
81
  /**
47
82
  * Instead of using a global logger instance, we want to force using a child logger
48
83
  * with a specific layer set in it, so that we can filter logs by where they're output from.
@@ -61,7 +96,12 @@ const baseLogger = (0, pino_1.default)({
61
96
  * @param layer - the layer name to include in the logs (e.g. "SomeMiddleware", "RedisCache", etc.)
62
97
  * @returns a layer specific logger
63
98
  */
64
- const makeLogger = (layer) => baseLogger.child({ layer });
99
+ const makeLogger = (layer) => baseLogger.child({
100
+ layer,
101
+ color: process.env['DEBUG'] === 'true' || process.env['NODE_ENV'] === 'development'
102
+ ? getNextColor()
103
+ : undefined,
104
+ });
65
105
  exports.makeLogger = makeLogger;
66
106
  const loggingContextMiddleware = (req, res, done) => {
67
107
  const correlationId = req.headers['x-correlation-id'] || (0, crypto_1.randomUUID)();
@@ -1 +1 @@
1
- {"version":3,"file":"logger.js","sourceRoot":"","sources":["../../../src/util/logger.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAuB;AACvB,sCAAw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OAAO,CAAC,CAAC,KAAK,EAAE,EAAE;QAC3B,WAAW,GAAG,WAAW,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,EAAE,IAAI,KAAK,CAAC,GAAG,YAAY,CAAC,CAAA;IAC3E,CAAC,CAAC,CAAA;IACF,OAAO,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,CAAA;AAChC,CAAC"}
@@ -5,7 +5,6 @@ const cache_1 = require("../cache");
5
5
  const util_1 = require("../metrics/util");
6
6
  const util_2 = require("../util");
7
7
  const error_1 = require("./error");
8
- const override_functions_1 = require("./override-functions");
9
8
  const errorCatcherLogger = (0, util_2.makeLogger)('ErrorCatchingMiddleware');
10
9
  const validatorMiddleware = (adapter) => (req, reply, done) => {
11
10
  if (req.headers['content-type'] !== 'application/json') {
@@ -55,16 +54,10 @@ const validatorMiddleware = (adapter) => (req, reply, done) => {
55
54
  }, validatedData);
56
55
  req.requestContext = { ...req.requestContext, meta: { metrics } };
57
56
  }
58
- const requestParams = req.requestContext.data ?? {};
59
- if (requestParams['tokenOverrides']) {
60
- throw new Error('Token overrides not yet supported');
61
- }
62
- if (requestParams['includes']) {
63
- throw new Error('Includes not yet supported');
64
- }
65
- // Swaps the 'base' parameter if any overrides are found in the request or the adapter configuration
66
- // Supports 'base' input as string or string[]
67
- (0, override_functions_1.performSymbolOverrides)(adapter, req);
57
+ // Run any request transforms that might have been defined in the adapter.
58
+ // This is the last time modifications are supposed to happen to the request.
59
+ adapter.runRequestTransforms(req);
60
+ // Now that all the transformations have been applied, all that's left is calculating the cache key
68
61
  req.requestContext.cacheKey = (0, cache_1.calculateCacheKey)({
69
62
  adapterEndpoint: endpoint,
70
63
  adapterConfig: adapter.config,
@@ -81,11 +74,11 @@ const errorCatchingMiddleware = (err, req, res) => {
81
74
  if (err instanceof error_1.AdapterError) {
82
75
  // We want to log these as warn, because although they are to be expected, NOPs should
83
76
  // Only use "correct" job specs and therefore not hit adapters with invalid requests.
84
- errorCatcherLogger.warn(err);
77
+ errorCatcherLogger.warn(err.message);
85
78
  res.status(err.statusCode).send(err.toJSONResponse());
86
79
  }
87
80
  else {
88
- errorCatcherLogger.error(err);
81
+ errorCatcherLogger.error(err.stack);
89
82
  res.status(200).send('There was an unexpected error in the adapter.');
90
83
  }
91
84
  };
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/validation/index.ts"],"names":[],"mappings":";;;AAEA,oCAA4C;AAC5C,0CAAgD;AAChD,kCAAoC;AAEpC,mCAAyD;AACzD,6DAA6D;AAG7D,MAAM,kBAAkB,GAAG,IAAA,iBAAU,EAAC,yBAAyB,CAAC,CAAA;AAEzD,MAAM,mBAAmB,GAC9B,CAAC,OAAgB,EAAE,EAAE,CACrB,CAAC,GAAmB,EAAE,KAAmB,EAAE,IAA6B,EAAE,EAAE;IAC1E,IAAI,GAAG,CAAC,OAAO,CAAC,cAAc,CAAC,KAAK,kBAAkB,EAAE;QACtD,MAAM,IAAI,yBAAiB,CAAC;YAC1B,OAAO,EAAE,oDAAoD;YAC7D,UAAU,EAAE,GAAG;SAChB,CAAC,CAAA;KACH;IAED,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE;QACb,MAAM,IAAI,yBAAiB,CAAC;YAC1B,OAAO,EAAE,oDAAoD;YAC7D,UAAU,EAAE,GAAG;SAChB,CAAC,CAAA;KACH;IAED,4EAA4E;IAC5E,qEAAqE;IACrE,MAAM,WAAW,GAAG,GAAG,CAAC,IAAqC,CAAA;IAE7D,kCAAkC;IAClC,MAAM,aAAa,GACjB,WAAW,CAAC,QAAQ,EAAE,WAAW,EAAE;QACnC,WAAW,CAAC,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE;QACzC,OAAO,CAAC,eAAe,CAAA;IACzB,IAAI,CAAC,aAAa,EAAE;QAClB,MAAM,IAAI,yBAAiB,CAAC;YAC1B,OAAO,EAAE,0GAA0G;YACnH,UAAU,EAAE,GAAG;SAChB,CAAC,CAAA;KACH;IAED,MAAM,QAAQ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AI,CAAC,+CAA+C,CAAC,CAAA;KACtE;AACH,CAAC,CAAA;AAfY,QAAA,uBAAuB,2BAenC"}
@@ -12,4 +12,3 @@ export declare type InputParameter = {
12
12
  export declare type InputParameters = {
13
13
  [name: string]: InputParameter;
14
14
  };
15
- export declare const baseInputParameters: InputParameters;
@@ -1,31 +1,3 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.baseInputParameters = void 0;
4
- exports.baseInputParameters = {
5
- endpoint: {
6
- description: 'The External Adapter "endpoint" name to use.',
7
- required: false,
8
- type: 'string',
9
- },
10
- resultPath: {
11
- description: 'The path to key into the API response the retrieve the result',
12
- required: false,
13
- // Type: 'string', TODO: Once multiple types are supported this could be string or array of strings
14
- },
15
- overrides: {
16
- description: 'Override the mapping of token symbols to another token symbol',
17
- required: false,
18
- // Type: 'string', TODO: Once complex types are supported this could be { [adapter: string]: { [token: string]: string } }
19
- },
20
- tokenOverrides: {
21
- description: 'Override the mapping of token symbols to smart contract address',
22
- required: false,
23
- // Type: 'string', TODO: Once complex types are supported this could be { [network: string]: { [token: string]: string } }
24
- },
25
- includes: {
26
- description: 'Override the array of includes that holds additional input parameters when matching a pair of symbols',
27
- required: false,
28
- // Type: 'string', TODO: Once complex types are supported this could be { from: string, to: string, includes: [{ from: string, to: string, adapters: string[], inverse: boolean, tokens: boolean }] } }[]
29
- },
30
- };
31
3
  //# sourceMappingURL=input-params.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"input-params.js","sourceRoot":"","sources":["../../../src/validation/input-params.ts"],"names":[],"mappings":";;;AAkBa,QAAA,mBAAmB,GAAoB;IAClD,QAAQ,EAAE;QACR,WAAW,EAAE,8CAA8C;QAC3D,QAAQ,EAAE,KAAK;QACf,IAAI,EAAE,QAAQ;KACf;IACD,UAAU,EAAE;QACV,WAAW,EAAE,+DAA+D;QAC5E,QAAQ,EAAE,KAAK;QACf,mGAAmG;KACpG;IACD,SAAS,EAAE;QACT,WAAW,EAAE,+DAA+D;QAC5E,QAAQ,EAAE,KAAK;QACf,0HAA0H;KAC3H;IACD,cAAc,EAAE;QACd,WAAW,EAAE,iEAAiE;QAC9E,QAAQ,EAAE,KAAK;QACf,0HAA0H;KAC3H;IACD,QAAQ,EAAE;QACR,WAAW,EACT,uGAAuG;QACzG,QAAQ,EAAE,KAAK;QACf,yMAAyM;KAC1M;CACF,CAAA"}
1
+ {"version":3,"file":"input-params.js","sourceRoot":"","sources":["../../../src/validation/input-params.ts"],"names":[],"mappings":""}
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.InputValidator = void 0;
4
- const input_params_1 = require("./input-params");
5
4
  const error_1 = require("./error");
6
5
  const util_1 = require("../util");
7
6
  class InputValidator {
@@ -12,7 +11,7 @@ class InputValidator {
12
11
  this.throwInvalid = (message) => {
13
12
  throw new error_1.AdapterInputError({ statusCode: 400, message });
14
13
  };
15
- this.inputConfig = { ...input_params_1.baseInputParameters, ...inputConfig };
14
+ this.inputConfig = { ...inputConfig };
16
15
  this.validateInputParamsSchema();
17
16
  }
18
17
  validateInput(input) {
@@ -1 +1 @@
1
- {"version":3,"file":"input-validator.js","sourceRoot":"","sources":["../../../src/validation/input-validator.ts"],"names":[],"mappings":";;;AAAA,iDAAqE;AACrE,mCAA2C;AAC3C,kCAAiC;AAIjC,MAAa,cAAc;IAEzB,YAA6B,WAA4B;QAA5B,gBAAW,GAAX,WAAW,CAAiB;QADjD,YAAO,GAAgC,EAAE,CAAA;QAqIzC,eAAU,GAAG,CAAC,OAAiB,EAAE,KAA8B,EAAU,EAAE,CACjF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,KAAK,IAAI,CAAC,IAAA,cAAO,EAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAA;QAEhD,iBAAY,GAAG,CAAC,OAAe,EAAQ,EAAE;YAC/C,MAAM,IAAI,yBAAiB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C,CAAA;aAC9E;SACF;IACH,CAAC;CAQF;AA5ID,wCA4IC"}
package/adapter.d.ts DELETED
@@ -1,156 +0,0 @@
1
- import Redis from 'ioredis';
2
- import type EventSource from 'eventsource';
3
- import { Cache } from './cache';
4
- import { AdapterConfig, BaseAdapterConfig, CustomSettingsType, SettingsMap } from './config';
5
- import { AdapterRateLimitTier, BackgroundExecuteRateLimiter, RequestRateLimiter } from './rate-limiting';
6
- import { Transport } from './transports';
7
- import { SubscriptionSetFactory } from './util';
8
- import { InputParameters } from './validation/input-params';
9
- import { InputValidator } from './validation/input-validator';
10
- /**
11
- * Dependencies that will be injected into the Adapter on startup
12
- */
13
- export interface AdapterDependencies {
14
- /** Specific instance of the Cache the adapter will use (e.g. Local, Redis, etc.) */
15
- cache: Cache;
16
- /** Shared instance of the request rate limiter */
17
- requestRateLimiter: RequestRateLimiter;
18
- /** Shared instance of the background execute rate limiter */
19
- backgroundExecuteRateLimiter: BackgroundExecuteRateLimiter;
20
- /** Factory to create subscription sets based on the specified cache type */
21
- subscriptionSetFactory: SubscriptionSetFactory;
22
- /** Redis client used for cache and subscription set */
23
- redisClient: Redis;
24
- /** EventSource to use for listening to server sent events. A mock EventSource can be provided as a dependency for testing */
25
- eventSource: typeof EventSource;
26
- }
27
- /**
28
- * Context that will be used on background executions of a Transport.
29
- * For example, the endpointName used to log statements or generate Cache keys.
30
- */
31
- export interface AdapterContext<CustomSettings extends CustomSettingsType<CustomSettings> = SettingsMap> {
32
- /** Endpoint instance within the adapter that the Transport is related to */
33
- adapterEndpoint: AdapterEndpoint<unknown, unknown, CustomSettings>;
34
- /** Initialized config for the adapter that the Transport can access */
35
- adapterConfig: AdapterConfig<CustomSettings>;
36
- }
37
- /**
38
- * Structure to describe rate limits specs for the Adapter
39
- */
40
- interface AdapterRateLimitingConfig {
41
- /** Adapter rate limits, gotten from the specific tier requested */
42
- tiers: Record<string, AdapterRateLimitTier>;
43
- }
44
- /**
45
- * Main structure of an External Adapter
46
- */
47
- export interface AdapterParams<CustomSettings extends SettingsMap> {
48
- /** Name of the adapter */
49
- name: string;
50
- /** If present, the string that will be used for requests with no specified endpoint */
51
- defaultEndpoint?: string;
52
- /**
53
- * List of [[AdapterEndpoint]]s in the adapter. This is purposefully typed any; it's the correct type in this case.
54
- *
55
- * When you try to create an adapter and you provide an endpoint, if these generics were set to "unknown" instead
56
- * what would happen is that Typescript would check if the types match, and would fail to assign unknown to the
57
- * specific Params or Result in the transport itself.
58
- * We also can't use generics, because if we had more than one transport with different requests (very likely)
59
- * then those new types wouldn't match with each other.
60
- */
61
- endpoints: AdapterEndpoint<any, any, CustomSettings>[];
62
- /** Map of overrides to the default config values for an Adapter */
63
- envDefaultOverrides?: Partial<BaseAdapterConfig>;
64
- /** List of custom env vars for this particular adapter (e.g. RPC_URL) */
65
- customSettings?: SettingsMap;
66
- /** Configuration relevant to outbound (EA --\> DP) communication rate limiting */
67
- rateLimiting?: AdapterRateLimitingConfig;
68
- /** Overrides for converting the 'base' parameter that are hardcoded into the adapter. */
69
- overrides?: Record<string, string>;
70
- }
71
- /**
72
- * Structure to describe rate limits specs for a specific adapter endpoint
73
- */
74
- export interface EndpointRateLimitingConfig {
75
- /**
76
- * How much of the total limit for the adapter will be assigned to this specific endpoint.
77
- * Should be a non-zero positive number up to 100.
78
- * Endpoints in the same adapter without a specific allocation will divide the remaining limits equally.
79
- */
80
- allocationPercentage: number;
81
- }
82
- /**
83
- * Structure to describe a specific endpoint in an [[Adapter]]
84
- */
85
- export interface AdapterEndpointParams<Params, Result, CustomSettings extends SettingsMap> {
86
- /** Name that will be used to match input params to this endpoint (case insensitive) */
87
- name: string;
88
- /** List of alternative endpoint names that will resolve to this same transport (case insensitive) */
89
- aliases?: string[];
90
- /** Transport that will be used to handle data processing and communication for this endpoint */
91
- transport: Transport<Params, Result, CustomSettings>;
92
- /** Specification of what the body of a request hitting this endpoint should look like (used for validation) */
93
- inputParameters: InputParameters;
94
- /** Specific details related to the rate limiting for this endpoint in particular */
95
- rateLimiting?: EndpointRateLimitingConfig;
96
- }
97
- export declare class AdapterEndpoint<Params, Result, CustomSettings extends SettingsMap> implements AdapterEndpointParams<Params, Result, CustomSettings> {
98
- name: string;
99
- aliases?: string[] | undefined;
100
- transport: Transport<Params, Result, CustomSettings>;
101
- inputParameters: InputParameters;
102
- rateLimiting?: EndpointRateLimitingConfig | undefined;
103
- validator: InputValidator;
104
- constructor(params: AdapterEndpointParams<Params, Result, CustomSettings>);
105
- }
106
- declare type CustomAdapterSettings = SettingsMap & NegatedAdapterSettings;
107
- declare type NegatedAdapterSettings = {
108
- [K in keyof BaseAdapterConfig]?: never;
109
- };
110
- export declare class Adapter<CustomSettings extends CustomAdapterSettings = SettingsMap> implements AdapterParams<CustomSettings> {
111
- name: string;
112
- defaultEndpoint?: string | undefined;
113
- endpoints: AdapterEndpoint<unknown, unknown, CustomSettings>[];
114
- envDefaultOverrides?: Partial<BaseAdapterConfig> | undefined;
115
- customSettings?: SettingsMap | undefined;
116
- rateLimiting?: AdapterRateLimitingConfig | undefined;
117
- overrides?: Record<string, string> | undefined;
118
- initialized: boolean;
119
- /** Object containing alias translations for all endpoints */
120
- endpointsMap: Record<string, AdapterEndpoint<unknown, unknown, CustomSettings>>;
121
- /** Initialized dependencies that the adapter will use */
122
- dependencies: AdapterDependencies;
123
- /** Configuration params for various adapter properties */
124
- config: AdapterConfig;
125
- constructor(params: AdapterParams<CustomSettings>);
126
- /**
127
- * Initializes all of the [[Transport]]s in the adapter, passing along any [[AdapterDependencies]] and [[AdapterConfig]].
128
- * Additionally, it builds a map out of all the endpoint names and aliases (checking for duplicates).
129
- */
130
- initialize(dependencies?: Partial<AdapterDependencies>): Promise<void>;
131
- /**
132
- * Takes an adapter and normalizes all endpoint names and aliases, as well as the default endpoint.
133
- * i.e. makes them lowercase for now
134
- */
135
- private normalizeEndpointNames;
136
- /**
137
- * This function will take an adapter structure and go through each endpoint, calculating
138
- * each one's allocation of the total rate limits that are set for the adapter as a whole.
139
- *
140
- */
141
- private calculateRateLimitAllocations;
142
- /**
143
- * Creates a list of key/value pairs that need to be censored in the logs
144
- * using the sensitive flag in the adapter config
145
- */
146
- private buildCensorList;
147
- /**
148
- * This function will process dependencies for an adapter, such as caches or rate limiters,
149
- * in order to inject them into transports and other relevant places later in the lifecycle.
150
- *
151
- * @param inputDependencies - a partial obj of initialized dependencies to override the created ones
152
- * @returns a set of AdapterDependencies all initialized
153
- */
154
- initializeDependencies(inputDependencies?: Partial<AdapterDependencies>): AdapterDependencies;
155
- }
156
- export {};
package/adapter.js DELETED
@@ -1,200 +0,0 @@
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.Adapter = exports.AdapterEndpoint = void 0;
30
- const ioredis_1 = __importDefault(require("ioredis"));
31
- const cache_1 = require("./cache");
32
- const config_1 = require("./config");
33
- const rate_limiting_1 = require("./rate-limiting");
34
- const util_1 = require("./util");
35
- const censor_list_1 = __importDefault(require("./util/censor/censor-list"));
36
- const cacheMetrics = __importStar(require("./cache/metrics"));
37
- const input_validator_1 = require("./validation/input-validator");
38
- const client = __importStar(require("prom-client"));
39
- const logger = (0, util_1.makeLogger)('Adapter');
40
- /**
41
- * `prom-client` is shared between v2 and v3 when both are dependencies, resulting in metric collision errors
42
- * Clearing metrics on import will wipe v2's existing register so we can replace them with v3's metrics
43
- **/
44
- client.register.clear();
45
- class AdapterEndpoint {
46
- constructor(params) {
47
- this.name = params.name;
48
- this.aliases = params.aliases;
49
- this.transport = params.transport;
50
- this.inputParameters = params.inputParameters;
51
- this.rateLimiting = params.rateLimiting;
52
- this.validator = new input_validator_1.InputValidator(this.inputParameters);
53
- }
54
- }
55
- exports.AdapterEndpoint = AdapterEndpoint;
56
- class Adapter {
57
- constructor(params) {
58
- // After initialization
59
- this.initialized = false;
60
- /** Object containing alias translations for all endpoints */
61
- this.endpointsMap = {};
62
- // Copy over params
63
- this.name = params.name;
64
- this.defaultEndpoint = params.defaultEndpoint?.toLowerCase();
65
- this.endpoints = params.endpoints;
66
- this.envDefaultOverrides = params.envDefaultOverrides;
67
- this.customSettings = params.customSettings;
68
- this.rateLimiting = params.rateLimiting;
69
- this.overrides = params.overrides;
70
- this.config = (0, config_1.buildAdapterConfig)({
71
- overrides: this.envDefaultOverrides,
72
- customSettings: this.customSettings,
73
- });
74
- this.normalizeEndpointNames();
75
- this.calculateRateLimitAllocations();
76
- }
77
- /**
78
- * Initializes all of the [[Transport]]s in the adapter, passing along any [[AdapterDependencies]] and [[AdapterConfig]].
79
- * Additionally, it builds a map out of all the endpoint names and aliases (checking for duplicates).
80
- */
81
- async initialize(dependencies) {
82
- if (this.initialized) {
83
- throw new Error('This adapter has already been initialized!');
84
- }
85
- this.dependencies = this.initializeDependencies(dependencies);
86
- for (const endpoint of this.endpoints) {
87
- // Add aliases to map to use in validation
88
- const aliases = [endpoint.name, ...(endpoint.aliases || [])];
89
- for (const alias of aliases) {
90
- if (this.endpointsMap[alias]) {
91
- throw new Error(`Duplicate endpoint / alias: "${alias}"`);
92
- }
93
- this.endpointsMap[alias] = endpoint;
94
- }
95
- logger.debug(`Initializing transport for endpoint "${endpoint.name}"...`);
96
- await endpoint.transport.initialize(this.dependencies, this.config, endpoint.name);
97
- }
98
- // Build list of key/values that need to be redacted in logs
99
- // Populates the static array in CensorList to use in censor-transport
100
- this.buildCensorList();
101
- logger.debug('Adapter initialization complete.');
102
- this.initialized = true;
103
- }
104
- /**
105
- * Takes an adapter and normalizes all endpoint names and aliases, as well as the default endpoint.
106
- * i.e. makes them lowercase for now
107
- */
108
- normalizeEndpointNames() {
109
- for (const endpoint of this.endpoints) {
110
- endpoint.name = endpoint.name.toLowerCase();
111
- endpoint.aliases = endpoint.aliases?.map((a) => a.toLowerCase());
112
- }
113
- }
114
- /**
115
- * This function will take an adapter structure and go through each endpoint, calculating
116
- * each one's allocation of the total rate limits that are set for the adapter as a whole.
117
- *
118
- */
119
- calculateRateLimitAllocations() {
120
- const numberOfEndpoints = this.endpoints.length;
121
- const endpointsWithExplicitAllocations = this.endpoints.filter((e) => e.rateLimiting);
122
- const totalExplicitAllocation = endpointsWithExplicitAllocations
123
- .map((e) => e.rateLimiting?.allocationPercentage || 0)
124
- .reduce((sum, next) => sum + next, 0);
125
- if (totalExplicitAllocation > 100) {
126
- throw new Error('The total allocation set for all endpoints summed cannot exceed 100%');
127
- }
128
- if (totalExplicitAllocation === 100 &&
129
- numberOfEndpoints - endpointsWithExplicitAllocations.length > 0) {
130
- throw new Error('The explicit allocation is at 100% but there are endpoints with implicit allocation');
131
- }
132
- const implicitAllocation = 100 - totalExplicitAllocation;
133
- logger.debug('Adapter rate limit allocations:');
134
- for (const endpoint of this.endpoints) {
135
- if (!endpoint.rateLimiting) {
136
- endpoint.rateLimiting = {
137
- allocationPercentage: implicitAllocation / (numberOfEndpoints - endpointsWithExplicitAllocations.length),
138
- };
139
- }
140
- logger.debug(`Endpoint [${endpoint.name}] - ${endpoint.rateLimiting?.allocationPercentage}%`);
141
- }
142
- }
143
- /**
144
- * Creates a list of key/value pairs that need to be censored in the logs
145
- * using the sensitive flag in the adapter config
146
- */
147
- buildCensorList() {
148
- const censorList = Object.entries(config_1.BaseSettings)
149
- .concat(Object.entries(this.customSettings || {}))
150
- .filter(([name, setting]) => setting && setting.type === 'string' && setting.sensitive && this.config[name])
151
- .map(([name]) => ({
152
- key: name,
153
- // Escaping potential special characters in values before creating regex
154
- value: new RegExp(
155
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
156
- this.config[name].replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&')),
157
- }));
158
- censor_list_1.default.set(censorList);
159
- }
160
- /**
161
- * This function will process dependencies for an adapter, such as caches or rate limiters,
162
- * in order to inject them into transports and other relevant places later in the lifecycle.
163
- *
164
- * @param inputDependencies - a partial obj of initialized dependencies to override the created ones
165
- * @returns a set of AdapterDependencies all initialized
166
- */
167
- initializeDependencies(inputDependencies) {
168
- const dependencies = inputDependencies || {};
169
- if (!dependencies.redisClient) {
170
- if (this.config.CACHE_TYPE === 'redis') {
171
- dependencies.redisClient = new ioredis_1.default({
172
- enableAutoPipelining: true,
173
- host: this.config.CACHE_REDIS_HOST,
174
- port: this.config.CACHE_REDIS_PORT,
175
- password: this.config.CACHE_REDIS_PASSWORD,
176
- path: this.config.CACHE_REDIS_PATH,
177
- timeout: this.config.CACHE_REDIS_TIMEOUT,
178
- });
179
- dependencies.redisClient.on('connect', () => {
180
- cacheMetrics.redisConnectionsOpen.inc();
181
- });
182
- }
183
- }
184
- if (!dependencies.cache) {
185
- dependencies.cache = cache_1.CacheFactory.buildCache(this.config.CACHE_TYPE, dependencies.redisClient);
186
- }
187
- const rateLimitingTier = (0, rate_limiting_1.getRateLimitingTier)(this.config, this.rateLimiting?.tiers);
188
- if (!dependencies.requestRateLimiter) {
189
- dependencies.requestRateLimiter = new rate_limiting_1.SimpleCountingRateLimiter().initialize(this.endpoints, rateLimitingTier);
190
- }
191
- if (!dependencies.backgroundExecuteRateLimiter) {
192
- dependencies.backgroundExecuteRateLimiter = new rate_limiting_1.FixedFrequencyRateLimiter().initialize(this.endpoints, rateLimitingTier);
193
- }
194
- if (!dependencies.subscriptionSetFactory) {
195
- dependencies.subscriptionSetFactory = new util_1.SubscriptionSetFactory(this.config, dependencies.redisClient, this.name);
196
- }
197
- return dependencies;
198
- }
199
- }
200
- exports.Adapter = Adapter;
package/adapter.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"adapter.js","sourceRoot":"","sources":["../../src/adapter.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,sDAA2B;AAE3B,mCAA6C;AAC7C,qCAOiB;AACjB,mDAOwB;AAExB,iCAA2D;AAC3D,4EAAsE;AAEtE,8DAA+C;AAC/C,kEAA6D;AAE7D,MAAM,MAAM,GAAG,IAAA,iBAAU,EAAC,SAAS,CAAC,CAAA;AAkHpC,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;AAOD,MAAa,OAAO;IAwBlB,YAAY,MAAqC;QAZjD,uBAAuB;QACvB,gBAAW,GAAG,KAAK,CAAA;QAEnB,6DAA6D;QAC7D,iBAAY,GAAsE,EAAE,CAAA;QASlF,mBAAmB;QACnB,IAAI,CAAC,IAAI,GAAG,MAAM,CAAC,IAAI,C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ACF;QACD,IAAI,CAAC,YAAY,CAAC,4BAA4B,EAAE;YAC9C,YAAY,CAAC,4BAA4B,GAAG,IAAI,yCAAyB,EAAE,CAAC,UAAU,CACpF,IAAI,CAAC,SAAS,EACd,gBAAgB,CACjB,CAAA;SACF;QACD,IAAI,CAAC,YAAY,CAAC,sBAAsB,EAAE;YACxC,YAAY,CAAC,sBAAsB,GAAG,IAAI,6BAAsB,CAC9D,IAAI,CAAC,MAAM,EACX,YAAY,CAAC,WAAW,EACxB,IAAI,CAAC,IAAI,CACV,CAAA;SACF;QAED,OAAO,YAAmC,CAAA;IAC5C,CAAC;CACF;AA3MD,0BA2MC"}
@@ -1,7 +0,0 @@
1
- import { AdapterEndpoint } from '../../adapter';
2
- interface AdapterRequestParams {
3
- base: string;
4
- quote: string;
5
- }
6
- export declare const batchEndpoint: AdapterEndpoint<AdapterRequestParams, unknown, import("../../config").SettingsMap>;
7
- export {};