@chainlink/external-adapter-framework 0.0.19 → 0.0.20

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 (46) hide show
  1. package/adapter.d.ts +139 -0
  2. package/background-executor.d.ts +11 -0
  3. package/cache/factory.d.ts +6 -0
  4. package/cache/index.d.ts +94 -0
  5. package/cache/local.d.ts +23 -0
  6. package/cache/metrics.d.ts +27 -0
  7. package/cache/redis.d.ts +16 -0
  8. package/config/index.d.ts +258 -0
  9. package/config/provider-limits.d.ts +27 -0
  10. package/examples/bank-frick/accounts.d.ts +39 -0
  11. package/examples/bank-frick/config/index.d.ts +4 -0
  12. package/examples/bank-frick/index.d.ts +2 -0
  13. package/examples/bank-frick/util.d.ts +4 -0
  14. package/examples/coingecko/batch-warming.d.ts +7 -0
  15. package/examples/coingecko/index.d.ts +2 -0
  16. package/examples/coingecko/rest.d.ts +12 -0
  17. package/examples/ncfx/config/index.d.ts +12 -0
  18. package/examples/ncfx/index.d.ts +13 -0
  19. package/examples/ncfx/websocket.d.ts +47 -0
  20. package/index.d.ts +11 -0
  21. package/metrics/constants.d.ts +16 -0
  22. package/metrics/index.d.ts +15 -0
  23. package/metrics/util.d.ts +7 -0
  24. package/package.json +1 -1
  25. package/rate-limiting/background/fixed-frequency.d.ts +11 -0
  26. package/rate-limiting/index.d.ts +55 -0
  27. package/rate-limiting/metrics.d.ts +3 -0
  28. package/rate-limiting/request/simple-counting.d.ts +21 -0
  29. package/test.d.ts +1 -0
  30. package/transports/batch-warming.d.ts +35 -0
  31. package/transports/index.d.ts +71 -0
  32. package/transports/metrics.d.ts +22 -0
  33. package/transports/rest.d.ts +44 -0
  34. package/transports/util.d.ts +9 -0
  35. package/transports/websocket.d.ts +80 -0
  36. package/util/index.d.ts +12 -0
  37. package/util/logger.d.ts +42 -0
  38. package/util/request.d.ts +57 -0
  39. package/util/subscription-set/expiring-sorted-set.d.ts +22 -0
  40. package/util/subscription-set/subscription-set.d.ts +18 -0
  41. package/util/test-payload-loader.d.ts +25 -0
  42. package/validation/error.d.ts +50 -0
  43. package/validation/index.d.ts +5 -0
  44. package/validation/input-params.d.ts +15 -0
  45. package/validation/override-functions.d.ts +3 -0
  46. package/validation/validator.d.ts +47 -0
@@ -0,0 +1,22 @@
1
+ import { SubscriptionSet } from './subscription-set';
2
+ /**
3
+ * An object describing an entry in the expiring sorted set.
4
+ * @typeParam T - the type of the entry's value
5
+ */
6
+ interface ExpiringSortedSetEntry<T> {
7
+ value: T;
8
+ expirationTimestamp: number;
9
+ }
10
+ /**
11
+ * This class implements a set of unique items, each of which has an expiration timestamp.
12
+ * On reads, items that have expired will be deleted from the set and not returned.
13
+ *
14
+ * @typeParam T - the type of the set entries' values
15
+ */
16
+ export declare class ExpiringSortedSet<T> implements SubscriptionSet<T> {
17
+ map: Map<string, ExpiringSortedSetEntry<T>>;
18
+ add(key: string, value: T, ttl: number): void;
19
+ get(key: string): T | undefined;
20
+ getAll(): T[];
21
+ }
22
+ export {};
@@ -0,0 +1,18 @@
1
+ import { PromiseOrValue } from '..';
2
+ import { AdapterConfig } from '../../config';
3
+ /**
4
+ * Set to hold items to subscribe to from a provider (regardless of protocol)
5
+ */
6
+ export interface SubscriptionSet<T> {
7
+ /** Add a new subscription to the set */
8
+ add(key: string, value: T, ttl: number): PromiseOrValue<void>;
9
+ /** Get a specific subscription from the set */
10
+ get(key: string): PromiseOrValue<T | undefined>;
11
+ /** Get all subscriptions from the set as a list */
12
+ getAll(): PromiseOrValue<T[]>;
13
+ }
14
+ export declare class SubscriptionSetFactory {
15
+ private cacheType;
16
+ constructor(config: AdapterConfig);
17
+ buildSet<T>(): SubscriptionSet<T>;
18
+ }
@@ -0,0 +1,25 @@
1
+ import { AdapterRequestData } from './request';
2
+ /**
3
+ * The test payload read in from filesystem
4
+ */
5
+ export interface Payload {
6
+ requests: Array<AdapterRequestData>;
7
+ }
8
+ /**
9
+ * Test payload with discriminated union so we can tell when we should just do
10
+ * a simple liveness check rather than a sample request
11
+ */
12
+ declare type TestPayload = (Payload & {
13
+ isDefault: false;
14
+ }) | {
15
+ isDefault: true;
16
+ };
17
+ /**
18
+ * Load in a JSON file containing a test payload for the current adapter,
19
+ * used in healthchecks to make sample requests
20
+ *
21
+ * @param fileName - name of file that contains the test payload data for the smoke endpoint
22
+ * @returns the parsed payload with individual requests
23
+ */
24
+ export declare function loadTestPayload(fileName?: string): TestPayload;
25
+ export {};
@@ -0,0 +1,50 @@
1
+ import { HttpRequestType } from '../metrics/constants';
2
+ declare type ErrorBasic = {
3
+ name: string;
4
+ message: string;
5
+ };
6
+ declare type ErrorFull = ErrorBasic & {
7
+ stack: string;
8
+ cause: string;
9
+ };
10
+ export declare type AdapterErrorResponse = {
11
+ jobRunID: string;
12
+ status: string;
13
+ statusCode: number;
14
+ providerStatusCode?: number;
15
+ error: ErrorBasic | ErrorFull;
16
+ };
17
+ export declare class AdapterError extends Error {
18
+ jobRunID: string;
19
+ status: string;
20
+ statusCode: number;
21
+ cause: unknown;
22
+ url?: string;
23
+ errorResponse: unknown;
24
+ feedID?: string;
25
+ providerStatusCode?: number;
26
+ metricsLabel?: HttpRequestType;
27
+ name: string;
28
+ message: string;
29
+ constructor({ jobRunID, status, statusCode, name, message, cause, url, errorResponse, feedID, providerStatusCode, metricsLabel, }: Partial<AdapterError>);
30
+ toJSONResponse(): AdapterErrorResponse;
31
+ }
32
+ export declare class AdapterInputError extends AdapterError {
33
+ constructor(input: Partial<AdapterError>);
34
+ }
35
+ export declare class AdapterRateLimitError extends AdapterError {
36
+ constructor(input: Partial<AdapterError>);
37
+ }
38
+ export declare class AdapterTimeoutError extends AdapterError {
39
+ constructor(input: Partial<AdapterError>);
40
+ }
41
+ export declare class AdapterDataProviderError extends AdapterError {
42
+ constructor(input: Partial<AdapterError>);
43
+ }
44
+ export declare class AdapterConnectionError extends AdapterError {
45
+ constructor(input: Partial<AdapterError>);
46
+ }
47
+ export declare class AdapterCustomError extends AdapterError {
48
+ constructor(input: Partial<AdapterError>);
49
+ }
50
+ export {};
@@ -0,0 +1,5 @@
1
+ import { FastifyReply, FastifyRequest } from 'fastify';
2
+ import { AdapterMiddlewareBuilder } from '../util/request';
3
+ export { InputParameters } from './input-params';
4
+ export declare const validatorMiddleware: AdapterMiddlewareBuilder;
5
+ export declare const errorCatchingMiddleware: (err: Error, req: FastifyRequest, res: FastifyReply) => void;
@@ -0,0 +1,15 @@
1
+ export declare type Override = Map<string, Map<string, string>>;
2
+ export declare type InputParameter = {
3
+ aliases?: string[];
4
+ description?: string;
5
+ type?: 'bigint' | 'boolean' | 'array' | 'number' | 'object' | 'string';
6
+ required?: boolean;
7
+ options?: unknown[];
8
+ default?: unknown;
9
+ dependsOn?: string[];
10
+ exclusive?: string[];
11
+ };
12
+ export declare type InputParameters = {
13
+ [name: string]: InputParameter | boolean | string[];
14
+ };
15
+ export declare const baseInputParameters: InputParameters;
@@ -0,0 +1,3 @@
1
+ import { Adapter } from '../adapter';
2
+ import { AdapterRequest } from '../util/request';
3
+ export declare const performSymbolOverrides: (adapter: Adapter, req: AdapterRequest) => void;
@@ -0,0 +1,47 @@
1
+ import { AdapterError, AdapterErrorResponse } from './error';
2
+ import { InputParameters, Override } from './input-params';
3
+ export declare type OverrideType = 'overrides' | 'tokenOverrides' | 'includes';
4
+ declare type InputType = {
5
+ id?: string;
6
+ data?: any;
7
+ };
8
+ export interface ValidatorOptions {
9
+ shouldThrowError?: boolean;
10
+ includes?: any[];
11
+ overrides?: any;
12
+ }
13
+ export declare type IncludePair = {
14
+ from: string;
15
+ to: string;
16
+ adapters?: string[];
17
+ inverse?: boolean;
18
+ tokens?: boolean;
19
+ };
20
+ export declare type Includes = {
21
+ from: string;
22
+ to: string;
23
+ includes: IncludePair[];
24
+ };
25
+ export declare class Validator {
26
+ input: InputType;
27
+ inputConfigs: InputParameters;
28
+ inputOptions: Record<string, any[]>;
29
+ validatorOptions: ValidatorOptions;
30
+ validated: any;
31
+ error: AdapterError | undefined;
32
+ errored: AdapterErrorResponse | undefined;
33
+ constructor(input?: InputType, inputConfigs?: {}, inputOptions?: {}, validatorOptions?: ValidatorOptions);
34
+ validateInput(): void;
35
+ validateOverrides(path: 'overrides' | 'tokenOverrides', preset: Record<string, any>): void;
36
+ checkDuplicateInputParams(inputConfig: InputParameters): void;
37
+ validateIncludeOverrides(): void;
38
+ parseError(error: unknown): void;
39
+ formatOverride: (param: any) => Override;
40
+ formatIncludeOverrides: (param: any) => Override;
41
+ throwInvalid: (message: string) => void;
42
+ validateObjectParam(key: string, shouldThrowError?: boolean): void;
43
+ validateOptionalParam(param: any, key: string, options: any[]): void;
44
+ validateRequiredParam(param: any, key: string, options: any[]): void;
45
+ getUsedKey(key: string, keyArray: string[]): string | undefined;
46
+ }
47
+ export {};