@chainlink/external-adapter-framework 0.3.9 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +102 -0
- package/package.json +42 -50
- package/adapter/basic.d.ts +0 -86
- package/adapter/basic.js +0 -325
- package/adapter/basic.js.map +0 -1
- package/adapter/endpoint.d.ts +0 -17
- package/adapter/endpoint.js +0 -19
- package/adapter/endpoint.js.map +0 -1
- package/adapter/index.d.ts +0 -4
- package/adapter/index.js +0 -21
- package/adapter/index.js.map +0 -1
- package/adapter/price.d.ts +0 -75
- package/adapter/price.js +0 -88
- package/adapter/price.js.map +0 -1
- package/adapter/types.d.ts +0 -118
- package/adapter/types.js +0 -3
- package/adapter/types.js.map +0 -1
- package/background-executor.d.ts +0 -9
- package/background-executor.js +0 -97
- package/background-executor.js.map +0 -1
- package/cache/factory.d.ts +0 -6
- package/cache/factory.js +0 -24
- package/cache/factory.js.map +0 -1
- package/cache/index.d.ts +0 -87
- package/cache/index.js +0 -133
- package/cache/index.js.map +0 -1
- package/cache/local.d.ts +0 -23
- package/cache/local.js +0 -84
- package/cache/local.js.map +0 -1
- package/cache/metrics.d.ts +0 -27
- package/cache/metrics.js +0 -121
- package/cache/metrics.js.map +0 -1
- package/cache/redis.d.ts +0 -16
- package/cache/redis.js +0 -101
- package/cache/redis.js.map +0 -1
- package/config/index.d.ts +0 -298
- package/config/index.js +0 -359
- package/config/index.js.map +0 -1
- package/config/provider-limits.d.ts +0 -27
- package/config/provider-limits.js +0 -75
- package/config/provider-limits.js.map +0 -1
- package/examples/bank-frick/accounts.d.ts +0 -52
- package/examples/bank-frick/accounts.js +0 -190
- package/examples/bank-frick/accounts.js.map +0 -1
- package/examples/bank-frick/config/index.d.ts +0 -17
- package/examples/bank-frick/config/index.js +0 -55
- package/examples/bank-frick/config/index.js.map +0 -1
- package/examples/bank-frick/index.d.ts +0 -16
- package/examples/bank-frick/index.js +0 -16
- package/examples/bank-frick/index.js.map +0 -1
- package/examples/bank-frick/util.d.ts +0 -4
- package/examples/bank-frick/util.js +0 -40
- package/examples/bank-frick/util.js.map +0 -1
- package/examples/coingecko/src/config/index.d.ts +0 -2
- package/examples/coingecko/src/config/index.js +0 -6
- package/examples/coingecko/src/config/index.js.map +0 -1
- package/examples/coingecko/src/config/overrides.json +0 -10825
- package/examples/coingecko/src/crypto-utils.d.ts +0 -48
- package/examples/coingecko/src/crypto-utils.js +0 -60
- package/examples/coingecko/src/crypto-utils.js.map +0 -1
- package/examples/coingecko/src/endpoint/coins.d.ts +0 -9
- package/examples/coingecko/src/endpoint/coins.js +0 -37
- package/examples/coingecko/src/endpoint/coins.js.map +0 -1
- package/examples/coingecko/src/endpoint/crypto-marketcap.d.ts +0 -3
- package/examples/coingecko/src/endpoint/crypto-marketcap.js +0 -30
- package/examples/coingecko/src/endpoint/crypto-marketcap.js.map +0 -1
- package/examples/coingecko/src/endpoint/crypto-volume.d.ts +0 -3
- package/examples/coingecko/src/endpoint/crypto-volume.js +0 -30
- package/examples/coingecko/src/endpoint/crypto-volume.js.map +0 -1
- package/examples/coingecko/src/endpoint/crypto.d.ts +0 -2
- package/examples/coingecko/src/endpoint/crypto.js +0 -28
- package/examples/coingecko/src/endpoint/crypto.js.map +0 -1
- package/examples/coingecko/src/endpoint/dominance.d.ts +0 -3
- package/examples/coingecko/src/endpoint/dominance.js +0 -28
- package/examples/coingecko/src/endpoint/dominance.js.map +0 -1
- package/examples/coingecko/src/endpoint/global-marketcap.d.ts +0 -3
- package/examples/coingecko/src/endpoint/global-marketcap.js +0 -28
- package/examples/coingecko/src/endpoint/global-marketcap.js.map +0 -1
- package/examples/coingecko/src/endpoint/index.d.ts +0 -6
- package/examples/coingecko/src/endpoint/index.js +0 -16
- package/examples/coingecko/src/endpoint/index.js.map +0 -1
- package/examples/coingecko/src/global-utils.d.ts +0 -27
- package/examples/coingecko/src/global-utils.js +0 -47
- package/examples/coingecko/src/global-utils.js.map +0 -1
- package/examples/coingecko/src/index.d.ts +0 -4
- package/examples/coingecko/src/index.js +0 -19
- package/examples/coingecko/src/index.js.map +0 -1
- package/examples/coingecko-old/batch-warming.d.ts +0 -7
- package/examples/coingecko-old/batch-warming.js +0 -54
- package/examples/coingecko-old/batch-warming.js.map +0 -1
- package/examples/coingecko-old/index.d.ts +0 -2
- package/examples/coingecko-old/index.js +0 -12
- package/examples/coingecko-old/index.js.map +0 -1
- package/examples/coingecko-old/rest.d.ts +0 -12
- package/examples/coingecko-old/rest.js +0 -55
- package/examples/coingecko-old/rest.js.map +0 -1
- package/examples/cryptocompare/src/config/index.d.ts +0 -2
- package/examples/cryptocompare/src/config/index.js +0 -6
- package/examples/cryptocompare/src/config/index.js.map +0 -1
- package/examples/cryptocompare/src/endpoints/crypto.d.ts +0 -28
- package/examples/cryptocompare/src/endpoints/crypto.js +0 -54
- package/examples/cryptocompare/src/endpoints/crypto.js.map +0 -1
- package/examples/cryptocompare/src/endpoints/index.d.ts +0 -1
- package/examples/cryptocompare/src/endpoints/index.js +0 -6
- package/examples/cryptocompare/src/endpoints/index.js.map +0 -1
- package/examples/cryptocompare/src/index.d.ts +0 -4
- package/examples/cryptocompare/src/index.js +0 -14
- package/examples/cryptocompare/src/index.js.map +0 -1
- package/examples/genesis/config/index.d.ts +0 -7
- package/examples/genesis/config/index.js +0 -11
- package/examples/genesis/config/index.js.map +0 -1
- package/examples/genesis/index.d.ts +0 -2
- package/examples/genesis/index.js +0 -13
- package/examples/genesis/index.js.map +0 -1
- package/examples/genesis/sseStream.d.ts +0 -16
- package/examples/genesis/sseStream.js +0 -149
- package/examples/genesis/sseStream.js.map +0 -1
- package/index.d.ts +0 -17
- package/index.js +0 -174
- package/index.js.map +0 -1
- package/metrics/constants.d.ts +0 -16
- package/metrics/constants.js +0 -26
- package/metrics/constants.js.map +0 -1
- package/metrics/index.d.ts +0 -19
- package/metrics/index.js +0 -139
- package/metrics/index.js.map +0 -1
- package/metrics/util.d.ts +0 -7
- package/metrics/util.js +0 -10
- package/metrics/util.js.map +0 -1
- package/rate-limiting/background/fixed-frequency.d.ts +0 -11
- package/rate-limiting/background/fixed-frequency.js +0 -36
- package/rate-limiting/background/fixed-frequency.js.map +0 -1
- package/rate-limiting/index.d.ts +0 -56
- package/rate-limiting/index.js +0 -86
- package/rate-limiting/index.js.map +0 -1
- package/rate-limiting/metrics.d.ts +0 -3
- package/rate-limiting/metrics.js +0 -45
- package/rate-limiting/metrics.js.map +0 -1
- package/rate-limiting/request/simple-counting.d.ts +0 -21
- package/rate-limiting/request/simple-counting.js +0 -63
- package/rate-limiting/request/simple-counting.js.map +0 -1
- package/transports/batch-warming.d.ts +0 -35
- package/transports/batch-warming.js +0 -138
- package/transports/batch-warming.js.map +0 -1
- package/transports/index.d.ts +0 -87
- package/transports/index.js +0 -56
- package/transports/index.js.map +0 -1
- package/transports/metrics.d.ts +0 -25
- package/transports/metrics.js +0 -122
- package/transports/metrics.js.map +0 -1
- package/transports/rest.d.ts +0 -51
- package/transports/rest.js +0 -133
- package/transports/rest.js.map +0 -1
- package/transports/routing.d.ts +0 -23
- package/transports/routing.js +0 -52
- package/transports/routing.js.map +0 -1
- package/transports/sse.d.ts +0 -40
- package/transports/sse.js +0 -92
- package/transports/sse.js.map +0 -1
- package/transports/util.d.ts +0 -9
- package/transports/util.js +0 -87
- package/transports/util.js.map +0 -1
- package/transports/websocket.d.ts +0 -81
- package/transports/websocket.js +0 -165
- package/transports/websocket.js.map +0 -1
- package/util/censor/censor-list.d.ts +0 -9
- package/util/censor/censor-list.js +0 -13
- package/util/censor/censor-list.js.map +0 -1
- package/util/index.d.ts +0 -13
- package/util/index.js +0 -38
- package/util/index.js.map +0 -1
- package/util/logger.d.ts +0 -49
- package/util/logger.js +0 -123
- package/util/logger.js.map +0 -1
- package/util/request.d.ts +0 -102
- package/util/request.js +0 -3
- package/util/request.js.map +0 -1
- package/util/subscription-set/expiring-sorted-set.d.ts +0 -21
- package/util/subscription-set/expiring-sorted-set.js +0 -36
- package/util/subscription-set/expiring-sorted-set.js.map +0 -1
- package/util/subscription-set/redis-sorted-set.d.ts +0 -9
- package/util/subscription-set/redis-sorted-set.js +0 -29
- package/util/subscription-set/redis-sorted-set.js.map +0 -1
- package/util/subscription-set/subscription-set.d.ts +0 -19
- package/util/subscription-set/subscription-set.js +0 -28
- package/util/subscription-set/subscription-set.js.map +0 -1
- package/util/test-payload-loader.d.ts +0 -26
- package/util/test-payload-loader.js +0 -85
- package/util/test-payload-loader.js.map +0 -1
- package/validation/error.d.ts +0 -48
- package/validation/error.js +0 -78
- package/validation/error.js.map +0 -1
- package/validation/index.d.ts +0 -5
- package/validation/index.js +0 -91
- package/validation/index.js.map +0 -1
- package/validation/input-params.d.ts +0 -14
- package/validation/input-params.js +0 -3
- package/validation/input-params.js.map +0 -1
- package/validation/input-validator.d.ts +0 -16
- package/validation/input-validator.js +0 -123
- package/validation/input-validator.js.map +0 -1
package/util/index.js
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.isEmpty = exports.isArray = exports.isObject = exports.sleep = void 0;
|
|
18
|
-
__exportStar(require("./request"), exports);
|
|
19
|
-
__exportStar(require("./logger"), exports);
|
|
20
|
-
__exportStar(require("./subscription-set/subscription-set"), exports);
|
|
21
|
-
/**
|
|
22
|
-
* Sleeps for the provided number of milliseconds
|
|
23
|
-
* @param ms - The number of milliseconds to sleep for
|
|
24
|
-
* @returns a Promise that resolves once the specified time passes
|
|
25
|
-
*/
|
|
26
|
-
const sleep = (ms) => {
|
|
27
|
-
return new Promise((resolve) => {
|
|
28
|
-
setTimeout(resolve, ms);
|
|
29
|
-
});
|
|
30
|
-
};
|
|
31
|
-
exports.sleep = sleep;
|
|
32
|
-
const isObject = (o) => o !== null && typeof o === 'object' && Array.isArray(o) === false;
|
|
33
|
-
exports.isObject = isObject;
|
|
34
|
-
const isArray = (o) => o !== null && typeof o === 'object' && Array.isArray(o);
|
|
35
|
-
exports.isArray = isArray;
|
|
36
|
-
const isEmpty = (o) => o === undefined || o === null || o === '';
|
|
37
|
-
exports.isEmpty = isEmpty;
|
|
38
|
-
//# sourceMappingURL=index.js.map
|
package/util/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/util/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,4CAAyB;AACzB,2CAAwB;AACxB,sEAAmD;AAEnD;;;;GAIG;AACI,MAAM,KAAK,GAAG,CAAC,EAAU,EAAiB,EAAE;IACjD,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;QAC7B,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAA;IACzB,CAAC,CAAC,CAAA;AACJ,CAAC,CAAA;AAJY,QAAA,KAAK,SAIjB;AAEM,MAAM,QAAQ,GAAG,CAAC,CAAU,EAAW,EAAE,CAC9C,CAAC,KAAK,IAAI,IAAI,OAAO,CAAC,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,KAAK,CAAA;AADtD,QAAA,QAAQ,YAC8C;AAE5D,MAAM,OAAO,GAAG,CAAC,CAAU,EAAW,EAAE,CAC7C,CAAC,KAAK,IAAI,IAAI,OAAO,CAAC,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAA;AAD5C,QAAA,OAAO,WACqC;AAElD,MAAM,OAAO,GAAG,CAAC,CAAU,EAAW,EAAE,CAAC,CAAC,KAAK,SAAS,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,EAAE,CAAA;AAA5E,QAAA,OAAO,WAAqE"}
|
package/util/logger.d.ts
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import pino from 'pino';
|
|
3
|
-
import { AdapterRequest } from './request';
|
|
4
|
-
import { FastifyReply, HookHandlerDoneFunction } from 'fastify';
|
|
5
|
-
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
6
|
-
import { CensorKeyValue } from './censor/censor-list';
|
|
7
|
-
export declare const asyncLocalStorage: AsyncLocalStorage<unknown>;
|
|
8
|
-
export declare type Store = {
|
|
9
|
-
correlationId: string;
|
|
10
|
-
};
|
|
11
|
-
export declare const COLORS: string[];
|
|
12
|
-
export declare const colorFactory: (colors: string[]) => () => string;
|
|
13
|
-
/**
|
|
14
|
-
* Instead of using a global logger instance, we want to force using a child logger
|
|
15
|
-
* with a specific layer set in it, so that we can filter logs by where they're output from.
|
|
16
|
-
*
|
|
17
|
-
* Details on what each log level represents:
|
|
18
|
-
* "trace": Forensic debugging of issues on a local machine.
|
|
19
|
-
* "debug": Detailed logging level to get more context from users on their environments.
|
|
20
|
-
* "info": High-level informational messages, to describe at a glance the high level state of the system.
|
|
21
|
-
* "warn": A mild error occurred that might require non-urgent action.
|
|
22
|
-
* "error": An unexpected error occurred during the regular operation of a well-maintained EA.
|
|
23
|
-
* "fatal": The EA encountered an unrecoverable problem and had to exit.
|
|
24
|
-
*
|
|
25
|
-
* Full reference this is based on can be found at
|
|
26
|
-
* https://github.com/smartcontractkit/documentation/blob/main/docs/Node%20Operators/configuration-variables.md#log_level
|
|
27
|
-
*
|
|
28
|
-
* @param layer - the layer name to include in the logs (e.g. "SomeMiddleware", "RedisCache", etc.)
|
|
29
|
-
* @returns a layer specific logger
|
|
30
|
-
*/
|
|
31
|
-
export declare const makeLogger: (layer: string) => pino.Logger<{
|
|
32
|
-
level: string;
|
|
33
|
-
hooks: {
|
|
34
|
-
logMethod(this: pino.Logger<pino.LoggerOptions>, inputArgs: [msg: string, ...args: any[]], method: pino.LogFn): void;
|
|
35
|
-
};
|
|
36
|
-
mixin(): {};
|
|
37
|
-
transport: {
|
|
38
|
-
target: string;
|
|
39
|
-
options: {
|
|
40
|
-
levelFirst: boolean;
|
|
41
|
-
levelLabel: string;
|
|
42
|
-
ignore: string;
|
|
43
|
-
messageFormat: string;
|
|
44
|
-
translateTime: string;
|
|
45
|
-
};
|
|
46
|
-
} | undefined;
|
|
47
|
-
} & pino.ChildLoggerOptions>;
|
|
48
|
-
export declare const loggingContextMiddleware: (req: AdapterRequest, res: FastifyReply, done: HookHandlerDoneFunction) => void;
|
|
49
|
-
export declare function censor(obj: any, censorList: CensorKeyValue[]): any;
|
package/util/logger.js
DELETED
|
@@ -1,123 +0,0 @@
|
|
|
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.censor = exports.loggingContextMiddleware = exports.makeLogger = exports.colorFactory = exports.COLORS = exports.asyncLocalStorage = void 0;
|
|
7
|
-
const pino_1 = __importDefault(require("pino"));
|
|
8
|
-
const config_1 = require("../config");
|
|
9
|
-
const crypto_1 = require("crypto");
|
|
10
|
-
const node_async_hooks_1 = require("node:async_hooks");
|
|
11
|
-
const censor_list_1 = __importDefault(require("./censor/censor-list"));
|
|
12
|
-
exports.asyncLocalStorage = new node_async_hooks_1.AsyncLocalStorage();
|
|
13
|
-
const debugTransport = {
|
|
14
|
-
target: 'pino-pretty',
|
|
15
|
-
options: {
|
|
16
|
-
levelFirst: true,
|
|
17
|
-
levelLabel: 'level',
|
|
18
|
-
ignore: 'layer,pid,hostname,correlationId,color',
|
|
19
|
-
messageFormat: `\x1b[0m[{correlationId}] {color}[{layer}]\x1b[0m {msg}`,
|
|
20
|
-
translateTime: 'yyyy-mm-dd HH:MM:ss.l',
|
|
21
|
-
},
|
|
22
|
-
};
|
|
23
|
-
// Base logger, shouldn't be used because we want layers to be specified
|
|
24
|
-
const baseLogger = (0, pino_1.default)({
|
|
25
|
-
level: process.env['LOG_LEVEL']?.toLowerCase() || config_1.BaseSettings.LOG_LEVEL.default,
|
|
26
|
-
hooks: {
|
|
27
|
-
logMethod(inputArgs, method) {
|
|
28
|
-
// Censor each argument of logger
|
|
29
|
-
const censorList = censor_list_1.default.getAll();
|
|
30
|
-
return method.apply(this, inputArgs.map((arg) => censor(arg, censorList)));
|
|
31
|
-
},
|
|
32
|
-
},
|
|
33
|
-
mixin() {
|
|
34
|
-
if (process.env['CORRELATION_ID_ENABLED'] !== 'false') {
|
|
35
|
-
const store = exports.asyncLocalStorage.getStore();
|
|
36
|
-
if (store) {
|
|
37
|
-
return store;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
return {};
|
|
41
|
-
},
|
|
42
|
-
transport: process.env['DEBUG'] === 'true' || process.env['NODE_ENV'] === 'development'
|
|
43
|
-
? debugTransport
|
|
44
|
-
: undefined,
|
|
45
|
-
});
|
|
46
|
-
exports.COLORS = [
|
|
47
|
-
'\u001b[31;1m',
|
|
48
|
-
'\u001b[32m',
|
|
49
|
-
'\u001b[33m',
|
|
50
|
-
'\u001b[34m',
|
|
51
|
-
'\u001b[35m',
|
|
52
|
-
'\u001b[36m',
|
|
53
|
-
'\u001b[38;2;121;85;72m',
|
|
54
|
-
'\u001b[92m',
|
|
55
|
-
'\u001b[93m',
|
|
56
|
-
'\u001b[94m',
|
|
57
|
-
'\u001b[95m',
|
|
58
|
-
'\u001b[96m',
|
|
59
|
-
'\u001b[38;5;202m',
|
|
60
|
-
'\u001b[38;5;31m',
|
|
61
|
-
'\u001b[38;5;130m',
|
|
62
|
-
'\u001b[38;2;255;122;92m',
|
|
63
|
-
'\u001b[38;2;46;125;50m',
|
|
64
|
-
'\u001b[38;2;129;168;37m',
|
|
65
|
-
'\u001b[38;2;175;180;43m',
|
|
66
|
-
'\u001b[91m',
|
|
67
|
-
'\u001b[38;2;63;81;181m',
|
|
68
|
-
];
|
|
69
|
-
const colorFactory = (colors) => {
|
|
70
|
-
let index = -1;
|
|
71
|
-
return () => {
|
|
72
|
-
index++;
|
|
73
|
-
if (index > colors.length - 1) {
|
|
74
|
-
index = 0;
|
|
75
|
-
}
|
|
76
|
-
return colors[index];
|
|
77
|
-
};
|
|
78
|
-
};
|
|
79
|
-
exports.colorFactory = colorFactory;
|
|
80
|
-
const getNextColor = (0, exports.colorFactory)(exports.COLORS);
|
|
81
|
-
/**
|
|
82
|
-
* Instead of using a global logger instance, we want to force using a child logger
|
|
83
|
-
* with a specific layer set in it, so that we can filter logs by where they're output from.
|
|
84
|
-
*
|
|
85
|
-
* Details on what each log level represents:
|
|
86
|
-
* "trace": Forensic debugging of issues on a local machine.
|
|
87
|
-
* "debug": Detailed logging level to get more context from users on their environments.
|
|
88
|
-
* "info": High-level informational messages, to describe at a glance the high level state of the system.
|
|
89
|
-
* "warn": A mild error occurred that might require non-urgent action.
|
|
90
|
-
* "error": An unexpected error occurred during the regular operation of a well-maintained EA.
|
|
91
|
-
* "fatal": The EA encountered an unrecoverable problem and had to exit.
|
|
92
|
-
*
|
|
93
|
-
* Full reference this is based on can be found at
|
|
94
|
-
* https://github.com/smartcontractkit/documentation/blob/main/docs/Node%20Operators/configuration-variables.md#log_level
|
|
95
|
-
*
|
|
96
|
-
* @param layer - the layer name to include in the logs (e.g. "SomeMiddleware", "RedisCache", etc.)
|
|
97
|
-
* @returns a layer specific logger
|
|
98
|
-
*/
|
|
99
|
-
const makeLogger = (layer) => baseLogger.child({
|
|
100
|
-
layer,
|
|
101
|
-
color: process.env['DEBUG'] === 'true' || process.env['NODE_ENV'] === 'development'
|
|
102
|
-
? getNextColor()
|
|
103
|
-
: undefined,
|
|
104
|
-
});
|
|
105
|
-
exports.makeLogger = makeLogger;
|
|
106
|
-
const loggingContextMiddleware = (req, res, done) => {
|
|
107
|
-
const correlationId = req.headers['x-correlation-id'] || (0, crypto_1.randomUUID)();
|
|
108
|
-
exports.asyncLocalStorage.run({ correlationId: correlationId }, () => {
|
|
109
|
-
done();
|
|
110
|
-
});
|
|
111
|
-
};
|
|
112
|
-
exports.loggingContextMiddleware = loggingContextMiddleware;
|
|
113
|
-
// Obj is typed as "any" because it could be a variety of structures in the logger
|
|
114
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
115
|
-
function censor(obj, censorList) {
|
|
116
|
-
let stringified = JSON.stringify(obj);
|
|
117
|
-
censorList.forEach((entry) => {
|
|
118
|
-
stringified = stringified.replace(entry.value, `[${entry.key} REDACTED]`);
|
|
119
|
-
});
|
|
120
|
-
return JSON.parse(stringified);
|
|
121
|
-
}
|
|
122
|
-
exports.censor = censor;
|
|
123
|
-
//# sourceMappingURL=logger.js.map
|
package/util/logger.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../../src/util/logger.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAuB;AACvB,sCAAwC;AAGxC,mCAAmC;AACnC,uDAAoD;AACpD,uEAAiE;AAEpD,QAAA,iBAAiB,GAAG,IAAI,oCAAiB,EAAE,CAAA;AAMxD,MAAM,cAAc,GAAG;IACrB,MAAM,EAAE,aAAa;IACrB,OAAO,EAAE;QACP,UAAU,EAAE,IAAI;QAChB,UAAU,EAAE,OAAO;QACnB,MAAM,EAAE,w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AAG,CAAC,CAAA;IACrC,UAAU,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE;QAC3B,WAAW,GAAG,WAAW,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,EAAE,IAAI,KAAK,CAAC,GAAG,YAAY,CAAC,CAAA;IAC3E,CAAC,CAAC,CAAA;IACF,OAAO,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,CAAA;AAChC,CAAC;AAND,wBAMC"}
|
package/util/request.d.ts
DELETED
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
import { FastifyReply, FastifyRequest, HookHandlerDoneFunction } from 'fastify';
|
|
2
|
-
import { Adapter } from '../adapter';
|
|
3
|
-
import { AdapterError } from '../validation/error';
|
|
4
|
-
declare module 'fastify' {
|
|
5
|
-
interface FastifyRequest {
|
|
6
|
-
requestContext: AdapterRequestContext;
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
/**
|
|
10
|
-
* Structure for the body of all requests that will be sent to the adapter
|
|
11
|
-
*/
|
|
12
|
-
export interface AdapterRequestBody<T = AdapterRequestData> {
|
|
13
|
-
/** Adapter endpoint (not to be confused with REST API endpoint) */
|
|
14
|
-
endpoint?: string;
|
|
15
|
-
/** Main data that will be validated and used on each adapter request */
|
|
16
|
-
data: T;
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Object that will be added to the request on a successful validation.
|
|
20
|
-
* Contains all the necessary information the adapter will need across the request execution.
|
|
21
|
-
*/
|
|
22
|
-
export declare type AdapterRequestContext<T = AdapterRequestData> = {
|
|
23
|
-
/** Name of the endpoint this payload should be directed to */
|
|
24
|
-
endpointName: string;
|
|
25
|
-
/** Precalculated cache key used to get and set corresponding values from the cache and subscription sets */
|
|
26
|
-
cacheKey: string;
|
|
27
|
-
/** Normalized and validated data coming from the request body */
|
|
28
|
-
data: T;
|
|
29
|
-
/** Metadata relevant to this particular request */
|
|
30
|
-
meta?: AdapterRequestMeta;
|
|
31
|
-
};
|
|
32
|
-
/**
|
|
33
|
-
* Helper type to denote an empty body
|
|
34
|
-
*/
|
|
35
|
-
declare type EmptyBody = Record<string, never>;
|
|
36
|
-
/**
|
|
37
|
-
* Helper type to provide fastify for all adapter handlers
|
|
38
|
-
*/
|
|
39
|
-
export declare type AdapterRouteGeneric = {
|
|
40
|
-
/** Set to an empty record so the user does not access the raw request data and uses the Validated data from the context instead */
|
|
41
|
-
Body: EmptyBody;
|
|
42
|
-
};
|
|
43
|
-
/**
|
|
44
|
-
* Structure for all requests incoming to this adapter
|
|
45
|
-
*/
|
|
46
|
-
export declare type AdapterRequest<T = AdapterRequestData> = FastifyRequest<AdapterRouteGeneric> & {
|
|
47
|
-
/** Set to an empty record so the user does not access the raw request data and uses the Validated data from the context instead */
|
|
48
|
-
body: EmptyBody;
|
|
49
|
-
/** Container for all validated information that will be used by the framework across this request's lifecycle */
|
|
50
|
-
requestContext: AdapterRequestContext<T>;
|
|
51
|
-
};
|
|
52
|
-
/**
|
|
53
|
-
* Metadata for a particular request
|
|
54
|
-
*/
|
|
55
|
-
export interface AdapterRequestMeta {
|
|
56
|
-
/** Relevant metrics gathered for this request */
|
|
57
|
-
metrics?: AdapterMetricsMeta;
|
|
58
|
-
/** An error that ocurred somewhere along this requests' lifecycle */
|
|
59
|
-
error?: AdapterError | Error;
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* Meta info that pertains to exposing metrics
|
|
63
|
-
*/
|
|
64
|
-
export interface AdapterMetricsMeta {
|
|
65
|
-
/** String to uniquely identify a specific price feed */
|
|
66
|
-
feedId?: string;
|
|
67
|
-
/** Boolean to note if this request's response was found in the cache directly */
|
|
68
|
-
cacheHit?: boolean;
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* Basic shape for the data within the request body
|
|
72
|
-
*/
|
|
73
|
-
export declare type AdapterRequestData = Record<string, unknown> & {
|
|
74
|
-
endpoint?: string;
|
|
75
|
-
};
|
|
76
|
-
/**
|
|
77
|
-
* Helper type to hold the value from responses from a provider, and the adapter params they correspond to
|
|
78
|
-
*/
|
|
79
|
-
export interface ProviderResult<Params> {
|
|
80
|
-
/** The set of parameters that uniquely relate to the response */
|
|
81
|
-
params: Params;
|
|
82
|
-
/** */
|
|
83
|
-
value: unknown;
|
|
84
|
-
}
|
|
85
|
-
/**
|
|
86
|
-
* Shape of the response body from the adapter
|
|
87
|
-
*/
|
|
88
|
-
export declare type AdapterResponse<T = unknown> = {
|
|
89
|
-
/** HTTP status code */
|
|
90
|
-
statusCode: number;
|
|
91
|
-
/** Response data, holds "result" for Flux Monitor */
|
|
92
|
-
data: T;
|
|
93
|
-
/** Result value used for OCR */
|
|
94
|
-
result: unknown;
|
|
95
|
-
/** Number detailing the maximum age of the result in the cache, will be replaced by telemetry eventually */
|
|
96
|
-
maxAge?: number;
|
|
97
|
-
/** Metadata relevant to this request */
|
|
98
|
-
meta?: AdapterRequestMeta;
|
|
99
|
-
};
|
|
100
|
-
export declare type Middleware = ((req: AdapterRequest, reply: FastifyReply, done: HookHandlerDoneFunction) => FastifyReply | void) | ((req: AdapterRequest, reply: FastifyReply) => Promise<FastifyReply | void>);
|
|
101
|
-
export declare type AdapterMiddlewareBuilder = (adapter: Adapter) => Middleware;
|
|
102
|
-
export {};
|
package/util/request.js
DELETED
package/util/request.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"request.js","sourceRoot":"","sources":["../../../src/util/request.ts"],"names":[],"mappings":""}
|
|
@@ -1,21 +0,0 @@
|
|
|
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
|
-
getAll(): T[];
|
|
20
|
-
}
|
|
21
|
-
export {};
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ExpiringSortedSet = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* This class implements a set of unique items, each of which has an expiration timestamp.
|
|
6
|
-
* On reads, items that have expired will be deleted from the set and not returned.
|
|
7
|
-
*
|
|
8
|
-
* @typeParam T - the type of the set entries' values
|
|
9
|
-
*/
|
|
10
|
-
class ExpiringSortedSet {
|
|
11
|
-
constructor() {
|
|
12
|
-
this.map = new Map();
|
|
13
|
-
}
|
|
14
|
-
add(key, value, ttl) {
|
|
15
|
-
this.map.set(key, {
|
|
16
|
-
value,
|
|
17
|
-
expirationTimestamp: Date.now() + ttl,
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
getAll() {
|
|
21
|
-
const results = [];
|
|
22
|
-
const now = Date.now();
|
|
23
|
-
// Since we're iterating, might as well prune here
|
|
24
|
-
for (const [key, entry] of this.map.entries()) {
|
|
25
|
-
if (entry.expirationTimestamp < now) {
|
|
26
|
-
this.map.delete(key); // In theory, this shouldn't happen frequently for feeds
|
|
27
|
-
}
|
|
28
|
-
else {
|
|
29
|
-
results.push(entry.value);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
return results;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
exports.ExpiringSortedSet = ExpiringSortedSet;
|
|
36
|
-
//# sourceMappingURL=expiring-sorted-set.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"expiring-sorted-set.js","sourceRoot":"","sources":["../../../../src/util/subscription-set/expiring-sorted-set.ts"],"names":[],"mappings":";;;AAWA;;;;;GAKG;AACH,MAAa,iBAAiB;IAA9B;QACE,QAAG,GAAG,IAAI,GAAG,EAAqC,CAAA;IAwBpD,CAAC;IAtBC,GAAG,CAAC,GAAW,EAAE,KAAQ,EAAE,GAAW;QACpC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,EAAE;YAChB,KAAK;YACL,mBAAmB,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,GAAG;SACtC,CAAC,CAAA;IACJ,CAAC;IAED,MAAM;QACJ,MAAM,OAAO,GAAQ,EAAE,CAAA;QACvB,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAA;QAEtB,kDAAkD;QAClD,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,EAAE;YAC7C,IAAI,KAAK,CAAC,mBAAmB,GAAG,GAAG,EAAE;gBACnC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA,CAAC,wDAAwD;aAC9E;iBAAM;gBACL,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;aAC1B;SACF;QAED,OAAO,OAAO,CAAA;IAChB,CAAC;CACF;AAzBD,8CAyBC"}
|
|
@@ -1,9 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,19 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,26 +0,0 @@
|
|
|
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 {};
|
|
@@ -1,85 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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,QAAQ;QACd,QAAQ,EAAE,CAAC,UAAU,CAAC;QACtB,UAAU,EAAE;YACV,QAAQ,EAAE;gBACR,IAAI,EAAE,OAAO;gBACb,KAAK,EAAE;oBACL,IAAI,EAAE,QAAQ;oBACd,QAAQ,EAAE,EAAE;iBACb;aACF;SACF;KACF,CAAA;IACD,MAAM,QAAQ,GAAG,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,CAAA;IACpC,IAAI;QACF,MAAM,OAAO,GAAG,cAAc,CAAC,QAAQ,CAAC,CAAA;QACxC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,EAAE,QAAQ,EAAE;YAC5C,MAAM,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,MAAM,IAAI,4CAA4C,CAAC,CAAC,CAAA;SAC9F;QACD,OAAO,EAAE,GAAG,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,CAAA;KACxC;IAAC,OAAO,CAAU,EAAE;QACnB,MAAM,CAAC,IA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