@chainlink/external-adapter-framework 0.5.0 → 0.5.2
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.
- package/adapter/basic.d.ts +90 -0
- package/adapter/basic.js +325 -0
- package/adapter/basic.js.map +1 -0
- package/adapter/endpoint.d.ts +17 -0
- package/adapter/endpoint.js +20 -0
- package/adapter/endpoint.js.map +1 -0
- package/adapter/index.d.ts +4 -0
- package/adapter/index.js +21 -0
- package/adapter/index.js.map +1 -0
- package/adapter/price.d.ts +77 -0
- package/adapter/price.js +88 -0
- package/adapter/price.js.map +1 -0
- package/adapter/types.d.ts +124 -0
- package/adapter/types.js +3 -0
- package/adapter/types.js.map +1 -0
- package/background-executor.d.ts +9 -0
- package/background-executor.js +97 -0
- package/background-executor.js.map +1 -0
- package/cache/factory.d.ts +6 -0
- package/cache/factory.js +24 -0
- package/cache/factory.js.map +1 -0
- package/cache/index.d.ts +87 -0
- package/cache/index.js +133 -0
- package/cache/index.js.map +1 -0
- package/cache/local.d.ts +23 -0
- package/cache/local.js +84 -0
- package/cache/local.js.map +1 -0
- package/cache/metrics.d.ts +27 -0
- package/cache/metrics.js +121 -0
- package/cache/metrics.js.map +1 -0
- package/cache/redis.d.ts +16 -0
- package/cache/redis.js +101 -0
- package/cache/redis.js.map +1 -0
- package/config/index.d.ts +298 -0
- package/config/index.js +359 -0
- package/config/index.js.map +1 -0
- package/config/provider-limits.d.ts +27 -0
- package/config/provider-limits.js +75 -0
- package/config/provider-limits.js.map +1 -0
- package/examples/bank-frick/accounts.d.ts +45 -0
- package/examples/bank-frick/accounts.js +203 -0
- package/examples/bank-frick/accounts.js.map +1 -0
- package/examples/bank-frick/config/index.d.ts +17 -0
- package/examples/bank-frick/config/index.js +55 -0
- package/examples/bank-frick/config/index.js.map +1 -0
- package/examples/bank-frick/index.d.ts +2 -0
- package/examples/bank-frick/index.js +16 -0
- package/examples/bank-frick/index.js.map +1 -0
- package/examples/bank-frick/util.d.ts +4 -0
- package/examples/bank-frick/util.js +40 -0
- package/examples/bank-frick/util.js.map +1 -0
- package/examples/coingecko/src/config/index.d.ts +2 -0
- package/examples/coingecko/src/config/index.js +6 -0
- package/examples/coingecko/src/config/index.js.map +1 -0
- package/examples/coingecko/src/config/overrides.json +10825 -0
- package/examples/coingecko/src/crypto-utils.d.ts +62 -0
- package/examples/coingecko/src/crypto-utils.js +60 -0
- package/examples/coingecko/src/crypto-utils.js.map +1 -0
- package/examples/coingecko/src/endpoint/coins.d.ts +26 -0
- package/examples/coingecko/src/endpoint/coins.js +37 -0
- package/examples/coingecko/src/endpoint/coins.js.map +1 -0
- package/examples/coingecko/src/endpoint/crypto-marketcap.d.ts +3 -0
- package/examples/coingecko/src/endpoint/crypto-marketcap.js +30 -0
- package/examples/coingecko/src/endpoint/crypto-marketcap.js.map +1 -0
- package/examples/coingecko/src/endpoint/crypto-volume.d.ts +3 -0
- package/examples/coingecko/src/endpoint/crypto-volume.js +30 -0
- package/examples/coingecko/src/endpoint/crypto-volume.js.map +1 -0
- package/examples/coingecko/src/endpoint/crypto.d.ts +3 -0
- package/examples/coingecko/src/endpoint/crypto.js +28 -0
- package/examples/coingecko/src/endpoint/crypto.js.map +1 -0
- package/examples/coingecko/src/endpoint/dominance.d.ts +3 -0
- package/examples/coingecko/src/endpoint/dominance.js +28 -0
- package/examples/coingecko/src/endpoint/dominance.js.map +1 -0
- package/examples/coingecko/src/endpoint/global-marketcap.d.ts +3 -0
- package/examples/coingecko/src/endpoint/global-marketcap.js +28 -0
- package/examples/coingecko/src/endpoint/global-marketcap.js.map +1 -0
- package/examples/coingecko/src/endpoint/index.d.ts +6 -0
- package/examples/coingecko/src/endpoint/index.js +16 -0
- package/examples/coingecko/src/endpoint/index.js.map +1 -0
- package/examples/coingecko/src/global-utils.d.ts +42 -0
- package/examples/coingecko/src/global-utils.js +47 -0
- package/examples/coingecko/src/global-utils.js.map +1 -0
- package/examples/coingecko/src/index.d.ts +4 -0
- package/examples/coingecko/src/index.js +19 -0
- package/examples/coingecko/src/index.js.map +1 -0
- package/examples/cryptocompare/src/config/index.d.ts +2 -0
- package/examples/cryptocompare/src/config/index.js +6 -0
- package/examples/cryptocompare/src/config/index.js.map +1 -0
- package/examples/cryptocompare/src/endpoints/crypto.d.ts +40 -0
- package/examples/cryptocompare/src/endpoints/crypto.js +54 -0
- package/examples/cryptocompare/src/endpoints/crypto.js.map +1 -0
- package/examples/cryptocompare/src/endpoints/index.d.ts +1 -0
- package/examples/cryptocompare/src/endpoints/index.js +6 -0
- package/examples/cryptocompare/src/endpoints/index.js.map +1 -0
- package/examples/cryptocompare/src/index.d.ts +4 -0
- package/examples/cryptocompare/src/index.js +14 -0
- package/examples/cryptocompare/src/index.js.map +1 -0
- package/examples/genesis/config/index.d.ts +7 -0
- package/examples/genesis/config/index.js +11 -0
- package/examples/genesis/config/index.js.map +1 -0
- package/examples/genesis/index.d.ts +2 -0
- package/examples/genesis/index.js +13 -0
- package/examples/genesis/index.js.map +1 -0
- package/examples/genesis/sseStream.d.ts +27 -0
- package/examples/genesis/sseStream.js +149 -0
- package/examples/genesis/sseStream.js.map +1 -0
- package/index.d.ts +17 -0
- package/index.js +174 -0
- package/index.js.map +1 -0
- package/metrics/constants.d.ts +16 -0
- package/metrics/constants.js +26 -0
- package/metrics/constants.js.map +1 -0
- package/metrics/index.d.ts +19 -0
- package/metrics/index.js +139 -0
- package/metrics/index.js.map +1 -0
- package/metrics/util.d.ts +7 -0
- package/metrics/util.js +10 -0
- package/metrics/util.js.map +1 -0
- package/package.json +50 -42
- package/rate-limiting/background/fixed-frequency.d.ts +10 -0
- package/rate-limiting/background/fixed-frequency.js +36 -0
- package/rate-limiting/background/fixed-frequency.js.map +1 -0
- package/rate-limiting/index.d.ts +56 -0
- package/rate-limiting/index.js +86 -0
- package/rate-limiting/index.js.map +1 -0
- package/rate-limiting/metrics.d.ts +3 -0
- package/rate-limiting/metrics.js +45 -0
- package/rate-limiting/metrics.js.map +1 -0
- package/rate-limiting/request/simple-counting.d.ts +20 -0
- package/rate-limiting/request/simple-counting.js +63 -0
- package/rate-limiting/request/simple-counting.js.map +1 -0
- package/transports/batch-warming.d.ts +53 -0
- package/transports/batch-warming.js +136 -0
- package/transports/batch-warming.js.map +1 -0
- package/transports/index.d.ts +108 -0
- package/transports/index.js +56 -0
- package/transports/index.js.map +1 -0
- package/transports/metrics.d.ts +25 -0
- package/transports/metrics.js +122 -0
- package/transports/metrics.js.map +1 -0
- package/transports/rest.d.ts +68 -0
- package/transports/rest.js +131 -0
- package/transports/rest.js.map +1 -0
- package/transports/routing.d.ts +21 -0
- package/transports/routing.js +50 -0
- package/transports/routing.js.map +1 -0
- package/transports/sse.d.ts +61 -0
- package/transports/sse.js +97 -0
- package/transports/sse.js.map +1 -0
- package/transports/util.d.ts +9 -0
- package/transports/util.js +87 -0
- package/transports/util.js.map +1 -0
- package/transports/websocket.d.ts +95 -0
- package/transports/websocket.js +164 -0
- package/transports/websocket.js.map +1 -0
- package/util/censor/censor-list.d.ts +9 -0
- package/util/censor/censor-list.js +13 -0
- package/util/censor/censor-list.js.map +1 -0
- package/util/index.d.ts +13 -0
- package/util/index.js +38 -0
- package/util/index.js.map +1 -0
- package/util/logger.d.ts +49 -0
- package/util/logger.js +123 -0
- package/util/logger.js.map +1 -0
- package/util/request.d.ts +138 -0
- package/util/request.js +3 -0
- package/util/request.js.map +1 -0
- package/util/subscription-set/expiring-sorted-set.d.ts +21 -0
- package/util/subscription-set/expiring-sorted-set.js +36 -0
- package/util/subscription-set/expiring-sorted-set.js.map +1 -0
- package/util/subscription-set/redis-sorted-set.d.ts +9 -0
- package/util/subscription-set/redis-sorted-set.js +29 -0
- package/util/subscription-set/redis-sorted-set.js.map +1 -0
- package/util/subscription-set/subscription-set.d.ts +19 -0
- package/util/subscription-set/subscription-set.js +28 -0
- package/util/subscription-set/subscription-set.js.map +1 -0
- package/util/test-payload-loader.d.ts +26 -0
- package/util/test-payload-loader.js +85 -0
- package/util/test-payload-loader.js.map +1 -0
- package/validation/error.d.ts +48 -0
- package/validation/error.js +78 -0
- package/validation/error.js.map +1 -0
- package/validation/index.d.ts +5 -0
- package/validation/index.js +102 -0
- package/validation/index.js.map +1 -0
- package/validation/input-params.d.ts +14 -0
- package/validation/input-params.js +3 -0
- package/validation/input-params.js.map +1 -0
- package/validation/input-validator.d.ts +16 -0
- package/validation/input-validator.js +123 -0
- package/validation/input-validator.js.map +1 -0
- package/README.md +0 -102
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import Redis from 'ioredis';
|
|
2
|
+
import { SubscriptionSet } from './subscription-set';
|
|
3
|
+
export declare class RedisSubscriptionSet<T> implements SubscriptionSet<T> {
|
|
4
|
+
private redisClient;
|
|
5
|
+
private subscriptionSetKey;
|
|
6
|
+
constructor(redisClient: Redis, subscriptionSetKey: string);
|
|
7
|
+
add(key: string, value: T, ttl: number): Promise<undefined>;
|
|
8
|
+
getAll(): Promise<T[]>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RedisSubscriptionSet = void 0;
|
|
4
|
+
// Delimiter used to store both key and value in redis sorted set string field together
|
|
5
|
+
const DELIMITER = '>';
|
|
6
|
+
class RedisSubscriptionSet {
|
|
7
|
+
constructor(redisClient, subscriptionSetKey) {
|
|
8
|
+
this.redisClient = redisClient;
|
|
9
|
+
this.subscriptionSetKey = subscriptionSetKey;
|
|
10
|
+
}
|
|
11
|
+
async add(key, value, ttl) {
|
|
12
|
+
const storedValue = `${key}${DELIMITER}${JSON.stringify(value)}`;
|
|
13
|
+
await this.redisClient.zadd(this.subscriptionSetKey, Date.now() + ttl, storedValue);
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
async getAll() {
|
|
17
|
+
// Remove expired keys from sorted set
|
|
18
|
+
await this.redisClient.zremrangebyscore(this.subscriptionSetKey, '-inf', Date.now());
|
|
19
|
+
const parsedRequests = [];
|
|
20
|
+
const validEntries = await this.redisClient.zrange(this.subscriptionSetKey, 0, -1);
|
|
21
|
+
validEntries.forEach((entry) => {
|
|
22
|
+
// Separate request and cache key prior to populating results array
|
|
23
|
+
parsedRequests.push(JSON.parse(entry.split(DELIMITER)[1]));
|
|
24
|
+
});
|
|
25
|
+
return parsedRequests;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
exports.RedisSubscriptionSet = RedisSubscriptionSet;
|
|
29
|
+
//# sourceMappingURL=redis-sorted-set.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"redis-sorted-set.js","sourceRoot":"","sources":["../../../../src/util/subscription-set/redis-sorted-set.ts"],"names":[],"mappings":";;;AAGA,uFAAuF;AACvF,MAAM,SAAS,GAAG,GAAG,CAAA;AAErB,MAAa,oBAAoB;IAK/B,YAAY,WAAkB,EAAE,kBAA0B;QACxD,IAAI,CAAC,WAAW,GAAG,WAAW,CAAA;QAC9B,IAAI,CAAC,kBAAkB,GAAG,kBAAkB,CAAA;IAC9C,CAAC;IAED,KAAK,CAAC,GAAG,CAAC,GAAW,EAAE,KAAQ,EAAE,GAAW;QAC1C,MAAM,WAAW,GAAG,GAAG,GAAG,GAAG,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,CAAA;QAChE,MAAM,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,kBAAkB,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,GAAG,EAAE,WAAW,CAAC,CAAA;QACnF,OAAM;IACR,CAAC;IAED,KAAK,CAAC,MAAM;QACV,sCAAsC;QACtC,MAAM,IAAI,CAAC,WAAW,CAAC,gBAAgB,CAAC,IAAI,CAAC,kBAAkB,EAAE,MAAM,EAAE,IAAI,CAAC,GAAG,EAAE,CAAC,CAAA;QACpF,MAAM,cAAc,GAAQ,EAAE,CAAA;QAC9B,MAAM,YAAY,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,IAAI,CAAC,kBAAkB,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAA;QAClF,YAAY,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE;YAC7B,mEAAmE;YACnE,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAM,CAAC,CAAA;QACjE,CAAC,CAAC,CAAA;QACF,OAAO,cAAc,CAAA;IACvB,CAAC;CACF;AA3BD,oDA2BC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import Redis from 'ioredis';
|
|
2
|
+
import { PromiseOrValue } from '..';
|
|
3
|
+
import { AdapterConfig } from '../../config';
|
|
4
|
+
/**
|
|
5
|
+
* Set to hold items to subscribe to from a provider (regardless of protocol)
|
|
6
|
+
*/
|
|
7
|
+
export interface SubscriptionSet<T> {
|
|
8
|
+
/** Add a new subscription to the set */
|
|
9
|
+
add(key: string, value: T, ttl: number): PromiseOrValue<void>;
|
|
10
|
+
/** Get all subscriptions from the set as a list */
|
|
11
|
+
getAll(): PromiseOrValue<T[]>;
|
|
12
|
+
}
|
|
13
|
+
export declare class SubscriptionSetFactory {
|
|
14
|
+
private cacheType;
|
|
15
|
+
private redisClient?;
|
|
16
|
+
private adapterName?;
|
|
17
|
+
constructor(config: AdapterConfig, adapterName: string, redisClient?: Redis);
|
|
18
|
+
buildSet<T>(endpointName: string): SubscriptionSet<T>;
|
|
19
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SubscriptionSetFactory = void 0;
|
|
4
|
+
const expiring_sorted_set_1 = require("./expiring-sorted-set");
|
|
5
|
+
const redis_sorted_set_1 = require("./redis-sorted-set");
|
|
6
|
+
class SubscriptionSetFactory {
|
|
7
|
+
constructor(config, adapterName, redisClient) {
|
|
8
|
+
this.cacheType = config.CACHE_TYPE;
|
|
9
|
+
this.redisClient = redisClient;
|
|
10
|
+
this.adapterName = adapterName;
|
|
11
|
+
}
|
|
12
|
+
buildSet(endpointName) {
|
|
13
|
+
switch (this.cacheType) {
|
|
14
|
+
case 'local':
|
|
15
|
+
return new expiring_sorted_set_1.ExpiringSortedSet();
|
|
16
|
+
case 'redis': {
|
|
17
|
+
if (!this.redisClient) {
|
|
18
|
+
throw new Error('Redis client undefined. Cannot create Redis subscription set');
|
|
19
|
+
}
|
|
20
|
+
// Identifier key used for the subscription set in redis
|
|
21
|
+
const subscriptionSetKey = `${this.adapterName}-${endpointName}-subscriptionSet`;
|
|
22
|
+
return new redis_sorted_set_1.RedisSubscriptionSet(this.redisClient, subscriptionSetKey);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
exports.SubscriptionSetFactory = SubscriptionSetFactory;
|
|
28
|
+
//# sourceMappingURL=subscription-set.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"subscription-set.js","sourceRoot":"","sources":["../../../../src/util/subscription-set/subscription-set.ts"],"names":[],"mappings":";;;AAGA,+DAAyD;AACzD,yDAAyD;AAazD,MAAa,sBAAsB;IAKjC,YAAY,MAAqB,EAAE,WAAmB,EAAE,WAAmB;QACzE,IAAI,CAAC,SAAS,GAAG,MAAM,CAAC,UAAU,CAAA;QAClC,IAAI,CAAC,WAAW,GAAG,WAAW,CAAA;QAC9B,IAAI,CAAC,WAAW,GAAG,WAAW,CAAA;IAChC,CAAC;IAED,QAAQ,CAAI,YAAoB;QAC9B,QAAQ,IAAI,CAAC,SAAS,EAAE;YACtB,KAAK,OAAO;gBACV,OAAO,IAAI,uCAAiB,EAAK,CAAA;YACnC,KAAK,OAAO,CAAC,CAAC;gBACZ,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE;oBACrB,MAAM,IAAI,KAAK,CAAC,8DAA8D,CAAC,CAAA;iBAChF;gBACD,wDAAwD;gBACxD,MAAM,kBAAkB,GAAG,GAAG,IAAI,CAAC,WAAW,IAAI,YAAY,kBAAkB,CAAA;gBAChF,OAAO,IAAI,uCAAoB,CAAI,IAAI,CAAC,WAAW,EAAE,kBAAkB,CAAC,CAAA;aACzE;SACF;IACH,CAAC;CACF;AAzBD,wDAyBC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
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 declare function resolvePayload(fileName?: string): Payload | null;
|
|
26
|
+
export {};
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.resolvePayload = exports.loadTestPayload = void 0;
|
|
7
|
+
const ajv_1 = __importDefault(require("ajv"));
|
|
8
|
+
const fs_1 = __importDefault(require("fs"));
|
|
9
|
+
const path_1 = __importDefault(require("path"));
|
|
10
|
+
const logger_1 = require("./logger");
|
|
11
|
+
const logger = (0, logger_1.makeLogger)('TestPayloadLoader');
|
|
12
|
+
/**
|
|
13
|
+
* Load in a JSON file containing a test payload for the current adapter,
|
|
14
|
+
* used in healthchecks to make sample requests
|
|
15
|
+
*
|
|
16
|
+
* @param fileName - name of file that contains the test payload data for the smoke endpoint
|
|
17
|
+
* @returns the parsed payload with individual requests
|
|
18
|
+
*/
|
|
19
|
+
function loadTestPayload(fileName) {
|
|
20
|
+
const ajv = new ajv_1.default();
|
|
21
|
+
const schema = {
|
|
22
|
+
type: 'object',
|
|
23
|
+
required: ['requests'],
|
|
24
|
+
properties: {
|
|
25
|
+
requests: {
|
|
26
|
+
type: 'array',
|
|
27
|
+
items: {
|
|
28
|
+
type: 'object',
|
|
29
|
+
required: [],
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
const validate = ajv.compile(schema);
|
|
35
|
+
try {
|
|
36
|
+
const payload = resolvePayload(fileName);
|
|
37
|
+
if (!validate(payload) || !payload?.requests) {
|
|
38
|
+
throw Error(JSON.stringify(validate?.errors || 'Could not validate schema for test payload'));
|
|
39
|
+
}
|
|
40
|
+
return { ...payload, isDefault: false };
|
|
41
|
+
}
|
|
42
|
+
catch (e) {
|
|
43
|
+
logger.warn(`Could not load payload: ${e.message}`);
|
|
44
|
+
logger.warn('Falling back to default empty payload');
|
|
45
|
+
return { isDefault: true };
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
exports.loadTestPayload = loadTestPayload;
|
|
49
|
+
function resolvePayload(fileName) {
|
|
50
|
+
try {
|
|
51
|
+
let payload = null;
|
|
52
|
+
// Find test payload by specified name, fallback to default names if not found
|
|
53
|
+
if (fileName && fs_1.default.existsSync(path_1.default.join(process.cwd(), fileName))) {
|
|
54
|
+
payload = require(path_1.default.join(process.cwd(), fileName));
|
|
55
|
+
}
|
|
56
|
+
else if (fileName && fs_1.default.existsSync(`./${fileName}`)) {
|
|
57
|
+
payload = require(`./${fileName}`);
|
|
58
|
+
}
|
|
59
|
+
// Search for test payload js first if no filename specified or found
|
|
60
|
+
else if (fs_1.default.existsSync(path_1.default.resolve('.', 'test-payload.js'))) {
|
|
61
|
+
payload = require(path_1.default.join(process.cwd(), 'test-payload.js'));
|
|
62
|
+
}
|
|
63
|
+
else if (fs_1.default.existsSync(`./test-payload.js`)) {
|
|
64
|
+
payload = require(`./test-payload.js`);
|
|
65
|
+
}
|
|
66
|
+
// Search for test payload json second if no filename specified or found
|
|
67
|
+
else if (fs_1.default.existsSync(path_1.default.join(process.cwd(), 'test-payload.json'))) {
|
|
68
|
+
payload = require(path_1.default.join(process.cwd(), 'test-payload.json'));
|
|
69
|
+
}
|
|
70
|
+
else if (fs_1.default.existsSync(`./test-payload.json`)) {
|
|
71
|
+
payload = require(`./test-payload.json`);
|
|
72
|
+
}
|
|
73
|
+
if (typeof payload === 'string') {
|
|
74
|
+
return JSON.parse(payload);
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
return payload;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
catch {
|
|
81
|
+
return null;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
exports.resolvePayload = resolvePayload;
|
|
85
|
+
//# sourceMappingURL=test-payload-loader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test-payload-loader.js","sourceRoot":"","sources":["../../../src/util/test-payload-loader.ts"],"names":[],"mappings":";;;;;;AAAA,8CAAqB;AACrB,4CAAmB;AACnB,gDAAuB;AACvB,qCAAqC;AAGrC,MAAM,MAAM,GAAG,IAAA,mBAAU,EAAC,mBAAmB,CAAC,CAAA;AAe9C;;;;;;GAMG;AACH,SAAgB,eAAe,CAAC,QAAiB;IAC/C,MAAM,GAAG,GAAG,IAAI,aAAG,EAAE,CAAA;IACrB,MAAM,MAAM,GAAG;QACb,IAAI,EAAE,QAA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,EAAE;YACrD,OAAO,GAAG,OAAO,CAAC,KAAK,QAAQ,EAAE,CAAC,CAAA;SACnC;QACD,qEAAqE;aAChE,IAAI,YAAE,CAAC,UAAU,CAAC,cAAI,CAAC,OAAO,CAAC,GAAG,EAAE,iBAAiB,CAAC,CAAC,EAAE;YAC5D,OAAO,GAAG,OAAO,CAAC,cAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,iBAAiB,CAAC,CAAC,CAAA;SAC/D;aAAM,IAAI,YAAE,CAAC,UAAU,CAAC,mBAAmB,CAAC,EAAE;YAC7C,OAAO,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAA;SACvC;QACD,wEAAwE;aACnE,IAAI,YAAE,CAAC,UAAU,CAAC,cAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,mBAAmB,CAAC,CAAC,EAAE;YACrE,OAAO,GAAG,OAAO,CAAC,cAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,mBAAmB,CAAC,CAAC,CAAA;SACjE;aAAM,IAAI,YAAE,CAAC,UAAU,CAAC,qBAAqB,CAAC,EAAE;YAC/C,OAAO,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAAA;SACzC;QACD,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE;YAC/B,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;SAC3B;aAAM;YACL,OAAO,OAAO,CAAA;SACf;KACF;IAAC,MAAM;QACN,OAAO,IAAI,CAAA;KACZ;AACH,CAAC;AA7BD,wCA6BC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
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
|
+
status: string;
|
|
12
|
+
statusCode: number;
|
|
13
|
+
providerStatusCode?: number;
|
|
14
|
+
error: ErrorBasic | ErrorFull;
|
|
15
|
+
};
|
|
16
|
+
export declare class AdapterError extends Error {
|
|
17
|
+
status: string;
|
|
18
|
+
statusCode: number;
|
|
19
|
+
cause: unknown;
|
|
20
|
+
url?: string;
|
|
21
|
+
errorResponse: unknown;
|
|
22
|
+
feedID?: string;
|
|
23
|
+
providerStatusCode?: number;
|
|
24
|
+
metricsLabel?: HttpRequestType;
|
|
25
|
+
name: string;
|
|
26
|
+
message: string;
|
|
27
|
+
constructor({ status, statusCode, name, message, cause, url, errorResponse, feedID, providerStatusCode, metricsLabel, }: Partial<AdapterError>);
|
|
28
|
+
toJSONResponse(): AdapterErrorResponse;
|
|
29
|
+
}
|
|
30
|
+
export declare class AdapterInputError extends AdapterError {
|
|
31
|
+
constructor(input: Partial<AdapterError>);
|
|
32
|
+
}
|
|
33
|
+
export declare class AdapterRateLimitError extends AdapterError {
|
|
34
|
+
constructor(input: Partial<AdapterError>);
|
|
35
|
+
}
|
|
36
|
+
export declare class AdapterTimeoutError extends AdapterError {
|
|
37
|
+
constructor(input: Partial<AdapterError>);
|
|
38
|
+
}
|
|
39
|
+
export declare class AdapterDataProviderError extends AdapterError {
|
|
40
|
+
constructor(input: Partial<AdapterError>);
|
|
41
|
+
}
|
|
42
|
+
export declare class AdapterConnectionError extends AdapterError {
|
|
43
|
+
constructor(input: Partial<AdapterError>);
|
|
44
|
+
}
|
|
45
|
+
export declare class AdapterCustomError extends AdapterError {
|
|
46
|
+
constructor(input: Partial<AdapterError>);
|
|
47
|
+
}
|
|
48
|
+
export {};
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AdapterCustomError = exports.AdapterConnectionError = exports.AdapterDataProviderError = exports.AdapterTimeoutError = exports.AdapterRateLimitError = exports.AdapterInputError = exports.AdapterError = void 0;
|
|
4
|
+
const constants_1 = require("../metrics/constants");
|
|
5
|
+
class AdapterError extends Error {
|
|
6
|
+
constructor({ status = 'errored', statusCode = 500, name = 'AdapterError', message = 'There was an unexpected error in the adapter.', cause, url, errorResponse, feedID, providerStatusCode, metricsLabel = constants_1.HttpRequestType.ADAPTER_ERROR, }) {
|
|
7
|
+
super(message);
|
|
8
|
+
this.status = status;
|
|
9
|
+
this.statusCode = statusCode;
|
|
10
|
+
this.name = name;
|
|
11
|
+
this.message = message;
|
|
12
|
+
this.cause = cause;
|
|
13
|
+
if (url) {
|
|
14
|
+
this.url = url;
|
|
15
|
+
}
|
|
16
|
+
if (feedID) {
|
|
17
|
+
this.feedID = feedID;
|
|
18
|
+
}
|
|
19
|
+
this.errorResponse = errorResponse;
|
|
20
|
+
this.providerStatusCode = providerStatusCode;
|
|
21
|
+
this.metricsLabel = metricsLabel;
|
|
22
|
+
}
|
|
23
|
+
toJSONResponse() {
|
|
24
|
+
const showDebugInfo = process.env['NODE_ENV'] === 'development' || process.env['DEBUG'] === 'true';
|
|
25
|
+
const errorBasic = {
|
|
26
|
+
name: this.name,
|
|
27
|
+
message: this.message,
|
|
28
|
+
url: this.url,
|
|
29
|
+
errorResponse: this.errorResponse,
|
|
30
|
+
feedID: this.feedID,
|
|
31
|
+
};
|
|
32
|
+
const errorFull = { ...errorBasic, stack: this.stack, cause: this.cause };
|
|
33
|
+
return {
|
|
34
|
+
status: this.status,
|
|
35
|
+
statusCode: this.statusCode,
|
|
36
|
+
providerStatusCode: this.providerStatusCode,
|
|
37
|
+
error: showDebugInfo ? errorFull : errorBasic,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
exports.AdapterError = AdapterError;
|
|
42
|
+
class AdapterInputError extends AdapterError {
|
|
43
|
+
constructor(input) {
|
|
44
|
+
super({ ...input, metricsLabel: constants_1.HttpRequestType.INPUT_ERROR });
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
exports.AdapterInputError = AdapterInputError;
|
|
48
|
+
class AdapterRateLimitError extends AdapterError {
|
|
49
|
+
constructor(input) {
|
|
50
|
+
super({ ...input, metricsLabel: constants_1.HttpRequestType.RATE_LIMIT_ERROR });
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
exports.AdapterRateLimitError = AdapterRateLimitError;
|
|
54
|
+
class AdapterTimeoutError extends AdapterError {
|
|
55
|
+
constructor(input) {
|
|
56
|
+
super({ ...input, metricsLabel: constants_1.HttpRequestType.TIMEOUT_ERROR });
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
exports.AdapterTimeoutError = AdapterTimeoutError;
|
|
60
|
+
class AdapterDataProviderError extends AdapterError {
|
|
61
|
+
constructor(input) {
|
|
62
|
+
super({ ...input, metricsLabel: constants_1.HttpRequestType.DP_ERROR });
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
exports.AdapterDataProviderError = AdapterDataProviderError;
|
|
66
|
+
class AdapterConnectionError extends AdapterError {
|
|
67
|
+
constructor(input) {
|
|
68
|
+
super({ ...input, metricsLabel: constants_1.HttpRequestType.CONNECTION_ERROR });
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
exports.AdapterConnectionError = AdapterConnectionError;
|
|
72
|
+
class AdapterCustomError extends AdapterError {
|
|
73
|
+
constructor(input) {
|
|
74
|
+
super({ ...input, metricsLabel: constants_1.HttpRequestType.CUSTOM_ERROR });
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
exports.AdapterCustomError = AdapterCustomError;
|
|
78
|
+
//# sourceMappingURL=error.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error.js","sourceRoot":"","sources":["../../../src/validation/error.ts"],"names":[],"mappings":";;;AAAA,oDAAsD;AAkBtD,MAAa,YAAa,SAAQ,KAAK;IAarC,YAAY,EACV,MAAM,GAAG,SAAS,EAClB,UAAU,GAAG,GAA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
@@ -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,102 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.errorCatchingMiddleware = exports.validatorMiddleware = void 0;
|
|
4
|
+
const cache_1 = require("../cache");
|
|
5
|
+
const util_1 = require("../metrics/util");
|
|
6
|
+
const util_2 = require("../util");
|
|
7
|
+
const error_1 = require("./error");
|
|
8
|
+
const errorCatcherLogger = (0, util_2.makeLogger)('ErrorCatchingMiddleware');
|
|
9
|
+
const validatorMiddleware = (adapter) => (req, reply, done) => {
|
|
10
|
+
if (req.headers['content-type'] !== 'application/json') {
|
|
11
|
+
throw new error_1.AdapterInputError({
|
|
12
|
+
message: 'Content type not "application/json", returning 400',
|
|
13
|
+
statusCode: 400,
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
if (!req.body) {
|
|
17
|
+
throw new error_1.AdapterInputError({
|
|
18
|
+
message: 'Body not present in adapter request, returning 400',
|
|
19
|
+
statusCode: 400,
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
// We can restrict usage of the raw request body everywhere in the framework
|
|
23
|
+
// by setting its type to EmptyBody, and we cast here (and only here)
|
|
24
|
+
const requestBody = req.body;
|
|
25
|
+
// Make endpoints case insensitive
|
|
26
|
+
const endpointParam = requestBody.endpoint?.toLowerCase() ||
|
|
27
|
+
requestBody.data?.endpoint?.toLowerCase() ||
|
|
28
|
+
adapter.defaultEndpoint;
|
|
29
|
+
if (!endpointParam) {
|
|
30
|
+
throw new error_1.AdapterInputError({
|
|
31
|
+
message: `Request body does not specify an endpoint, and there is no default endpoint configured for this adapter.`,
|
|
32
|
+
statusCode: 400,
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
const endpoint = adapter.endpointsMap[endpointParam];
|
|
36
|
+
if (!endpoint) {
|
|
37
|
+
throw new error_1.AdapterInputError({
|
|
38
|
+
message: `Adapter does not have a "${endpointParam}" endpoint.`,
|
|
39
|
+
statusCode: 404,
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
const validatedData = endpoint.validator.validateInput(requestBody.data);
|
|
43
|
+
req.requestContext = {
|
|
44
|
+
cacheKey: '',
|
|
45
|
+
data: validatedData,
|
|
46
|
+
endpointName: endpoint.name,
|
|
47
|
+
};
|
|
48
|
+
if (adapter.config.METRICS_ENABLED && adapter.config.EXPERIMENTAL_METRICS_ENABLED) {
|
|
49
|
+
// Add metrics meta which includes feedId to the request
|
|
50
|
+
// Perform prior to overrides to maintain consistent Feed IDs across adapters
|
|
51
|
+
const metrics = (0, util_1.getMetricsMeta)({
|
|
52
|
+
adapterEndpoint: endpoint,
|
|
53
|
+
adapterConfig: adapter.config,
|
|
54
|
+
}, validatedData);
|
|
55
|
+
req.requestContext = { ...req.requestContext, meta: { metrics } };
|
|
56
|
+
}
|
|
57
|
+
// Run any request transforms that might have been defined in the adapter.
|
|
58
|
+
// This is the last time modifications are supposed to happen to the request.
|
|
59
|
+
adapter.runRequestTransforms(req);
|
|
60
|
+
// Now that all the transformations have been applied, all that's left is calculating the cache key
|
|
61
|
+
if (endpoint.cacheKeyGenerator) {
|
|
62
|
+
let cacheKey;
|
|
63
|
+
cacheKey = endpoint.cacheKeyGenerator(req.requestContext.data);
|
|
64
|
+
if (cacheKey.length > adapter.config.MAX_COMMON_KEY_SIZE) {
|
|
65
|
+
errorCatcherLogger.warn(`Generated custom cache key for adapter request is bigger than the MAX_COMMON_KEY_SIZE and will be truncated`);
|
|
66
|
+
cacheKey = cacheKey.slice(0, adapter.config.MAX_COMMON_KEY_SIZE);
|
|
67
|
+
}
|
|
68
|
+
req.requestContext.cacheKey = cacheKey;
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
req.requestContext.cacheKey = (0, cache_1.calculateCacheKey)({
|
|
72
|
+
adapterEndpoint: endpoint,
|
|
73
|
+
adapterConfig: adapter.config,
|
|
74
|
+
}, req.requestContext.data);
|
|
75
|
+
}
|
|
76
|
+
done();
|
|
77
|
+
};
|
|
78
|
+
exports.validatorMiddleware = validatorMiddleware;
|
|
79
|
+
const errorCatchingMiddleware = (err, req, res) => {
|
|
80
|
+
// Add adapter or generic error to request meta for metrics use
|
|
81
|
+
// There's a chance we have no request context if there was an error during input validation
|
|
82
|
+
if (req.requestContext) {
|
|
83
|
+
req.requestContext.meta = { ...req.requestContext?.meta, error: err };
|
|
84
|
+
}
|
|
85
|
+
// Add the request context to the error so that we can check things like incoming params, endpoint, etc
|
|
86
|
+
const errorWithContext = {
|
|
87
|
+
requestContext: req.requestContext,
|
|
88
|
+
...err,
|
|
89
|
+
};
|
|
90
|
+
if (err instanceof error_1.AdapterError) {
|
|
91
|
+
// We want to log these as warn, because although they are to be expected, NOPs should
|
|
92
|
+
// Only use "correct" job specs and therefore not hit adapters with invalid requests.
|
|
93
|
+
errorCatcherLogger.warn(errorWithContext);
|
|
94
|
+
res.status(err.statusCode).send(err.toJSONResponse());
|
|
95
|
+
}
|
|
96
|
+
else {
|
|
97
|
+
errorCatcherLogger.error(errorWithContext);
|
|
98
|
+
res.status(500).send(err.message || 'There was an unexpected error in the adapter.');
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
exports.errorCatchingMiddleware = errorCatchingMiddleware;
|
|
102
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/validation/index.ts"],"names":[],"mappings":";;;AAEA,oCAA4C;AAC5C,0CAAgD;AAChD,kCAAoC;AAEpC,mCAAyD;AAGzD,MAAM,kBAAkB,GAAG,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AAEI,MAAM,uBAAuB,GAAG,CAAC,GAAU,EAAE,GAAmB,EAAE,GAAiB,EAAE,EAAE;IAC5F,+DAA+D;IAC/D,4FAA4F;IAC5F,IAAI,GAAG,CAAC,cAAc,EAAE;QACtB,GAAG,CAAC,cAAc,CAAC,IAAI,GAAG,EAAE,GAAG,GAAG,CAAC,cAAc,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,EAAE,CAAA;KACtE;IAED,uGAAuG;IACvG,MAAM,gBAAgB,GAAG;QACvB,cAAc,EAAE,GAAG,CAAC,cAAc;QAClC,GAAG,GAAG;KACP,CAAA;IAED,IAAI,GAAG,YAAY,oBAAY,EAAE;QAC/B,sFAAsF;QACtF,qFAAqF;QACrF,kBAAkB,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAA;QACzC,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,cAAc,EAAE,CAAC,CAAA;KACtD;SAAM;QACL,kBAAkB,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAA;QAC1C,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,IAAI,+CAA+C,CAAC,CAAA;KACrF;AACH,CAAC,CAAA;AAtBY,QAAA,uBAAuB,2BAsBnC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare type Override = Map<string, Map<string, string>>;
|
|
2
|
+
export declare type InputParameter = {
|
|
3
|
+
aliases?: readonly string[];
|
|
4
|
+
description?: string;
|
|
5
|
+
type?: 'bigint' | 'boolean' | 'array' | 'number' | 'object' | 'string';
|
|
6
|
+
required?: boolean;
|
|
7
|
+
options?: unknown[];
|
|
8
|
+
default?: unknown;
|
|
9
|
+
dependsOn?: readonly string[];
|
|
10
|
+
exclusive?: readonly string[];
|
|
11
|
+
};
|
|
12
|
+
export declare type InputParameters = {
|
|
13
|
+
[name: string]: InputParameter;
|
|
14
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"input-params.js","sourceRoot":"","sources":["../../../src/validation/input-params.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { InputParameters } from './input-params';
|
|
2
|
+
export declare type NormalizedInput = Record<string, unknown>;
|
|
3
|
+
export declare class InputValidator {
|
|
4
|
+
private readonly inputConfig;
|
|
5
|
+
private aliases;
|
|
6
|
+
constructor(inputConfig: InputParameters);
|
|
7
|
+
validateInput(input: Record<string, unknown>): NormalizedInput;
|
|
8
|
+
private initializeInputs;
|
|
9
|
+
private validateInputParamsSchema;
|
|
10
|
+
private validateRequiredConfig;
|
|
11
|
+
private validateOptions;
|
|
12
|
+
private validateTypes;
|
|
13
|
+
private validateDeps;
|
|
14
|
+
private getUsedKey;
|
|
15
|
+
private throwInvalid;
|
|
16
|
+
}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.InputValidator = void 0;
|
|
4
|
+
const error_1 = require("./error");
|
|
5
|
+
const util_1 = require("../util");
|
|
6
|
+
class InputValidator {
|
|
7
|
+
constructor(inputConfig) {
|
|
8
|
+
this.inputConfig = inputConfig;
|
|
9
|
+
this.aliases = {};
|
|
10
|
+
this.getUsedKey = (allKeys, input) => allKeys.find((k) => input && !(0, util_1.isEmpty)(input[k])) || '';
|
|
11
|
+
this.throwInvalid = (message) => {
|
|
12
|
+
throw new error_1.AdapterInputError({ statusCode: 400, message });
|
|
13
|
+
};
|
|
14
|
+
this.inputConfig = { ...inputConfig };
|
|
15
|
+
this.validateInputParamsSchema();
|
|
16
|
+
}
|
|
17
|
+
validateInput(input) {
|
|
18
|
+
const normalized = this.initializeInputs(input);
|
|
19
|
+
for (const configKey in this.inputConfig) {
|
|
20
|
+
this.validateRequiredConfig(configKey, normalized);
|
|
21
|
+
if (!(0, util_1.isEmpty)(normalized[configKey])) {
|
|
22
|
+
this.validateTypes(configKey, normalized);
|
|
23
|
+
this.validateOptions(configKey, normalized);
|
|
24
|
+
this.validateDeps(configKey, normalized);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return normalized;
|
|
28
|
+
}
|
|
29
|
+
initializeInputs(input) {
|
|
30
|
+
const normalized = {};
|
|
31
|
+
for (const paramName in this.inputConfig) {
|
|
32
|
+
const usedKey = this.getUsedKey(this.aliases[paramName], input);
|
|
33
|
+
normalized[paramName] =
|
|
34
|
+
!usedKey || (0, util_1.isEmpty)(input[usedKey]) ? this.inputConfig[paramName].default : input[usedKey];
|
|
35
|
+
}
|
|
36
|
+
return normalized;
|
|
37
|
+
}
|
|
38
|
+
validateInputParamsSchema() {
|
|
39
|
+
for (const configKey in this.inputConfig) {
|
|
40
|
+
const config = this.inputConfig[configKey];
|
|
41
|
+
if (config.required && config.default) {
|
|
42
|
+
throw new error_1.AdapterInputError({
|
|
43
|
+
statusCode: 400,
|
|
44
|
+
message: `${configKey} can't be required and have default value`,
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
const aliases = [configKey, ...(config.aliases ?? [])];
|
|
48
|
+
if (aliases.length !== new Set(aliases).size) {
|
|
49
|
+
throw new error_1.AdapterInputError({
|
|
50
|
+
statusCode: 400,
|
|
51
|
+
message: `Duplicate aliases`,
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
this.aliases[configKey] = aliases;
|
|
55
|
+
const deps = [...(config.dependsOn ?? []), ...(config.exclusive ?? [])];
|
|
56
|
+
if (!deps || !deps.length) {
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
deps.forEach((inputDepKey) => {
|
|
60
|
+
if (!this.inputConfig[inputDepKey]) {
|
|
61
|
+
throw new error_1.AdapterInputError({
|
|
62
|
+
statusCode: 400,
|
|
63
|
+
message: `Input dependency/exclusive '${inputDepKey}' is missing in input schema`,
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
validateRequiredConfig(configKey, normalized) {
|
|
70
|
+
if (!this.inputConfig[configKey].required) {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
if ((0, util_1.isEmpty)(normalized[configKey])) {
|
|
74
|
+
this.throwInvalid(`Required parameter ${configKey} must be non-null and non-empty`);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
validateOptions(key, normalized) {
|
|
78
|
+
if (!this.inputConfig[key].options?.length) {
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
if (!this.inputConfig[key].options?.includes(normalized[key])) {
|
|
82
|
+
this.throwInvalid(`${key} parameter must be one of following options: ${this.inputConfig[key].options?.join(',')}`);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
validateTypes(key, normalized) {
|
|
86
|
+
const type = this.inputConfig[key].type;
|
|
87
|
+
if (!type) {
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
if (['array', 'object'].includes(type)) {
|
|
91
|
+
if (type === 'array' &&
|
|
92
|
+
(!Array.isArray(normalized[key]) || normalized[key].length === 0)) {
|
|
93
|
+
this.throwInvalid(`${key} parameter must be a non-empty array`);
|
|
94
|
+
}
|
|
95
|
+
if (type === 'object' &&
|
|
96
|
+
normalized[key] &&
|
|
97
|
+
(Object.getPrototypeOf(normalized[key]) !== Object.prototype ||
|
|
98
|
+
Object.keys(normalized[key]).length === 0)) {
|
|
99
|
+
this.throwInvalid(`${key} parameter must be an object with at least one property`);
|
|
100
|
+
}
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
else if (typeof normalized[key] !== type) {
|
|
104
|
+
this.throwInvalid(`${key} parameter must be of type ${type}`);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
validateDeps(key, normalized) {
|
|
108
|
+
for (const dependency of this.inputConfig[key].dependsOn ?? []) {
|
|
109
|
+
const value = normalized[dependency];
|
|
110
|
+
if ((0, util_1.isEmpty)(value)) {
|
|
111
|
+
this.throwInvalid(`${key} dependency ${dependency} not supplied`);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
for (const exclusive of this.inputConfig[key].exclusive ?? []) {
|
|
115
|
+
const value = normalized[exclusive];
|
|
116
|
+
if (!(0, util_1.isEmpty)(value)) {
|
|
117
|
+
this.throwInvalid(`${key} cannot be supplied concurrently with ${exclusive}`);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
exports.InputValidator = InputValidator;
|
|
123
|
+
//# sourceMappingURL=input-validator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"input-validator.js","sourceRoot":"","sources":["../../../src/validation/input-validator.ts"],"names":[],"mappings":";;;AACA,mCAA2C;AAC3C,kCAAiC;AAIjC,MAAa,cAAc;IAEzB,YAA6B,WAA4B;QAA5B,gBAAW,GAAX,WAAW,CAAiB;QADjD,YAAO,GAAgC,EAAE,CAAA;QAqIzC,eAAU,GAAG,CAAC,OAAiB,EAAE,KAA8B,EAAU,EAAE,CACjF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,KAAK,IAAI,CAAC,IAAA,cAAO,EAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAA;QAEhD,iBAAY,GAAG,CAAC,OAAe,EAAQ,EAAE;YAC/C,MAAM,IAAI,yBAAiB,CAAC,EAAE,UAAU,EAAE,GAAG,EAAE,OAAO,EAAE,CAAC,CAAA;QAC3D,CAAC,CAAA;QAxIC,IAAI,CAAC,WAAW,GAAG,EAAE,GAAG,WAAW,EAAE,CAAA;QACrC,IAAI,CAAC,yBAAyB,EAAE,CAAA;IAClC,CAAC;IAED,aAAa,CAAC,KAA8B;QAC1C,MAAM,UAAU,GAAG,IAAI,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAA;QAE/C,KAAK,MAAM,SAAS,IAAI,IAAI,CAAC,WAAW,EA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