@chainlink/external-adapter-framework 0.3.7 → 0.4.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 (210) hide show
  1. package/README.md +102 -0
  2. package/package.json +42 -50
  3. package/adapter/basic.d.ts +0 -86
  4. package/adapter/basic.js +0 -323
  5. package/adapter/basic.js.map +0 -1
  6. package/adapter/endpoint.d.ts +0 -17
  7. package/adapter/endpoint.js +0 -19
  8. package/adapter/endpoint.js.map +0 -1
  9. package/adapter/index.d.ts +0 -4
  10. package/adapter/index.js +0 -21
  11. package/adapter/index.js.map +0 -1
  12. package/adapter/price.d.ts +0 -75
  13. package/adapter/price.js +0 -88
  14. package/adapter/price.js.map +0 -1
  15. package/adapter/types.d.ts +0 -118
  16. package/adapter/types.js +0 -3
  17. package/adapter/types.js.map +0 -1
  18. package/background-executor.d.ts +0 -9
  19. package/background-executor.js +0 -97
  20. package/background-executor.js.map +0 -1
  21. package/cache/factory.d.ts +0 -6
  22. package/cache/factory.js +0 -24
  23. package/cache/factory.js.map +0 -1
  24. package/cache/index.d.ts +0 -87
  25. package/cache/index.js +0 -133
  26. package/cache/index.js.map +0 -1
  27. package/cache/local.d.ts +0 -23
  28. package/cache/local.js +0 -84
  29. package/cache/local.js.map +0 -1
  30. package/cache/metrics.d.ts +0 -27
  31. package/cache/metrics.js +0 -121
  32. package/cache/metrics.js.map +0 -1
  33. package/cache/redis.d.ts +0 -16
  34. package/cache/redis.js +0 -101
  35. package/cache/redis.js.map +0 -1
  36. package/config/index.d.ts +0 -297
  37. package/config/index.js +0 -353
  38. package/config/index.js.map +0 -1
  39. package/config/provider-limits.d.ts +0 -27
  40. package/config/provider-limits.js +0 -75
  41. package/config/provider-limits.js.map +0 -1
  42. package/examples/bank-frick/accounts.d.ts +0 -52
  43. package/examples/bank-frick/accounts.js +0 -190
  44. package/examples/bank-frick/accounts.js.map +0 -1
  45. package/examples/bank-frick/config/index.d.ts +0 -17
  46. package/examples/bank-frick/config/index.js +0 -55
  47. package/examples/bank-frick/config/index.js.map +0 -1
  48. package/examples/bank-frick/index.d.ts +0 -16
  49. package/examples/bank-frick/index.js +0 -16
  50. package/examples/bank-frick/index.js.map +0 -1
  51. package/examples/bank-frick/util.d.ts +0 -4
  52. package/examples/bank-frick/util.js +0 -40
  53. package/examples/bank-frick/util.js.map +0 -1
  54. package/examples/coingecko/src/config/index.d.ts +0 -2
  55. package/examples/coingecko/src/config/index.js +0 -6
  56. package/examples/coingecko/src/config/index.js.map +0 -1
  57. package/examples/coingecko/src/config/overrides.json +0 -10825
  58. package/examples/coingecko/src/crypto-utils.d.ts +0 -48
  59. package/examples/coingecko/src/crypto-utils.js +0 -60
  60. package/examples/coingecko/src/crypto-utils.js.map +0 -1
  61. package/examples/coingecko/src/endpoint/coins.d.ts +0 -9
  62. package/examples/coingecko/src/endpoint/coins.js +0 -37
  63. package/examples/coingecko/src/endpoint/coins.js.map +0 -1
  64. package/examples/coingecko/src/endpoint/crypto-marketcap.d.ts +0 -3
  65. package/examples/coingecko/src/endpoint/crypto-marketcap.js +0 -30
  66. package/examples/coingecko/src/endpoint/crypto-marketcap.js.map +0 -1
  67. package/examples/coingecko/src/endpoint/crypto-volume.d.ts +0 -3
  68. package/examples/coingecko/src/endpoint/crypto-volume.js +0 -30
  69. package/examples/coingecko/src/endpoint/crypto-volume.js.map +0 -1
  70. package/examples/coingecko/src/endpoint/crypto.d.ts +0 -2
  71. package/examples/coingecko/src/endpoint/crypto.js +0 -28
  72. package/examples/coingecko/src/endpoint/crypto.js.map +0 -1
  73. package/examples/coingecko/src/endpoint/dominance.d.ts +0 -3
  74. package/examples/coingecko/src/endpoint/dominance.js +0 -28
  75. package/examples/coingecko/src/endpoint/dominance.js.map +0 -1
  76. package/examples/coingecko/src/endpoint/global-marketcap.d.ts +0 -3
  77. package/examples/coingecko/src/endpoint/global-marketcap.js +0 -28
  78. package/examples/coingecko/src/endpoint/global-marketcap.js.map +0 -1
  79. package/examples/coingecko/src/endpoint/index.d.ts +0 -6
  80. package/examples/coingecko/src/endpoint/index.js +0 -16
  81. package/examples/coingecko/src/endpoint/index.js.map +0 -1
  82. package/examples/coingecko/src/global-utils.d.ts +0 -27
  83. package/examples/coingecko/src/global-utils.js +0 -47
  84. package/examples/coingecko/src/global-utils.js.map +0 -1
  85. package/examples/coingecko/src/index.d.ts +0 -4
  86. package/examples/coingecko/src/index.js +0 -19
  87. package/examples/coingecko/src/index.js.map +0 -1
  88. package/examples/coingecko-old/batch-warming.d.ts +0 -7
  89. package/examples/coingecko-old/batch-warming.js +0 -54
  90. package/examples/coingecko-old/batch-warming.js.map +0 -1
  91. package/examples/coingecko-old/index.d.ts +0 -2
  92. package/examples/coingecko-old/index.js +0 -12
  93. package/examples/coingecko-old/index.js.map +0 -1
  94. package/examples/coingecko-old/rest.d.ts +0 -12
  95. package/examples/coingecko-old/rest.js +0 -55
  96. package/examples/coingecko-old/rest.js.map +0 -1
  97. package/examples/cryptocompare/src/config/index.d.ts +0 -2
  98. package/examples/cryptocompare/src/config/index.js +0 -6
  99. package/examples/cryptocompare/src/config/index.js.map +0 -1
  100. package/examples/cryptocompare/src/endpoints/crypto.d.ts +0 -28
  101. package/examples/cryptocompare/src/endpoints/crypto.js +0 -54
  102. package/examples/cryptocompare/src/endpoints/crypto.js.map +0 -1
  103. package/examples/cryptocompare/src/endpoints/index.d.ts +0 -1
  104. package/examples/cryptocompare/src/endpoints/index.js +0 -6
  105. package/examples/cryptocompare/src/endpoints/index.js.map +0 -1
  106. package/examples/cryptocompare/src/index.d.ts +0 -4
  107. package/examples/cryptocompare/src/index.js +0 -14
  108. package/examples/cryptocompare/src/index.js.map +0 -1
  109. package/examples/genesis/config/index.d.ts +0 -7
  110. package/examples/genesis/config/index.js +0 -11
  111. package/examples/genesis/config/index.js.map +0 -1
  112. package/examples/genesis/index.d.ts +0 -2
  113. package/examples/genesis/index.js +0 -13
  114. package/examples/genesis/index.js.map +0 -1
  115. package/examples/genesis/sseStream.d.ts +0 -16
  116. package/examples/genesis/sseStream.js +0 -149
  117. package/examples/genesis/sseStream.js.map +0 -1
  118. package/examples/ncfx/config/index.d.ts +0 -12
  119. package/examples/ncfx/config/index.js +0 -16
  120. package/examples/ncfx/config/index.js.map +0 -1
  121. package/examples/ncfx/index.d.ts +0 -13
  122. package/examples/ncfx/index.js +0 -12
  123. package/examples/ncfx/index.js.map +0 -1
  124. package/examples/ncfx/websocket.d.ts +0 -47
  125. package/examples/ncfx/websocket.js +0 -74
  126. package/examples/ncfx/websocket.js.map +0 -1
  127. package/index.d.ts +0 -17
  128. package/index.js +0 -174
  129. package/index.js.map +0 -1
  130. package/metrics/constants.d.ts +0 -16
  131. package/metrics/constants.js +0 -26
  132. package/metrics/constants.js.map +0 -1
  133. package/metrics/index.d.ts +0 -19
  134. package/metrics/index.js +0 -139
  135. package/metrics/index.js.map +0 -1
  136. package/metrics/util.d.ts +0 -7
  137. package/metrics/util.js +0 -10
  138. package/metrics/util.js.map +0 -1
  139. package/rate-limiting/background/fixed-frequency.d.ts +0 -11
  140. package/rate-limiting/background/fixed-frequency.js +0 -36
  141. package/rate-limiting/background/fixed-frequency.js.map +0 -1
  142. package/rate-limiting/index.d.ts +0 -56
  143. package/rate-limiting/index.js +0 -86
  144. package/rate-limiting/index.js.map +0 -1
  145. package/rate-limiting/metrics.d.ts +0 -3
  146. package/rate-limiting/metrics.js +0 -45
  147. package/rate-limiting/metrics.js.map +0 -1
  148. package/rate-limiting/request/simple-counting.d.ts +0 -21
  149. package/rate-limiting/request/simple-counting.js +0 -63
  150. package/rate-limiting/request/simple-counting.js.map +0 -1
  151. package/transports/batch-warming.d.ts +0 -35
  152. package/transports/batch-warming.js +0 -138
  153. package/transports/batch-warming.js.map +0 -1
  154. package/transports/index.d.ts +0 -87
  155. package/transports/index.js +0 -56
  156. package/transports/index.js.map +0 -1
  157. package/transports/metrics.d.ts +0 -25
  158. package/transports/metrics.js +0 -122
  159. package/transports/metrics.js.map +0 -1
  160. package/transports/rest.d.ts +0 -51
  161. package/transports/rest.js +0 -133
  162. package/transports/rest.js.map +0 -1
  163. package/transports/routing.d.ts +0 -23
  164. package/transports/routing.js +0 -52
  165. package/transports/routing.js.map +0 -1
  166. package/transports/sse.d.ts +0 -40
  167. package/transports/sse.js +0 -92
  168. package/transports/sse.js.map +0 -1
  169. package/transports/util.d.ts +0 -9
  170. package/transports/util.js +0 -87
  171. package/transports/util.js.map +0 -1
  172. package/transports/websocket.d.ts +0 -81
  173. package/transports/websocket.js +0 -165
  174. package/transports/websocket.js.map +0 -1
  175. package/util/censor/censor-list.d.ts +0 -9
  176. package/util/censor/censor-list.js +0 -13
  177. package/util/censor/censor-list.js.map +0 -1
  178. package/util/index.d.ts +0 -13
  179. package/util/index.js +0 -38
  180. package/util/index.js.map +0 -1
  181. package/util/logger.d.ts +0 -49
  182. package/util/logger.js +0 -123
  183. package/util/logger.js.map +0 -1
  184. package/util/request.d.ts +0 -102
  185. package/util/request.js +0 -3
  186. package/util/request.js.map +0 -1
  187. package/util/subscription-set/expiring-sorted-set.d.ts +0 -21
  188. package/util/subscription-set/expiring-sorted-set.js +0 -36
  189. package/util/subscription-set/expiring-sorted-set.js.map +0 -1
  190. package/util/subscription-set/redis-sorted-set.d.ts +0 -9
  191. package/util/subscription-set/redis-sorted-set.js +0 -29
  192. package/util/subscription-set/redis-sorted-set.js.map +0 -1
  193. package/util/subscription-set/subscription-set.d.ts +0 -19
  194. package/util/subscription-set/subscription-set.js +0 -28
  195. package/util/subscription-set/subscription-set.js.map +0 -1
  196. package/util/test-payload-loader.d.ts +0 -26
  197. package/util/test-payload-loader.js +0 -85
  198. package/util/test-payload-loader.js.map +0 -1
  199. package/validation/error.d.ts +0 -48
  200. package/validation/error.js +0 -78
  201. package/validation/error.js.map +0 -1
  202. package/validation/index.d.ts +0 -5
  203. package/validation/index.js +0 -91
  204. package/validation/index.js.map +0 -1
  205. package/validation/input-params.d.ts +0 -14
  206. package/validation/input-params.js +0 -3
  207. package/validation/input-params.js.map +0 -1
  208. package/validation/input-validator.d.ts +0 -16
  209. package/validation/input-validator.js +0 -123
  210. package/validation/input-validator.js.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"file":"basic.js","sourceRoot":"","sources":["../../../src/adapter/basic.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,sDAA2B;AAC3B,oCAAyF;AACzF,+DAAgD;AAChD,sCAMkB;AAClB,wEAAyD;AACzD,oDAIyB;AACzB,kCAA6F;AAC7F,6EAAuE;AAUvE,+CAAyD;AAEzD,MAAM,MAAM,GAAG,IAAA,iBAAU,EAAC,SAAS,CAAC,CAAA;AAEpC;;GAEG;AACH,MAAa,OAAO;IA4BlB,YAAY,MAAqC;QAfjD,uBAAuB;QACvB,gBAAW,GAAG,KAAK,CAAA;QAEnB,6DAA6D;QAC7D,iBAAY,GAAsE,EAAE,CAAA;QAYlF,mBAAmB;QACnB,IAAI,CAAC,IAAI,GAAG,MAAM,CAAC,IAAI,CAAA;QACvB,IAAI,CAAC,eAAe,GAAG,MAAM,CAAC,eAAe,EAAE,WAAW,EAAE,CAAA;QAC5D,IAAI,CAAC,SAAS,GAAG,MAAM,CAAC,SAAS,CAAA;QACjC,IAAI,CAAC,mBAAmB,GAAG,MAAM,CAAC,mBAAmB,CAAA;QACrD,IAAI,CAAC,cAAc,GAAG,MAAM,CAAC,cAAc,CAAA;QAC3C,IAAI,CAAC,YAAY,GAAG,MAAM,CAAC,YAAY,CAAA;QACvC,IAAI,CAAC,SAAS,GAAG,MAAM,CAAC,SAAS,CAAA;QACjC,IAAI,CAAC,iBAAiB,GAAG,CAAC,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,iBAAiB,IAAI,EAAE,CAAC,CAAC,CAAA;QAC/F,IAAI,CAAC,SAAS,GAAG,MAAM,CAAC,SAAS,CAAA;QAEjC,IAAI,CAAC,MAAM,GAAG,IAAA,2B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AAE,SAAS,EAAE,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAA;QAE/C,IAAI,QAAQ,EAAE;YACZ,MAAM,CAAC,KAAK,CAAC,0DAA0D,CAAC,CAAA;YACxE,OAAO,QAAQ,CAAA;SAChB;QAED,sDAAsD;QACtD,gBAAgB,CAAC,4BAA4B;aAC1C,MAAM,CAAC,EAAE,QAAQ,EAAE,GAAG,CAAC,cAAc,CAAC,YAAY,EAAE,CAAC;aACrD,GAAG,EAAE,CAAA;QAER,MAAM,CAAC,KAAK,CAAC,gDAAgD,CAAC,CAAA;QAC9D,MAAM,IAAI,2BAAmB,CAAC;YAC5B,OAAO,EAAE,wCAAwC;YACjD,UAAU,EAAE,GAAG;SAChB,CAAC,CAAA;IACJ,CAAC;CACF;AArYD,0BAqYC"}
@@ -1,17 +0,0 @@
1
- import { SettingsMap } from '../config';
2
- import { MetaTransport, Transport } from '../transports';
3
- import { InputParameters } from '../validation';
4
- import { AdapterEndpointParams, EndpointRateLimitingConfig } from './types';
5
- import { InputValidator } from '../validation/input-validator';
6
- /**
7
- * Main class to represent an endpoint within an External Adapter
8
- */
9
- export declare class AdapterEndpoint<Params, Result, CustomSettings extends SettingsMap> implements AdapterEndpointParams<Params, Result, CustomSettings> {
10
- name: string;
11
- aliases?: string[] | undefined;
12
- transport: Transport<Params, Result, CustomSettings> | MetaTransport<Params, Result, CustomSettings>;
13
- inputParameters: InputParameters;
14
- rateLimiting?: EndpointRateLimitingConfig | undefined;
15
- validator: InputValidator;
16
- constructor(params: AdapterEndpointParams<Params, Result, CustomSettings>);
17
- }
@@ -1,19 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AdapterEndpoint = void 0;
4
- const input_validator_1 = require("../validation/input-validator");
5
- /**
6
- * Main class to represent an endpoint within an External Adapter
7
- */
8
- class AdapterEndpoint {
9
- constructor(params) {
10
- this.name = params.name;
11
- this.aliases = params.aliases;
12
- this.transport = params.transport;
13
- this.inputParameters = params.inputParameters;
14
- this.rateLimiting = params.rateLimiting;
15
- this.validator = new input_validator_1.InputValidator(this.inputParameters);
16
- }
17
- }
18
- exports.AdapterEndpoint = AdapterEndpoint;
19
- //# sourceMappingURL=endpoint.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"endpoint.js","sourceRoot":"","sources":["../../../src/adapter/endpoint.ts"],"names":[],"mappings":";;;AAIA,mEAA8D;AAE9D;;GAEG;AACH,MAAa,eAAe;IAY1B,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;AApBD,0CAoBC"}
@@ -1,4 +0,0 @@
1
- export * from './basic';
2
- export * from './price';
3
- export * from './endpoint';
4
- export * from './types';
package/adapter/index.js DELETED
@@ -1,21 +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 __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./basic"), exports);
18
- __exportStar(require("./price"), exports);
19
- __exportStar(require("./endpoint"), exports);
20
- __exportStar(require("./types"), exports);
21
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/adapter/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0CAAuB;AACvB,0CAAuB;AACvB,6CAA0B;AAC1B,0CAAuB"}
@@ -1,75 +0,0 @@
1
- import { SettingsMap } from '../config';
2
- import { AdapterRequest, AdapterRequestContext, AdapterResponse } from '../util';
3
- import { AdapterEndpoint } from './endpoint';
4
- import { Adapter, AdapterEndpointParams, AdapterParams } from './index';
5
- /**
6
- * Type for the base input parameter config that any [[PriceEndpoint]] must extend
7
- */
8
- export declare type PriceEndpointInputParameters = {
9
- base: {
10
- aliases: readonly ['from', 'coin', ...string[]];
11
- type: 'string';
12
- description: 'The symbol of symbols of the currency to query';
13
- required: boolean;
14
- };
15
- quote: {
16
- aliases: readonly ['to', 'market', ...string[]];
17
- type: 'string';
18
- description: 'The symbol of the currency to convert to';
19
- required: boolean;
20
- };
21
- };
22
- /**
23
- * Base input parameter config that any [[PriceEndpoint]] must extend
24
- */
25
- export declare const priceEndpointInputParameters: PriceEndpointInputParameters;
26
- /**
27
- * Type for base input params for a PriceEndpoint
28
- */
29
- export declare type PriceEndpointParams = {
30
- base: string;
31
- quote: string;
32
- };
33
- /**
34
- * Structure of an "includes" file.
35
- * Include pairs describe an incoming price feed request, and the details specify
36
- */
37
- export declare type IncludesFile = IncludePair[];
38
- declare type IncludeDetails = {
39
- from: string;
40
- to: string;
41
- inverse: boolean;
42
- };
43
- declare type IncludePair = {
44
- from: string;
45
- to: string;
46
- includes: IncludeDetails[];
47
- };
48
- declare type IncludesMap = Record<string, Record<string, IncludeDetails>>;
49
- /**
50
- * A PriceEndpoint is a specific type of AdapterEndpoint. Meant to comply with standard practices for
51
- * Data Feeds, its InputParameters must extend the basic ones (base/quote).
52
- */
53
- export declare class PriceEndpoint<Params extends PriceEndpointParams, ProviderResponseBody, CustomSettings extends SettingsMap> extends AdapterEndpoint<Params, ProviderResponseBody, CustomSettings> {
54
- constructor(params: AdapterEndpointParams<Params, ProviderResponseBody, CustomSettings> & {
55
- inputParameters: PriceEndpointInputParameters;
56
- });
57
- }
58
- declare type PriceAdapterRequest<T> = AdapterRequest<T> & {
59
- requestContext: AdapterRequestContext<T> & {
60
- priceMeta: {
61
- inverse: boolean;
62
- };
63
- };
64
- };
65
- /**
66
- * A PriceAdapter is a specific kind of Adapter that includes at least one PriceEnpoint.
67
- */
68
- export declare class PriceAdapter<CustomSettings extends SettingsMap> extends Adapter<CustomSettings> {
69
- includesMap?: IncludesMap;
70
- constructor(params: AdapterParams<CustomSettings> & {
71
- includes?: IncludesFile;
72
- });
73
- handleRequest(req: PriceAdapterRequest<PriceEndpointParams>, replySent: Promise<unknown>): Promise<AdapterResponse>;
74
- }
75
- export {};
package/adapter/price.js DELETED
@@ -1,88 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PriceAdapter = exports.PriceEndpoint = exports.priceEndpointInputParameters = void 0;
4
- const endpoint_1 = require("./endpoint");
5
- const index_1 = require("./index");
6
- /**
7
- * Base input parameter config that any [[PriceEndpoint]] must extend
8
- */
9
- exports.priceEndpointInputParameters = {
10
- base: {
11
- aliases: ['from', 'coin'],
12
- type: 'string',
13
- description: 'The symbol of symbols of the currency to query',
14
- required: true,
15
- },
16
- quote: {
17
- aliases: ['to', 'market'],
18
- type: 'string',
19
- description: 'The symbol of the currency to convert to',
20
- required: true,
21
- },
22
- };
23
- /**
24
- * A PriceEndpoint is a specific type of AdapterEndpoint. Meant to comply with standard practices for
25
- * Data Feeds, its InputParameters must extend the basic ones (base/quote).
26
- */
27
- class PriceEndpoint extends endpoint_1.AdapterEndpoint {
28
- constructor(params) {
29
- super(params);
30
- }
31
- }
32
- exports.PriceEndpoint = PriceEndpoint;
33
- const buildIncludesMap = (includesFile) => {
34
- const includesMap = {};
35
- for (const { from, to, includes } of includesFile) {
36
- if (!includesMap[from]) {
37
- includesMap[from] = {};
38
- }
39
- includesMap[from][to] = includes[0];
40
- }
41
- return includesMap;
42
- };
43
- /**
44
- * A PriceAdapter is a specific kind of Adapter that includes at least one PriceEnpoint.
45
- */
46
- class PriceAdapter extends index_1.Adapter {
47
- constructor(params) {
48
- // Doing this with types would be too complex to maintain
49
- if (!params.endpoints.some((e) => e instanceof PriceEndpoint)) {
50
- throw new Error(`This PriceAdapter's list of endpoints does not contain a valid PriceEndpoint`);
51
- }
52
- super(params);
53
- if (params.includes) {
54
- // Build includes map for constant lookups
55
- this.includesMap = buildIncludesMap(params.includes);
56
- const requestTransform = (req) => {
57
- const priceRequest = req;
58
- const requestData = priceRequest.requestContext.data;
59
- const includesDetails = this.includesMap?.[requestData.base]?.[requestData.quote];
60
- if (includesDetails) {
61
- requestData.base = includesDetails.from || requestData.base;
62
- requestData.quote = includesDetails.to || requestData.quote;
63
- }
64
- const inverse = includesDetails?.inverse || false;
65
- priceRequest.requestContext.priceMeta = {
66
- inverse,
67
- };
68
- };
69
- this.requestTransforms?.push(requestTransform);
70
- }
71
- }
72
- async handleRequest(req, replySent) {
73
- const response = await super.handleRequest(req, replySent);
74
- if (this.includesMap && req.requestContext.priceMeta.inverse) {
75
- // We need to search in the reverse order (quote -> base) because the request transform will have inverted the pair
76
- const inverseResult = 1 / response.result;
77
- response.result = inverseResult;
78
- // Check if response data has a result within it
79
- const data = response.data;
80
- if (data?.result) {
81
- data.result = inverseResult;
82
- }
83
- }
84
- return response;
85
- }
86
- }
87
- exports.PriceAdapter = PriceAdapter;
88
- //# sourceMappingURL=price.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"price.js","sourceRoot":"","sources":["../../../src/adapter/price.ts"],"names":[],"mappings":";;;AAEA,yCAA4C;AAC5C,mCAAuE;AAo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aAAa,CAAA;aAC5B;SACF;QAED,OAAO,QAAQ,CAAA;IACjB,CAAC;CACF;AA5DD,oCA4DC"}
@@ -1,118 +0,0 @@
1
- import Redis from 'ioredis';
2
- import { AdapterEndpoint } from './endpoint';
3
- import { CustomSettingsType, SettingsMap, AdapterConfig, BaseAdapterConfig } from '../config';
4
- import { RequestRateLimiter, BackgroundExecuteRateLimiter, AdapterRateLimitTier } from '../rate-limiting';
5
- import { Transport } from '../transports';
6
- import { AdapterRequest, SubscriptionSetFactory } from '../util';
7
- import { InputParameters } from '../validation';
8
- import { Cache } from '../cache';
9
- import type EventSource from 'eventsource';
10
- import { Adapter } from './basic';
11
- export declare type CustomAdapterSettings = SettingsMap & NegatedAdapterSettings;
12
- declare type NegatedAdapterSettings = {
13
- [K in keyof BaseAdapterConfig]?: never;
14
- };
15
- /**
16
- * Dependencies that will be injected into the Adapter on startup
17
- */
18
- export interface AdapterDependencies {
19
- /** Specific instance of the Cache the adapter will use (e.g. Local, Redis, etc.) */
20
- cache: Cache;
21
- /** Shared instance of the request rate limiter */
22
- requestRateLimiter: RequestRateLimiter;
23
- /** Shared instance of the background execute rate limiter */
24
- backgroundExecuteRateLimiter: BackgroundExecuteRateLimiter;
25
- /** Factory to create subscription sets based on the specified cache type */
26
- subscriptionSetFactory: SubscriptionSetFactory;
27
- /** Redis client used for cache and subscription set */
28
- redisClient: Redis;
29
- /** EventSource to use for listening to server sent events. A mock EventSource can be provided as a dependency for testing */
30
- eventSource: typeof EventSource;
31
- }
32
- /**
33
- * Context that will be used on background executions of a Transport.
34
- * For example, the endpointName used to log statements or generate Cache keys.
35
- */
36
- export interface AdapterContext<CustomSettings extends CustomSettingsType<CustomSettings> = SettingsMap> {
37
- /** Endpoint instance within the adapter that the Transport is related to */
38
- adapterEndpoint: AdapterEndpoint<unknown, unknown, CustomSettings>;
39
- /** Initialized config for the adapter that the Transport can access */
40
- adapterConfig: AdapterConfig<CustomSettings>;
41
- }
42
- /**
43
- * Structure to describe rate limits specs for the Adapter
44
- */
45
- export interface AdapterRateLimitingConfig {
46
- /** Adapter rate limits, gotten from the specific tier requested */
47
- tiers: Record<string, AdapterRateLimitTier>;
48
- }
49
- /**
50
- * Type to perform arbitrary modifications on an adapter request
51
- */
52
- export declare type RequestTransform = (req: AdapterRequest) => void;
53
- /**
54
- * Map of overrides objects (symbol -\> symbol) per adapter name
55
- */
56
- export declare type Overrides = {
57
- [adapterName: string]: {
58
- [symbol: string]: string;
59
- };
60
- };
61
- /**
62
- * Main structure of an External Adapter
63
- */
64
- export interface AdapterParams<CustomSettings extends SettingsMap> {
65
- /** Name of the adapter */
66
- name: string;
67
- /** If present, the string that will be used for requests with no specified endpoint */
68
- defaultEndpoint?: string;
69
- /**
70
- * List of [[AdapterEndpoint]]s in the adapter. This is purposefully typed any; it's the correct type in this case.
71
- *
72
- * When you try to create an adapter and you provide an endpoint, if these generics were set to "unknown" instead
73
- * what would happen is that Typescript would check if the types match, and would fail to assign unknown to the
74
- * specific Params or Result in the transport itself.
75
- * We also can't use generics, because if we had more than one transport with different requests (very likely)
76
- * then those new types wouldn't match with each other.
77
- */
78
- endpoints: AdapterEndpoint<any, any, CustomSettings>[];
79
- /** Map of overrides to the default config values for an Adapter */
80
- envDefaultOverrides?: Partial<BaseAdapterConfig>;
81
- /** List of custom env vars for this particular adapter (e.g. RPC_URL) */
82
- customSettings?: SettingsMap;
83
- /** Configuration relevant to outbound (EA --\> DP) communication rate limiting */
84
- rateLimiting?: AdapterRateLimitingConfig;
85
- /** Overrides for converting the 'base' parameter that are hardcoded into the adapter. */
86
- overrides?: Record<string, string>;
87
- /** Transforms that will apply to the request before submitting it through the adapter request flow */
88
- requestTransforms?: RequestTransform[];
89
- /** Bootstrap function that will run when initializing the adapter */
90
- bootstrap?: (adapter: Adapter<CustomSettings>) => Promise<void>;
91
- }
92
- /**
93
- * Structure to describe rate limits specs for a specific adapter endpoint
94
- */
95
- export interface EndpointRateLimitingConfig {
96
- /**
97
- * How much of the total limit for the adapter will be assigned to this specific endpoint.
98
- * Should be a non-zero positive number up to 100.
99
- * Endpoints in the same adapter without a specific allocation will divide the remaining limits equally.
100
- */
101
- allocationPercentage: number;
102
- }
103
- /**
104
- * Structure to describe a specific endpoint in an [[Adapter]]
105
- */
106
- export interface AdapterEndpointParams<Params, Result, CustomSettings extends SettingsMap> {
107
- /** Name that will be used to match input params to this endpoint (case insensitive) */
108
- name: string;
109
- /** List of alternative endpoint names that will resolve to this same transport (case insensitive) */
110
- aliases?: string[];
111
- /** Transport that will be used to handle data processing and communication for this endpoint */
112
- transport: Transport<Params, Result, CustomSettings>;
113
- /** Specification of what the body of a request hitting this endpoint should look like (used for validation) */
114
- inputParameters: InputParameters;
115
- /** Specific details related to the rate limiting for this endpoint in particular */
116
- rateLimiting?: EndpointRateLimitingConfig;
117
- }
118
- export {};
package/adapter/types.js DELETED
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/adapter/types.ts"],"names":[],"mappings":""}
@@ -1,9 +0,0 @@
1
- import { Adapter } from './adapter';
2
- /**
3
- * Very simple background loop that will call the [[Transport.backgroundExecute]] functions in all Transports.
4
- * It gets the time in ms to wait as the return value from those functions, and sleeps until next execution.
5
- *
6
- * @param adapter - an initialized External Adapter
7
- * @param server - the http server to attach an on close listener to
8
- */
9
- export declare function callBackgroundExecutes(adapter: Adapter, apiShutdownPromise?: Promise<void>): Promise<void>;
@@ -1,97 +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
- Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.callBackgroundExecutes = void 0;
27
- const util_1 = require("./util");
28
- const metrics = __importStar(require("./metrics"));
29
- const logger = (0, util_1.makeLogger)('BackgroundExecutor');
30
- /**
31
- * Very simple background loop that will call the [[Transport.backgroundExecute]] functions in all Transports.
32
- * It gets the time in ms to wait as the return value from those functions, and sleeps until next execution.
33
- *
34
- * @param adapter - an initialized External Adapter
35
- * @param server - the http server to attach an on close listener to
36
- */
37
- async function callBackgroundExecutes(adapter, apiShutdownPromise) {
38
- // Set up variable to check later on to see if we need to stop this background "thread"
39
- // If no server is provided, the listener won't be set and serverClosed will always be false
40
- let serverClosed = false;
41
- const timeoutsMap = {};
42
- apiShutdownPromise?.then(() => {
43
- serverClosed = true;
44
- for (const endpointName in timeoutsMap) {
45
- logger.debug(`Clearing timeout for endpoint "${endpointName}"`);
46
- timeoutsMap[endpointName].unref();
47
- clearTimeout(timeoutsMap[endpointName]);
48
- }
49
- });
50
- // Checks if an individual transport has a backgroundExecute function, and executes it if it does
51
- const callBackgroundExecute = (endpoint, transport) => {
52
- const backgroundExecute = transport.backgroundExecute?.bind(transport);
53
- if (!backgroundExecute) {
54
- logger.debug(`Endpoint "${endpoint.name}" has no background execute, skipping...`);
55
- return;
56
- }
57
- const context = {
58
- adapterEndpoint: endpoint,
59
- adapterConfig: adapter.config,
60
- };
61
- const handler = async () => {
62
- if (serverClosed) {
63
- logger.info('Server closed, stopping recursive backgroundExecute handler chain');
64
- return;
65
- }
66
- // Count number of background executions per endpoint
67
- metrics.bgExecuteTotal.labels({ endpoint: endpoint.name }).inc();
68
- // Time the duration of the background execute process excluding sleep time
69
- const metricsTimer = metrics.bgExecuteDurationSeconds
70
- .labels({ endpoint: endpoint.name })
71
- .startTimer();
72
- logger.debug(`Calling background execute for endpoint "${endpoint.name}"`);
73
- const timeToWait = await backgroundExecute(context);
74
- logger.debug(`Finished background execute for endpoint "${endpoint.name}", sleeping for ${timeToWait}ms`);
75
- metricsTimer();
76
- timeoutsMap[endpoint.name] = setTimeout(handler, timeToWait);
77
- };
78
- // Start recursive async calls
79
- handler();
80
- };
81
- for (const endpoint of adapter.endpoints) {
82
- const { transport } = endpoint;
83
- // Check if transport is a MetaTransport by casting and checking a known property (transports)
84
- const castMeta = transport;
85
- if (castMeta.transports) {
86
- logger.debug(`Encountered MetaTransport ${transport.constructor.name}, calling backgroundExecute on all transports`);
87
- for (const nestedTransport of Object.values(castMeta.transports)) {
88
- callBackgroundExecute(endpoint, nestedTransport);
89
- }
90
- }
91
- else {
92
- callBackgroundExecute(endpoint, transport);
93
- }
94
- }
95
- }
96
- exports.callBackgroundExecutes = callBackgroundExecutes;
97
- //# sourceMappingURL=background-executor.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"background-executor.js","sourceRoot":"","sources":["../../src/background-executor.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AACA,iCAAmC;AACnC,mDAAoC;AAIpC,MAAM,MAAM,GAAG,IAAA,iBAAU,EAAC,oBAAoB,CAAC,CAAA;AAE/C;;;;;;GAMG;AACI,KAAK,UAAU,sBAAsB,CAAC,OAAgB,EAAE,kBAAkC;IAC/F,uFAAuF;IACvF,4FAA4F;IAC5F,IAAI,YAAY,GAAG,KAAK,CAAA;IACxB,MAAM,WAAW,GAEb,EAAE,CAAA;IAEN,kBAAkB,EAAE,IAA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AAC,CAAA;YACnD,MAAM,CAAC,KAAK,CACV,6CAA6C,QAAQ,CAAC,IAAI,mBAAmB,UAAU,IAAI,CAC5F,CAAA;YAED,YAAY,EAAE,CAAA;YACd,WAAW,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,UAAU,CAAC,OAAO,EAAE,UAAU,CAAC,CAAA;QAC9D,CAAC,CAAA;QAED,8BAA8B;QAC9B,OAAO,EAAE,CAAA;IACX,CAAC,CAAA;IAED,KAAK,MAAM,QAAQ,IAAI,OAAO,CAAC,SAAS,EAAE;QACxC,MAAM,EAAE,SAAS,EAAE,GAAG,QAAQ,CAAA;QAE9B,8FAA8F;QAC9F,MAAM,QAAQ,GAAG,SAAyD,CAAA;QAC1E,IAAI,QAAQ,CAAC,UAAU,EAAE;YACvB,MAAM,CAAC,KAAK,CACV,6BAA6B,SAAS,CAAC,WAAW,CAAC,IAAI,+CAA+C,CACvG,CAAA;YACD,KAAK,MAAM,eAAe,IAAI,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE;gBAChE,qBAAqB,CAAC,QAAQ,EAAE,eAAe,CAAC,CAAA;aACjD;SACF;aAAM;YACL,qBAAqB,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAA;SAC3C;KACF;AACH,CAAC;AA5ED,wDA4EC"}
@@ -1,6 +0,0 @@
1
- import Redis from 'ioredis';
2
- import { LocalCache } from './local';
3
- import { RedisCache } from './redis';
4
- export declare class CacheFactory {
5
- static buildCache(cacheType: string, redisClient?: Redis): LocalCache<unknown> | RedisCache<unknown> | undefined;
6
- }
package/cache/factory.js DELETED
@@ -1,24 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CacheFactory = void 0;
4
- const util_1 = require("../util");
5
- const local_1 = require("./local");
6
- const redis_1 = require("./redis");
7
- const logger = (0, util_1.makeLogger)('CacheFactory');
8
- class CacheFactory {
9
- static buildCache(cacheType, redisClient) {
10
- logger.info(`Using "${cacheType}" cache.`);
11
- switch (cacheType) {
12
- case 'local':
13
- return new local_1.LocalCache();
14
- case 'redis': {
15
- if (!redisClient) {
16
- throw new Error('Redis client undefined. Cannot create Redis cache');
17
- }
18
- return new redis_1.RedisCache(redisClient);
19
- }
20
- }
21
- }
22
- }
23
- exports.CacheFactory = CacheFactory;
24
- //# sourceMappingURL=factory.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"factory.js","sourceRoot":"","sources":["../../../src/cache/factory.ts"],"names":[],"mappings":";;;AACA,kCAAoC;AACpC,mCAAoC;AACpC,mCAAoC;AAEpC,MAAM,MAAM,GAAG,IAAA,iBAAU,EAAC,cAAc,CAAC,CAAA;AACzC,MAAa,YAAY;IACvB,MAAM,CAAC,UAAU,CAAC,SAAiB,EAAE,WAAmB;QACtD,MAAM,CAAC,IAAI,CAAC,UAAU,SAAS,UAAU,CAAC,CAAA;QAC1C,QAAQ,SAAS,EAAE;YACjB,KAAK,OAAO;gBACV,OAAO,IAAI,kBAAU,EAAE,CAAA;YACzB,KAAK,OAAO,CAAC,CAAC;gBACZ,IAAI,CAAC,WAAW,EAAE;oBAChB,MAAM,IAAI,KAAK,CAAC,mDAAmD,CAAC,CAAA;iBACrE;gBACD,OAAO,IAAI,kBAAU,CAAC,WAAW,CAAC,CAAA;aACnC;SACF;IACH,CAAC;CACF;AAdD,oCAcC"}
package/cache/index.d.ts DELETED
@@ -1,87 +0,0 @@
1
- import { AdapterEndpoint } from '../adapter';
2
- import { AdapterConfig, SettingsMap } from '../config';
3
- import { AdapterResponse, sleep } from '../util';
4
- export * from './factory';
5
- export * from './local';
6
- export * from './redis';
7
- /**
8
- * An object describing an entry in the cache.
9
- * @typeParam T - the type of the entry's value
10
- */
11
- export interface CacheEntry<T> {
12
- key: string;
13
- value: T;
14
- }
15
- /**
16
- * Generic interface for a local or remote Cache.
17
- * @typeParam T - the type of the cache entries' values
18
- */
19
- export interface Cache<T = unknown> {
20
- /**
21
- * Gets an item from the Cache.
22
- *
23
- * @param key - the key of the desired entry for which to fetch its value
24
- * @returns a Promise of the entry's value, or undefined if not found / expired.
25
- */
26
- get: (key: string) => Promise<T | undefined>;
27
- /**
28
- * Sets an item in the Cache.
29
- *
30
- * @param key - the key of the new entry
31
- * @param value - the value of the new entry
32
- * @param ttl - the time in milliseconds until the entry expires
33
- * @returns an empty Promise that resolves when the entry has been set
34
- */
35
- set: (key: string, value: T, ttl: number) => Promise<void>;
36
- /**
37
- * Sets a list of items in the Cache.
38
- *
39
- * @param entries - a list of cache entries
40
- * @param ttl - the time in milliseconds until the entries expire
41
- * @returns an empty Promise that resolves when all entries have been set
42
- */
43
- setMany: (entries: CacheEntry<T>[], ttl: number) => Promise<void>;
44
- /**
45
- * Deletes the specified item from the Cache
46
- *
47
- * @param key - the key of the entry to be deleted
48
- * @returns an empty Promise that resolves when the entry has been deleted
49
- */
50
- delete: (key: string) => Promise<void>;
51
- }
52
- export declare const calculateCacheKey: <Params, Result, CustomSettings extends SettingsMap>({ adapterEndpoint, adapterConfig, }: {
53
- adapterEndpoint: AdapterEndpoint<Params, Result, CustomSettings>;
54
- adapterConfig: AdapterConfig<CustomSettings>;
55
- }, data: unknown) => string;
56
- export declare const calculateFeedId: <Params, Result, CustomSettings extends SettingsMap>({ adapterEndpoint, adapterConfig, }: {
57
- adapterEndpoint: AdapterEndpoint<Params, Result, CustomSettings>;
58
- adapterConfig: AdapterConfig<CustomSettings>;
59
- }, data: unknown) => string;
60
- /**
61
- * Calculates a unique key from the provided data.
62
- *
63
- * @param data - the request data/body, i.e. the adapter input params
64
- * @param paramNames - the keys from adapter endpoint input parameters
65
- * @returns the calculated unique key
66
- *
67
- * @example
68
- * ```
69
- * calculateKey({ base: 'ETH', quote: 'BTC' }, ['base','quote'])
70
- * // equals `|base:eth|quote:btc`
71
- * ```
72
- */
73
- export declare const calculateKey: <CustomSettings extends SettingsMap>(data: unknown, paramNames: string[], adapterConfig: AdapterConfig<CustomSettings>) => string;
74
- export declare const calculateStaleness: (expirationTimestamp: number | undefined, ttl: number) => number;
75
- /**
76
- * Polls the provided Cache for an AdapterResponse set in the provided key. If the maximum
77
- * amount of retries is exceeded, it returns undefined instead.
78
- *
79
- * @param cache - a Cache instance
80
- * @param key - the key generated from an AdapterRequest that corresponds to the desired AdapterResponse
81
- * @param retry - current retry, only for internal use
82
- * @returns the AdapterResponse if found, else undefined
83
- */
84
- export declare const pollResponseFromCache: (cache: Cache<AdapterResponse>, key: string, options: {
85
- maxRetries: number;
86
- sleep: number;
87
- }, retry?: number) => Promise<AdapterResponse | undefined>;