@chainlink/external-adapter-framework 0.15.1 → 0.16.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 (95) hide show
  1. package/config/index.js +1 -1
  2. package/config/index.js.map +1 -1
  3. package/examples/bank-frick/accounts.d.ts +45 -0
  4. package/examples/bank-frick/accounts.js +203 -0
  5. package/examples/bank-frick/accounts.js.map +1 -0
  6. package/examples/bank-frick/config/index.d.ts +17 -0
  7. package/examples/bank-frick/config/index.js +55 -0
  8. package/examples/bank-frick/config/index.js.map +1 -0
  9. package/examples/bank-frick/index.d.ts +2 -0
  10. package/examples/bank-frick/index.js +16 -0
  11. package/examples/bank-frick/index.js.map +1 -0
  12. package/examples/bank-frick/util.d.ts +4 -0
  13. package/examples/bank-frick/util.js +40 -0
  14. package/examples/bank-frick/util.js.map +1 -0
  15. package/examples/coingecko/src/config/index.d.ts +2 -0
  16. package/examples/coingecko/src/config/index.js +6 -0
  17. package/examples/coingecko/src/config/index.js.map +1 -0
  18. package/examples/coingecko/src/config/overrides.json +10825 -0
  19. package/examples/coingecko/src/crypto-utils.d.ts +62 -0
  20. package/examples/coingecko/src/crypto-utils.js +60 -0
  21. package/examples/coingecko/src/crypto-utils.js.map +1 -0
  22. package/examples/coingecko/src/endpoint/coins.d.ts +26 -0
  23. package/examples/coingecko/src/endpoint/coins.js +37 -0
  24. package/examples/coingecko/src/endpoint/coins.js.map +1 -0
  25. package/examples/coingecko/src/endpoint/crypto-marketcap.d.ts +3 -0
  26. package/examples/coingecko/src/endpoint/crypto-marketcap.js +30 -0
  27. package/examples/coingecko/src/endpoint/crypto-marketcap.js.map +1 -0
  28. package/examples/coingecko/src/endpoint/crypto-volume.d.ts +3 -0
  29. package/examples/coingecko/src/endpoint/crypto-volume.js +30 -0
  30. package/examples/coingecko/src/endpoint/crypto-volume.js.map +1 -0
  31. package/examples/coingecko/src/endpoint/crypto.d.ts +3 -0
  32. package/examples/coingecko/src/endpoint/crypto.js +28 -0
  33. package/examples/coingecko/src/endpoint/crypto.js.map +1 -0
  34. package/examples/coingecko/src/endpoint/dominance.d.ts +3 -0
  35. package/examples/coingecko/src/endpoint/dominance.js +28 -0
  36. package/examples/coingecko/src/endpoint/dominance.js.map +1 -0
  37. package/examples/coingecko/src/endpoint/global-marketcap.d.ts +3 -0
  38. package/examples/coingecko/src/endpoint/global-marketcap.js +28 -0
  39. package/examples/coingecko/src/endpoint/global-marketcap.js.map +1 -0
  40. package/examples/coingecko/src/endpoint/index.d.ts +6 -0
  41. package/examples/coingecko/src/endpoint/index.js +16 -0
  42. package/examples/coingecko/src/endpoint/index.js.map +1 -0
  43. package/examples/coingecko/src/global-utils.d.ts +42 -0
  44. package/examples/coingecko/src/global-utils.js +47 -0
  45. package/examples/coingecko/src/global-utils.js.map +1 -0
  46. package/examples/coingecko/src/index.d.ts +4 -0
  47. package/examples/coingecko/src/index.js +19 -0
  48. package/examples/coingecko/src/index.js.map +1 -0
  49. package/examples/cryptocompare/src/config/index.d.ts +2 -0
  50. package/examples/cryptocompare/src/config/index.js +6 -0
  51. package/examples/cryptocompare/src/config/index.js.map +1 -0
  52. package/examples/cryptocompare/src/endpoints/crypto.d.ts +40 -0
  53. package/examples/cryptocompare/src/endpoints/crypto.js +54 -0
  54. package/examples/cryptocompare/src/endpoints/crypto.js.map +1 -0
  55. package/examples/cryptocompare/src/endpoints/index.d.ts +1 -0
  56. package/examples/cryptocompare/src/endpoints/index.js +6 -0
  57. package/examples/cryptocompare/src/endpoints/index.js.map +1 -0
  58. package/examples/cryptocompare/src/index.d.ts +4 -0
  59. package/examples/cryptocompare/src/index.js +14 -0
  60. package/examples/cryptocompare/src/index.js.map +1 -0
  61. package/examples/genesis/config/index.d.ts +7 -0
  62. package/examples/genesis/config/index.js +11 -0
  63. package/examples/genesis/config/index.js.map +1 -0
  64. package/examples/genesis/index.d.ts +2 -0
  65. package/examples/genesis/index.js +13 -0
  66. package/examples/genesis/index.js.map +1 -0
  67. package/examples/genesis/sseStream.d.ts +27 -0
  68. package/examples/genesis/sseStream.js +149 -0
  69. package/examples/genesis/sseStream.js.map +1 -0
  70. package/package.json +1 -1
  71. package/rate-limiting/request/simple-counting.d.ts +1 -1
  72. package/rate-limiting/request/simple-counting.js +8 -12
  73. package/rate-limiting/request/simple-counting.js.map +1 -1
  74. package/scripts/generator/index.d.ts +1 -0
  75. package/scripts/generator/index.js +5 -0
  76. package/scripts/generator/index.js.map +1 -0
  77. package/scripts/generator/lib.d.ts +1 -0
  78. package/scripts/generator/lib.js +170 -0
  79. package/scripts/generator/lib.js.map +1 -0
  80. package/scripts/generator/workspace.d.ts +21 -0
  81. package/scripts/generator/workspace.js +76 -0
  82. package/scripts/generator/workspace.js.map +1 -0
  83. package/transports/batch-warming.d.ts +8 -20
  84. package/transports/batch-warming.js +68 -55
  85. package/transports/batch-warming.js.map +1 -1
  86. package/transports/meta/routing.d.ts +1 -1
  87. package/transports/meta/routing.js +1 -1
  88. package/transports/meta/routing.js.map +1 -1
  89. package/transports/routing.d.ts +22 -0
  90. package/transports/routing.js +60 -0
  91. package/transports/routing.js.map +1 -0
  92. package/transports/websocket.d.ts +3 -1
  93. package/transports/websocket.js +7 -3
  94. package/transports/websocket.js.map +1 -1
  95. package/util/request.d.ts +25 -25
package/util/request.d.ts CHANGED
@@ -6,7 +6,7 @@ declare module 'fastify' {
6
6
  requestContext: AdapterRequestContext;
7
7
  }
8
8
  }
9
- export declare type Merge<T1, T2> = {
9
+ export type Merge<T1, T2> = {
10
10
  [K in keyof T1 | keyof T2]: K extends keyof T2 ? T2[K] : K extends keyof T1 ? T1[K] : never;
11
11
  };
12
12
  /**
@@ -22,7 +22,7 @@ export interface AdapterRequestBody<T = AdapterRequestData> {
22
22
  * Object that will be added to the request on a successful validation.
23
23
  * Contains all the necessary information the adapter will need across the request execution.
24
24
  */
25
- export declare type AdapterRequestContext<T = AdapterRequestData> = {
25
+ export type AdapterRequestContext<T = AdapterRequestData> = {
26
26
  /** Name of the endpoint this payload should be directed to */
27
27
  endpointName: string;
28
28
  /** Precalculated cache key used to get and set corresponding values from the cache and subscription sets */
@@ -35,18 +35,18 @@ export declare type AdapterRequestContext<T = AdapterRequestData> = {
35
35
  /**
36
36
  * Helper type to denote an empty body
37
37
  */
38
- declare type EmptyBody = Record<string, never>;
38
+ type EmptyBody = Record<string, never>;
39
39
  /**
40
40
  * Helper type to provide fastify for all adapter handlers
41
41
  */
42
- export declare type AdapterRouteGeneric = {
42
+ export type AdapterRouteGeneric = {
43
43
  /** Set to an empty record so the user does not access the raw request data and uses the Validated data from the context instead */
44
44
  Body: EmptyBody;
45
45
  };
46
46
  /**
47
47
  * Structure for all requests incoming to this adapter
48
48
  */
49
- export declare type AdapterRequest<T extends RequestGenerics = RequestGenerics> = FastifyRequest<AdapterRouteGeneric> & {
49
+ export type AdapterRequest<T extends RequestGenerics = RequestGenerics> = FastifyRequest<AdapterRouteGeneric> & {
50
50
  /** Set to an empty record so the user does not access the raw request data and uses the Validated data from the context instead */
51
51
  body: EmptyBody;
52
52
  /** Container for all validated information that will be used by the framework across this request's lifecycle */
@@ -73,23 +73,23 @@ export interface AdapterMetricsMeta {
73
73
  /**
74
74
  * Basic shape for the data within the request body
75
75
  */
76
- export declare type AdapterRequestData = Record<string, unknown> & {
76
+ export type AdapterRequestData = Record<string, unknown> & {
77
77
  endpoint?: string;
78
78
  };
79
- export declare type ProviderResultGenerics = {
79
+ export type ProviderResultGenerics = {
80
80
  Request: RequestGenerics;
81
81
  Response: ResponseGenerics;
82
82
  };
83
83
  /**
84
84
  * Helper type to hold the value from responses from a provider, and the adapter params they correspond to.
85
85
  */
86
- export declare type ProviderResult<T extends ProviderResultGenerics> = {
86
+ export type ProviderResult<T extends ProviderResultGenerics> = {
87
87
  /** The set of parameters that uniquely relate to the response */
88
88
  params: T['Request']['Params'];
89
89
  /** Value that will be included in the result property of the response */
90
90
  response: PartialAdapterResponse<T['Response']>;
91
91
  };
92
- export declare type TimestampedProviderResult<T extends ProviderResultGenerics> = Pick<ProviderResult<T>, 'params'> & {
92
+ export type TimestampedProviderResult<T extends ProviderResultGenerics> = Pick<ProviderResult<T>, 'params'> & {
93
93
  /** Value that will be included in the result property of the response, with timestamps applied */
94
94
  response: TimestampedAdapterResponse<T['Response']>;
95
95
  };
@@ -97,11 +97,11 @@ export declare type TimestampedProviderResult<T extends ProviderResultGenerics>
97
97
  * Here we do actually want an object, since unknown could be a primitive.
98
98
  * The rule itself does say "marginally better"
99
99
  */
100
- export declare type EmptyObject = Object;
100
+ export type EmptyObject = Object;
101
101
  /**
102
102
  * Helper struct type that provides detail about the incoming Adapter Request
103
103
  */
104
- export declare type RequestGenerics = {
104
+ export type RequestGenerics = {
105
105
  /**
106
106
  * Type for the parameters sent to the EA in the data property of the body.
107
107
  */
@@ -110,7 +110,7 @@ export declare type RequestGenerics = {
110
110
  /**
111
111
  * Helper struct type that provides detail about the outgoing Adapter Response
112
112
  */
113
- export declare type ResponseGenerics = {
113
+ export type ResponseGenerics = {
114
114
  /**
115
115
  * Type for the data property of the response.
116
116
  */
@@ -124,7 +124,7 @@ export declare type ResponseGenerics = {
124
124
  /**
125
125
  * Details for timestamps to be included in the response
126
126
  */
127
- export declare type ResponseTimestamps = {
127
+ type ResponseTimestamps = {
128
128
  /** Time at which data was received from the provider */
129
129
  providerDataReceived: number;
130
130
  /** Time indicated by the provider representing the time at which this value was calculated/set/valid */
@@ -147,14 +147,14 @@ export declare type ResponseTimestamps = {
147
147
  /**
148
148
  * Object with timestamps that will be present in both successful and provider error responses
149
149
  */
150
- declare type TimestampedResponseObject = {
150
+ type TimestampedResponseObject = {
151
151
  /** Timestamps relevant for data provider timings */
152
152
  timestamps: ResponseTimestamps;
153
153
  };
154
154
  /**
155
155
  * Response from the EA to send when manually storing an error in the cache
156
156
  */
157
- declare type ProviderErrorResponse = {
157
+ type ProviderErrorResponse = {
158
158
  /** Status code for the errored response */
159
159
  statusCode: number;
160
160
  /** Error message that will be sent back from the adapter */
@@ -167,11 +167,11 @@ declare type ProviderErrorResponse = {
167
167
  /**
168
168
  * Provider error response with timestamps added
169
169
  */
170
- export declare type TimestampedProviderErrorResponse = ProviderErrorResponse & TimestampedResponseObject;
170
+ export type TimestampedProviderErrorResponse = ProviderErrorResponse & TimestampedResponseObject;
171
171
  /**
172
172
  * The most basic data that needs to be manually set for an adapter response.
173
173
  */
174
- export declare type PartialSuccessfulResponse<T extends ResponseGenerics> = {
174
+ export type PartialSuccessfulResponse<T extends ResponseGenerics> = {
175
175
  /** Response data, holds "result" for Flux Monitor */
176
176
  data: T['Data'];
177
177
  /** Result value used for OCR */
@@ -184,11 +184,11 @@ export declare type PartialSuccessfulResponse<T extends ResponseGenerics> = {
184
184
  /**
185
185
  * Partial EA response, with timestamps added
186
186
  */
187
- declare type TimestampedSuccessfulResponse<T extends ResponseGenerics> = PartialSuccessfulResponse<T> & TimestampedResponseObject;
187
+ type TimestampedSuccessfulResponse<T extends ResponseGenerics> = PartialSuccessfulResponse<T> & TimestampedResponseObject;
188
188
  /**
189
189
  * Full EA successful response, with metadata and defaults added
190
190
  */
191
- declare type SuccessfulResponse<T extends ResponseGenerics> = TimestampedSuccessfulResponse<T> & {
191
+ type SuccessfulResponse<T extends ResponseGenerics> = TimestampedSuccessfulResponse<T> & {
192
192
  /** Metadata relevant to this request */
193
193
  meta?: AdapterRequestMeta;
194
194
  /** HTTP status code, by default will be set to 200 */
@@ -197,21 +197,21 @@ declare type SuccessfulResponse<T extends ResponseGenerics> = TimestampedSuccess
197
197
  /**
198
198
  * Response body from the EA, before timestamps, defaults and metadata are filled in
199
199
  */
200
- export declare type PartialAdapterResponse<T extends ResponseGenerics = ResponseGenerics> = PartialSuccessfulResponse<T> | ProviderErrorResponse;
200
+ export type PartialAdapterResponse<T extends ResponseGenerics = ResponseGenerics> = PartialSuccessfulResponse<T> | ProviderErrorResponse;
201
201
  /**
202
202
  * Response body from the EA with timestamps, before defaults and metadata are filled in
203
203
  */
204
- export declare type TimestampedAdapterResponse<T extends ResponseGenerics = ResponseGenerics> = TimestampedSuccessfulResponse<T> | TimestampedProviderErrorResponse;
204
+ export type TimestampedAdapterResponse<T extends ResponseGenerics = ResponseGenerics> = TimestampedSuccessfulResponse<T> | TimestampedProviderErrorResponse;
205
205
  /**
206
206
  * Shape of the response body from the adapter
207
207
  */
208
- export declare type AdapterResponse<T extends ResponseGenerics = ResponseGenerics> = SuccessfulResponse<T> | TimestampedProviderErrorResponse;
209
- export declare type SingleNumberResultResponse = {
208
+ export type AdapterResponse<T extends ResponseGenerics = ResponseGenerics> = SuccessfulResponse<T> | TimestampedProviderErrorResponse;
209
+ export type SingleNumberResultResponse = {
210
210
  Result: number;
211
211
  Data: {
212
212
  result: number;
213
213
  };
214
214
  };
215
- export declare type Middleware = ((req: AdapterRequest, reply: FastifyReply, done: HookHandlerDoneFunction) => FastifyReply | void) | ((req: AdapterRequest, reply: FastifyReply) => Promise<FastifyReply | void>);
216
- export declare type AdapterMiddlewareBuilder = (adapter: Adapter) => Middleware;
215
+ export type Middleware = ((req: AdapterRequest, reply: FastifyReply, done: HookHandlerDoneFunction) => FastifyReply | void) | ((req: AdapterRequest, reply: FastifyReply) => Promise<FastifyReply | void>);
216
+ export type AdapterMiddlewareBuilder = (adapter: Adapter) => Middleware;
217
217
  export {};