@chainlink/external-adapter-framework 0.0.22 → 0.0.25

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 (78) hide show
  1. package/cache/factory.js +27 -0
  2. package/cache/index.js +16 -1
  3. package/cache/local.js +26 -0
  4. package/cache/redis.js +45 -0
  5. package/package.json +2 -2
  6. package/transports/batch-warming.js +36 -0
  7. package/transports/rest.js +32 -0
  8. package/transports/util.js +33 -0
  9. package/transports/websocket.js +31 -0
  10. package/adapter.d.ts +0 -139
  11. package/background-executor.d.ts +0 -9
  12. package/cache/factory.d.ts +0 -6
  13. package/cache/index.d.ts +0 -94
  14. package/cache/local.d.ts +0 -23
  15. package/cache/metrics.d.ts +0 -27
  16. package/cache/redis.d.ts +0 -16
  17. package/config/index.d.ts +0 -258
  18. package/config/provider-limits.d.ts +0 -27
  19. package/examples/bank-frick/accounts.d.ts +0 -39
  20. package/examples/bank-frick/config/index.d.ts +0 -4
  21. package/examples/bank-frick/index.d.ts +0 -2
  22. package/examples/bank-frick/util.d.ts +0 -4
  23. package/examples/coingecko/batch-warming.d.ts +0 -7
  24. package/examples/coingecko/batch-warming.js +0 -53
  25. package/examples/coingecko/index.d.ts +0 -2
  26. package/examples/coingecko/index.js +0 -11
  27. package/examples/coingecko/rest.d.ts +0 -12
  28. package/examples/coingecko/rest.js +0 -51
  29. package/examples/coingecko/src/config/index.d.ts +0 -2
  30. package/examples/coingecko/src/cryptoUtils.d.ts +0 -31
  31. package/examples/coingecko/src/endpoint/coins.d.ts +0 -9
  32. package/examples/coingecko/src/endpoint/crypto-marketcap.d.ts +0 -3
  33. package/examples/coingecko/src/endpoint/crypto-volume.d.ts +0 -3
  34. package/examples/coingecko/src/endpoint/crypto.d.ts +0 -3
  35. package/examples/coingecko/src/endpoint/dominance.d.ts +0 -3
  36. package/examples/coingecko/src/endpoint/global-marketcap.d.ts +0 -3
  37. package/examples/coingecko/src/endpoint/index.d.ts +0 -6
  38. package/examples/coingecko/src/globalUtils.d.ts +0 -27
  39. package/examples/coingecko/src/index.d.ts +0 -4
  40. package/examples/coingecko/test/e2e/adapter.test.js +0 -262
  41. package/examples/coingecko/test/integration/adapter.test.js +0 -264
  42. package/examples/coingecko/test/integration/capturedRequests.json +0 -1
  43. package/examples/coingecko/test/integration/fixtures.js +0 -41
  44. package/examples/coingecko-old/batch-warming.d.ts +0 -7
  45. package/examples/coingecko-old/index.d.ts +0 -2
  46. package/examples/coingecko-old/rest.d.ts +0 -12
  47. package/examples/ncfx/config/index.d.ts +0 -12
  48. package/examples/ncfx/index.d.ts +0 -13
  49. package/examples/ncfx/websocket.d.ts +0 -47
  50. package/index.d.ts +0 -11
  51. package/metrics/constants.d.ts +0 -16
  52. package/metrics/index.d.ts +0 -15
  53. package/metrics/util.d.ts +0 -7
  54. package/rate-limiting/background/fixed-frequency.d.ts +0 -11
  55. package/rate-limiting/index.d.ts +0 -55
  56. package/rate-limiting/metrics.d.ts +0 -3
  57. package/rate-limiting/request/simple-counting.d.ts +0 -21
  58. package/test.d.ts +0 -1
  59. package/test.js +0 -6
  60. package/transports/batch-warming.d.ts +0 -35
  61. package/transports/index.d.ts +0 -73
  62. package/transports/metrics.d.ts +0 -22
  63. package/transports/rest.d.ts +0 -44
  64. package/transports/util.d.ts +0 -9
  65. package/transports/websocket.d.ts +0 -80
  66. package/util/index.d.ts +0 -12
  67. package/util/logger.d.ts +0 -42
  68. package/util/recordRequests.js +0 -45
  69. package/util/request.d.ts +0 -56
  70. package/util/subscription-set/expiring-sorted-set.d.ts +0 -22
  71. package/util/subscription-set/subscription-set.d.ts +0 -18
  72. package/util/test-payload-loader.d.ts +0 -25
  73. package/validation/error.d.ts +0 -50
  74. package/validation/index.d.ts +0 -5
  75. package/validation/input-params.d.ts +0 -15
  76. package/validation/override-functions.d.ts +0 -3
  77. package/validation/overrideFunctions.js +0 -40
  78. package/validation/validator.d.ts +0 -47
package/cache/index.d.ts DELETED
@@ -1,94 +0,0 @@
1
- import { AdapterEndpoint } from '../adapter';
2
- import { AdapterConfig, SettingsMap } from '../config';
3
- import { AdapterMiddlewareBuilder, AdapterResponse, sleep } from '../util';
4
- export * from './local';
5
- export * from './redis';
6
- export * from './factory';
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
- /**
75
- * Polls the provided Cache for an AdapterResponse set in the provided key. If the maximum
76
- * amount of retries is exceeded, it returns undefined instead.
77
- *
78
- * @param cache - a Cache instance
79
- * @param key - the key generated from an AdapterRequest that corresponds to the desired AdapterResponse
80
- * @param retry - current retry, only for internal use
81
- * @returns the AdapterResponse if found, else undefined
82
- */
83
- export declare const pollResponseFromCache: (cache: Cache<AdapterResponse>, key: string, options: {
84
- maxRetries: number;
85
- sleep: number;
86
- }, retry?: number) => Promise<AdapterResponse | undefined>;
87
- /**
88
- * Given a Cache instance in the adapter dependencies, builds a middleware function that will perform
89
- * a get from said Cache and return that if found; otherwise it'll continue the middleware chain.
90
- *
91
- * @param adapter - an initialized adapter
92
- * @returns the cache middleware function
93
- */
94
- export declare const buildCacheMiddleware: AdapterMiddlewareBuilder;
package/cache/local.d.ts DELETED
@@ -1,23 +0,0 @@
1
- import { Cache, CacheEntry } from './index';
2
- /**
3
- * Type for a value stored in a LocalCache entry.
4
- *
5
- * @typeParam T - the type for the entry's value
6
- */
7
- export interface LocalCacheEntry<T> {
8
- expirationTimestamp: number;
9
- value: T;
10
- }
11
- /**
12
- * Local implementation of a Cache. It uses a simple js Object, storing entries with both
13
- * a value and an expiration timestamp. Expired entries are deleted on reads (i.e. no background gc/upkeep).
14
- *
15
- * @typeParam T - the type for the entries' values
16
- */
17
- export declare class LocalCache<T = unknown> implements Cache<T> {
18
- store: Record<string, LocalCacheEntry<T>>;
19
- get(key: string): Promise<T | undefined>;
20
- delete(key: string): Promise<void>;
21
- set(key: string, value: T, ttl: number): Promise<void>;
22
- setMany(entries: CacheEntry<T>[], ttl: number): Promise<void>;
23
- }
@@ -1,27 +0,0 @@
1
- import * as client from 'prom-client';
2
- interface CacheMetricsLabels {
3
- participant_id: string;
4
- feed_id: string;
5
- cache_type: string;
6
- }
7
- export declare const cacheGet: (label: CacheMetricsLabels, value: unknown, staleness: number) => void;
8
- export declare const cacheSet: (label: CacheMetricsLabels, maxAge: number) => void;
9
- export declare const cacheMetricsLabel: (cacheKey: string, feedId: string, cacheType: string) => {
10
- participant_id: string;
11
- feed_id: string;
12
- cache_type: string;
13
- };
14
- export declare enum CacheTypes {
15
- Redis = "redis",
16
- Local = "local"
17
- }
18
- export declare enum CMD_SENT_STATUS {
19
- TIMEOUT = "TIMEOUT",
20
- FAIL = "FAIL",
21
- SUCCESS = "SUCCESS"
22
- }
23
- export declare const redisConnectionsOpen: client.Counter<string>;
24
- export declare const redisRetriesCount: client.Counter<string>;
25
- export declare const redisCommandsSentCount: client.Counter<"status" | "function_name">;
26
- export declare const cacheWarmerCount: client.Gauge<"isBatched">;
27
- export {};
package/cache/redis.d.ts DELETED
@@ -1,16 +0,0 @@
1
- import Redis from 'ioredis';
2
- import { Cache, CacheEntry } from './index';
3
- /**
4
- * Redis implementation of a Cache. It uses a simple js Object, storing entries with both
5
- * a value and an expiration timestamp. Expired entries are deleted on reads (i.e. no background gc/upkeep).
6
- *
7
- * @typeParam T - the type for the entries' values
8
- */
9
- export declare class RedisCache<T = unknown> implements Cache<T> {
10
- private client;
11
- constructor(client: Redis);
12
- get(key: string): Promise<T | undefined>;
13
- delete(key: string): Promise<void>;
14
- set(key: string, value: T, ttl: number): Promise<void>;
15
- setMany(entries: CacheEntry<T>[], ttl: number): Promise<void>;
16
- }
package/config/index.d.ts DELETED
@@ -1,258 +0,0 @@
1
- export declare const BaseSettings: {
2
- readonly API_ENDPOINT: {
3
- readonly description: "The URL that certain transports use to retrieve data";
4
- readonly type: "string";
5
- };
6
- readonly API_KEY: {
7
- readonly description: "Default setting for an EA key";
8
- readonly type: "string";
9
- };
10
- readonly API_TIMEOUT: {
11
- readonly description: "The number of milliseconds a request can be pending before returning a timeout error for data provider request";
12
- readonly type: "number";
13
- readonly default: 30000;
14
- };
15
- readonly API_VERBOSE: {
16
- readonly description: "Toggle whether the response from the EA should contain just the results or also include the full response body from the queried API.";
17
- readonly type: "boolean";
18
- readonly default: false;
19
- };
20
- readonly BASE_URL: {
21
- readonly description: "Starting path for the EA handler endpoint";
22
- readonly type: "string";
23
- readonly default: "/";
24
- };
25
- readonly CACHE_MAX_AGE: {
26
- readonly description: "Maximum amount of time (in ms) that a response will stay cached";
27
- readonly type: "number";
28
- readonly default: 90000;
29
- };
30
- readonly CACHE_REDIS_HOST: {
31
- readonly description: "Hostname for the Redis instance to be used";
32
- readonly type: "string";
33
- readonly default: "127.0.0.1";
34
- };
35
- readonly CACHE_REDIS_PASSWORD: {
36
- readonly description: "The password required for redis auth";
37
- readonly type: "string";
38
- };
39
- readonly CACHE_REDIS_PATH: {
40
- readonly description: "The UNIX socket string of the Redis server";
41
- readonly type: "string";
42
- };
43
- readonly CACHE_REDIS_PORT: {
44
- readonly description: "Port for the Redis instance to be used";
45
- readonly type: "number";
46
- readonly default: 6379;
47
- };
48
- readonly CACHE_REDIS_TIMEOUT: {
49
- readonly description: "Timeout to fail a Redis server request if no response (ms)";
50
- readonly type: "number";
51
- readonly default: 500;
52
- };
53
- readonly CACHE_TYPE: {
54
- readonly description: "The type of cache to use throughout the EA";
55
- readonly type: "enum";
56
- readonly default: "local";
57
- readonly options: readonly ["local", "redis"];
58
- };
59
- readonly CORRELATION_ID_ENABLED: {
60
- readonly description: "Flag to enable correlation IDs for sent requests in logging";
61
- readonly type: "boolean";
62
- readonly default: true;
63
- };
64
- readonly DEBUG: {
65
- readonly description: "Toggles debug mode";
66
- readonly type: "boolean";
67
- readonly default: false;
68
- };
69
- readonly EA_PORT: {
70
- readonly description: "Port through which the EA will listen for REST requests (if mode is set to \"reader\" or \"reader-writer\")";
71
- readonly type: "number";
72
- readonly default: 8080;
73
- };
74
- readonly EXPERIMENTAL_METRICS_ENABLED: {
75
- readonly description: "Flag to specify whether or not to collect metrics. Used as fallback for METRICS_ENABLED";
76
- readonly type: "boolean";
77
- readonly default: true;
78
- };
79
- readonly LOG_LEVEL: {
80
- readonly description: "Minimum level required for logs to be output";
81
- readonly type: "string";
82
- readonly default: "info";
83
- };
84
- readonly METRICS_ENABLED: {
85
- readonly description: "Flag to specify whether or not to startup the metrics server";
86
- readonly type: "boolean";
87
- readonly default: true;
88
- };
89
- readonly METRICS_NAME: {
90
- readonly description: "Metrics name";
91
- readonly type: "string";
92
- };
93
- readonly METRICS_PORT: {
94
- readonly description: "Port metrics will be exposed to";
95
- readonly type: "number";
96
- readonly default: 9080;
97
- };
98
- readonly METRICS_USE_BASE_URL: {
99
- readonly description: "Flag to specify whether or not to prepend the BASE_URL to the metrics endpoint";
100
- readonly type: "boolean";
101
- };
102
- readonly RATE_LIMIT_API_TIER: {
103
- readonly description: "Rate limiting tier to use from the available options for the adapter. If not present, the adapter will run using the first tier on the list.";
104
- readonly type: "string";
105
- };
106
- readonly RATE_LIMIT_CAPACITY: {
107
- readonly description: "Used as rate limit capacity per minute and ignores tier settings if defined";
108
- readonly type: "number";
109
- };
110
- readonly RATE_LIMIT_CAPACITY_MINUTE: {
111
- readonly description: "Used as rate limit capacity per minute and ignores tier settings if defined. Supercedes RATE_LIMIT_CAPACITY if both vars are set";
112
- readonly type: "number";
113
- };
114
- readonly RATE_LIMIT_CAPACITY_SECOND: {
115
- readonly description: "Used as rate limit capacity per second and ignores tier settings if defined";
116
- readonly type: "number";
117
- };
118
- readonly REQUEST_COALESCING_ENABLED: {
119
- readonly description: "Enable request coalescing";
120
- readonly type: "boolean";
121
- };
122
- readonly WARMUP_SUBSCRIPTION_TTL: {
123
- readonly type: "number";
124
- readonly description: "TTL for batch warmer subscriptions";
125
- readonly default: 10000;
126
- };
127
- readonly WS_SUBSCRIPTION_TTL: {
128
- readonly description: "";
129
- readonly type: "number";
130
- readonly default: 120000;
131
- };
132
- readonly CACHE_POLLING_MAX_RETRIES: {
133
- readonly description: "Max amount of times to attempt to find EA response in the cache after the Transport has been set up";
134
- readonly type: "number";
135
- readonly default: 10;
136
- };
137
- readonly CACHE_POLLING_SLEEP_MS: {
138
- readonly description: "The number of ms to sleep between each retry to fetch the EA response in the cache";
139
- readonly type: "number";
140
- readonly default: 200;
141
- };
142
- readonly DEFAULT_CACHE_KEY: {
143
- readonly description: "Default key to be used when one cannot be determined from request parameters";
144
- readonly type: "string";
145
- readonly default: "DEFAULT_CACHE_KEY";
146
- };
147
- readonly EA_HOST: {
148
- readonly description: "Host this EA will listen for REST requests on (if mode is set to \"reader\" or \"reader-writer\")";
149
- readonly type: "string";
150
- readonly default: "::";
151
- };
152
- readonly EA_MODE: {
153
- readonly description: "Port this EA will listen for REST requests on (if mode is set to \"reader\" or \"reader-writer\")";
154
- readonly type: "enum";
155
- readonly default: "reader-writer";
156
- readonly options: readonly ["reader", "writer", "reader-writer"];
157
- };
158
- readonly MAX_COMMON_KEY_SIZE: {
159
- readonly description: "Maximum amount of characters that the common part of the cache key or feed ID can have";
160
- readonly type: "number";
161
- readonly default: 300;
162
- readonly validate: (value?: number) => "MAX_COMMON_KEY_SIZE must be a number between 150 and 500" | undefined;
163
- };
164
- readonly REST_TRANSPORT_MAX_RATE_LIMIT_RETRIES: {
165
- readonly description: "Maximum amount of times the Rest Transport will attempt to set up a request when blocked by the rate limiter";
166
- readonly type: "number";
167
- readonly default: 3;
168
- };
169
- readonly REST_TRANSPORT_MS_BETWEEN_RATE_LIMIT_RETRIES: {
170
- readonly description: "Time that the Rest Transport will wait between retries when blocked by the rate limiter";
171
- readonly type: "number";
172
- readonly default: 400;
173
- };
174
- readonly SMOKE_TEST_PAYLOAD_FILE_NAME: {
175
- readonly description: "Name of the test payload file used for the smoke endpoint";
176
- readonly type: "string";
177
- };
178
- };
179
- export declare const buildAdapterConfig: <CustomSettings extends CustomSettingsType<CustomSettings> = EmptySettings>({ overrides, customSettings, }: {
180
- overrides?: Partial<BaseAdapterConfig> | undefined;
181
- customSettings?: SettingsMap | undefined;
182
- }) => AdapterConfig<CustomSettings>;
183
- declare type SettingValueType = string | number | boolean;
184
- declare type SettingType<C extends Setting> = C['type'] extends 'string' ? string : C['type'] extends 'number' ? number : C['type'] extends 'boolean' ? boolean : C['type'] extends 'enum' ? C['options'] extends readonly string[] ? C['options'][number] : never : never;
185
- declare type BaseSettingsType = typeof BaseSettings;
186
- export declare type Setting = {
187
- type: 'string';
188
- description: string;
189
- options?: never;
190
- default?: string;
191
- validate?: (value?: string) => ValidationErrorMessage;
192
- required?: false;
193
- } | {
194
- type: 'string';
195
- description: string;
196
- options?: never;
197
- default?: string;
198
- validate?: (value: string) => ValidationErrorMessage;
199
- required: true;
200
- } | {
201
- type: 'number';
202
- description: string;
203
- options?: never;
204
- default?: number;
205
- validate?: (value?: number) => ValidationErrorMessage;
206
- required?: false;
207
- } | {
208
- type: 'number';
209
- description: string;
210
- options?: never;
211
- default?: number;
212
- validate?: (value: number) => ValidationErrorMessage;
213
- required: true;
214
- } | {
215
- type: 'boolean';
216
- description: string;
217
- options?: never;
218
- default?: boolean;
219
- validate?: (value?: boolean) => ValidationErrorMessage;
220
- required?: false;
221
- } | {
222
- type: 'boolean';
223
- description: string;
224
- options?: never;
225
- default?: boolean;
226
- validate?: (value: boolean) => ValidationErrorMessage;
227
- required: true;
228
- } | {
229
- type: 'enum';
230
- description: string;
231
- default?: string;
232
- options: readonly string[];
233
- validate?: (value?: string) => ValidationErrorMessage;
234
- required?: false;
235
- } | {
236
- type: 'enum';
237
- description: string;
238
- default?: string;
239
- options: readonly string[];
240
- validate?: (value: string) => ValidationErrorMessage;
241
- required: true;
242
- };
243
- export declare type AdapterConfigFromSettings<T extends SettingsMap> = {
244
- -readonly [K in keyof T as T[K] extends {
245
- default: SettingValueType;
246
- } ? K : T[K]['required'] extends true ? K : never]: SettingType<T[K]>;
247
- } & {
248
- -readonly [K in keyof T as T[K] extends {
249
- default: SettingValueType;
250
- } ? never : T[K]['required'] extends true ? never : K]?: SettingType<T[K]> | undefined;
251
- };
252
- export declare type BaseAdapterConfig = AdapterConfigFromSettings<BaseSettingsType>;
253
- export declare type AdapterConfig<T extends CustomSettingsType<T> = SettingsMap> = AdapterConfigFromSettings<T> & BaseAdapterConfig;
254
- export declare type CustomSettingsType<T = SettingsMap> = Record<keyof T, Setting>;
255
- export declare type EmptySettings = Record<string, never>;
256
- export declare type SettingsMap = Record<string, Setting>;
257
- export declare type ValidationErrorMessage = string | undefined;
258
- export {};
@@ -1,27 +0,0 @@
1
- export declare const DEFAULT_MINUTE_RATE_LIMIT = 60;
2
- export declare const BURST_UNDEFINED_QUOTA_MULTIPLE = 2;
3
- export declare const DEFAULT_WS_CONNECTIONS = 2;
4
- export declare const DEFAULT_WS_SUBSCRIPTIONS = 10;
5
- declare type RateLimitTimeFrame = 'rateLimit1s' | 'rateLimit1m' | 'rateLimit1h';
6
- declare type HTTPTier = {
7
- rateLimit1s?: number;
8
- rateLimit1m?: number;
9
- rateLimit1h?: number;
10
- note?: string;
11
- };
12
- declare type WSTier = {
13
- connections: number;
14
- subscriptions: number;
15
- };
16
- export interface Limits {
17
- http: Record<string, HTTPTier>;
18
- ws: Record<string, WSTier>;
19
- }
20
- interface ProviderRateLimit {
21
- second: number;
22
- minute: number;
23
- }
24
- export declare const getHTTPLimit: (provider: string, limits: Limits, tier: string, timeframe: RateLimitTimeFrame) => number;
25
- export declare const getRateLimit: (provider: string, limits: Limits, tier: string) => ProviderRateLimit;
26
- export declare const getWSLimits: (provider: string, limits: Limits, tier: string) => WSTier;
27
- export {};
@@ -1,39 +0,0 @@
1
- import { AxiosRequestConfig, AxiosResponse } from 'axios';
2
- import { AdapterInputParameters, BankFrickAccountsRequestSchema, BankFrickAccountsResponseSchema, SigningAlgorithm } from './types';
3
- import { customSettings } from './config';
4
- import { Transport } from '../../transports';
5
- import { AdapterRequest, AdapterResponse } from '../../util';
6
- import { AdapterConfig } from '../../config';
7
- import { Cache } from '../../cache';
8
- import { AdapterDependencies, AdapterEndpoint } from '../../adapter';
9
- /**
10
- * RestTransport implementation for Bank Frick, which has unusually complex requirements for an EA
11
- * The RestTransport is generally built to make a single request and return a single response.
12
- * This transport instead is used to fetch and process pages of data, and also requires a JWT to run
13
- *
14
- * This transport does all the heavy lifting in setup(), which is where the paging happens, and it
15
- * also has complex retry logic that will attempt to refresh the JWT when certain HTTP errors occur
16
- */
17
- export declare class BankFrickAccountsTransport implements Transport<AdapterInputParameters, number, typeof customSettings> {
18
- token: string;
19
- cache: Cache;
20
- initialize(dependencies: AdapterDependencies): Promise<void>;
21
- hasBeenSetUp(): Promise<boolean>;
22
- /**
23
- * Creates an AxiosRequestConfig object for fetching a page of accounts from the Bank Frick API
24
- */
25
- prepareRequest(firstPosition: number, inputParams: AdapterInputParameters, config: AdapterConfig<typeof customSettings>): AxiosRequestConfig<BankFrickAccountsRequestSchema>;
26
- /**
27
- * Request with retry logic for Bank Frick's API. In addition to standard retry logic, this function
28
- * compares errors against expected errors from the Bank Frick API, and will throw without retries
29
- * on a known fatal error, or try to refresh the JWT on a known auth error
30
- **/
31
- makeRequest(axiosRequest: AxiosRequestConfig<BankFrickAccountsRequestSchema>, config: AdapterConfig<typeof customSettings>, signingAlgorithm?: SigningAlgorithm): Promise<AxiosResponse<BankFrickAccountsResponseSchema>>;
32
- validateInputParams(params: AdapterInputParameters): string[];
33
- /**
34
- * Fetches pages of data from the Bank Frick API, scans for accounts by IBAN, and returns the balance
35
- * of all found accounts. Returns a 404 if any IBAN isn't found.
36
- */
37
- setup(req: AdapterRequest<AdapterInputParameters>, config: AdapterConfig<typeof customSettings>): Promise<AdapterResponse<number>>;
38
- }
39
- export declare const accountsRestEndpoint: AdapterEndpoint<AdapterInputParameters, number, import("../../config").SettingsMap>;
@@ -1,4 +0,0 @@
1
- import { SettingsMap } from '../../../config';
2
- import { SigningAlgorithm } from '../types';
3
- export declare const signingAlgorithms: SigningAlgorithm[];
4
- export declare const customSettings: SettingsMap;
@@ -1,2 +0,0 @@
1
- import { Adapter } from '../../adapter';
2
- export declare const adapter: Adapter<import("../../config").SettingsMap>;
@@ -1,4 +0,0 @@
1
- import { SigningAlgorithm } from './types';
2
- import { customSettings } from './config';
3
- import { AdapterConfig } from '../../config';
4
- export declare const generateJWT: (config: AdapterConfig<typeof customSettings>, signingAlgorithm?: SigningAlgorithm) => Promise<string>;
@@ -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 {};
@@ -1,53 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.batchEndpoint = void 0;
4
- const adapter_1 = require("../../adapter");
5
- const batch_warming_1 = require("../../transports/batch-warming");
6
- const DEFAULT_URL = 'https://pro-api.coingecko.com/api/v3';
7
- const inputParameters = {
8
- coinid: {
9
- description: 'The CoinGecko id or array of ids of the coin(s) to query (Note: because of current limitations to use a dummy base will need to be supplied)',
10
- required: false,
11
- },
12
- base: {
13
- aliases: ['from', 'coin'],
14
- description: 'The symbol or array of symbols of the currency to query',
15
- required: true,
16
- },
17
- quote: {
18
- aliases: ['to', 'market'],
19
- description: 'The symbol of the currency to convert to',
20
- required: true,
21
- },
22
- };
23
- const batchEndpointTransport = new batch_warming_1.BatchWarmingTransport({
24
- prepareRequest: (params, context) => {
25
- return {
26
- baseURL: DEFAULT_URL,
27
- url: '/simple/price',
28
- method: 'GET',
29
- params: {
30
- ids: [...new Set(params.map((p) => p.base))].join(','),
31
- vs_currencies: [...new Set(params.map((p) => p.quote))].join(','),
32
- x_cg_pro_api_key: context.adapterConfig.API_KEY,
33
- },
34
- };
35
- },
36
- parseResponse: (res) => {
37
- const entries = [];
38
- for (const [base, entry] of Object.entries(res.data)) {
39
- for (const [quote, price] of Object.entries(entry)) {
40
- entries.push({
41
- params: { base, quote },
42
- value: price,
43
- });
44
- }
45
- }
46
- return entries;
47
- },
48
- });
49
- exports.batchEndpoint = new adapter_1.AdapterEndpoint({
50
- name: 'batch',
51
- transport: batchEndpointTransport,
52
- inputParameters,
53
- });
@@ -1,2 +0,0 @@
1
- import { Adapter } from '../../adapter';
2
- export declare const adapter: Adapter<import("../../config").SettingsMap>;
@@ -1,11 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.adapter = void 0;
4
- const adapter_1 = require("../../adapter");
5
- const batch_warming_1 = require("./batch-warming");
6
- const rest_1 = require("./rest");
7
- exports.adapter = new adapter_1.Adapter({
8
- name: 'coingecko',
9
- defaultEndpoint: 'batch',
10
- endpoints: [rest_1.restEndpoint, batch_warming_1.batchEndpoint],
11
- });
@@ -1,12 +0,0 @@
1
- import { AdapterEndpoint } from '../../adapter';
2
- interface AdapterRequestParams {
3
- base: string;
4
- quote: string;
5
- }
6
- interface ProviderResponseBody {
7
- [base: string]: {
8
- [quote: string]: number;
9
- };
10
- }
11
- export declare const restEndpoint: AdapterEndpoint<AdapterRequestParams, ProviderResponseBody, import("../../config").SettingsMap>;
12
- export {};
@@ -1,51 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.restEndpoint = void 0;
4
- const adapter_1 = require("../../adapter");
5
- const transports_1 = require("../../transports");
6
- const DEFAULT_URL = 'https://api.coingecko.com/api/v3';
7
- const inputParameters = {
8
- coinid: {
9
- description: 'The CoinGecko id or array of ids of the coin(s) to query (Note: because of current limitations to use a dummy base will need to be supplied)',
10
- required: false,
11
- },
12
- base: {
13
- aliases: ['from', 'coin'],
14
- description: 'The symbol or array of symbols of the currency to query',
15
- required: true,
16
- },
17
- quote: {
18
- aliases: ['to', 'market'],
19
- description: 'The symbol of the currency to convert to',
20
- required: true,
21
- },
22
- };
23
- const restEndpointTransport = new transports_1.RestTransport({
24
- prepareRequest: (req) => {
25
- return {
26
- baseURL: DEFAULT_URL,
27
- url: '/simple/price',
28
- method: 'GET',
29
- params: {
30
- ids: req.requestContext.data.base,
31
- vs_currencies: req.requestContext.data.quote,
32
- },
33
- };
34
- },
35
- parseResponse: (req, res) => {
36
- return {
37
- data: res.data,
38
- statusCode: 200,
39
- result: res.data[req.requestContext.data.base]?.[req.requestContext.data.quote],
40
- };
41
- },
42
- options: {
43
- coalescing: true,
44
- },
45
- });
46
- exports.restEndpoint = new adapter_1.AdapterEndpoint({
47
- name: 'rest',
48
- aliases: ['qwe'],
49
- transport: restEndpointTransport,
50
- inputParameters,
51
- });
@@ -1,2 +0,0 @@
1
- export declare const DEFAULT_API_ENDPOINT = "https://api.coingecko.com/api/v3";
2
- export declare const PRO_API_ENDPOINT = "https://pro-api.coingecko.com/api/v3";