From 9a3cfc8ede0de69cc13bf8a634b30d58989d6314 Mon Sep 17 00:00:00 2001 From: Elena Izaguirre Date: Thu, 11 Nov 2021 17:14:42 +0100 Subject: [PATCH] fix: added a dummy package added a dummy package for tests about install packages from github sources required for #1210 Signed-off-by: Elena Izaguirre --- .../main/json/openapi.json | 192 ++++++++++++++++++ .../generated/openapi/typescript-axios/api.js | 118 +++++++++++ .../openapi/typescript-axios/base.js | 65 ++++++ .../openapi/typescript-axios/common.js | 138 +++++++++++++ .../openapi/typescript-axios/configuration.js | 43 ++++ .../openapi/typescript-axios/index.js | 28 +++ ...prometheus-exporter-metrics-endpoint-v1.js | 70 +++++++ .../main/typescript/index.js | 27 +++ .../main/typescript/index.web.js | 3 + .../typescript/plugin-factory-keychain.js | 20 ++ .../main/typescript/plugin-keychain-memory.js | 117 +++++++++++ .../prometheus-exporter/data-fetcher.js | 11 + .../typescript/prometheus-exporter/metrics.js | 13 ++ .../prometheus-exporter.js | 69 +++++++ .../prometheus-exporter/response.type.js | 3 + .../main/typescript/public-api.js | 49 +++++ .../package.json | 19 ++ 17 files changed, 985 insertions(+) create mode 100644 packages/cactus-cmd-api-server/src/test/resources/cactus-plugin-dummy-javascript/main/json/openapi.json create mode 100644 packages/cactus-cmd-api-server/src/test/resources/cactus-plugin-dummy-javascript/main/typescript/generated/openapi/typescript-axios/api.js create mode 100644 packages/cactus-cmd-api-server/src/test/resources/cactus-plugin-dummy-javascript/main/typescript/generated/openapi/typescript-axios/base.js create mode 100644 packages/cactus-cmd-api-server/src/test/resources/cactus-plugin-dummy-javascript/main/typescript/generated/openapi/typescript-axios/common.js create mode 100644 packages/cactus-cmd-api-server/src/test/resources/cactus-plugin-dummy-javascript/main/typescript/generated/openapi/typescript-axios/configuration.js create mode 100644 packages/cactus-cmd-api-server/src/test/resources/cactus-plugin-dummy-javascript/main/typescript/generated/openapi/typescript-axios/index.js create mode 100644 packages/cactus-cmd-api-server/src/test/resources/cactus-plugin-dummy-javascript/main/typescript/get-prometheus-exporter-metrics/get-prometheus-exporter-metrics-endpoint-v1.js create mode 100644 packages/cactus-cmd-api-server/src/test/resources/cactus-plugin-dummy-javascript/main/typescript/index.js create mode 100644 packages/cactus-cmd-api-server/src/test/resources/cactus-plugin-dummy-javascript/main/typescript/index.web.js create mode 100644 packages/cactus-cmd-api-server/src/test/resources/cactus-plugin-dummy-javascript/main/typescript/plugin-factory-keychain.js create mode 100644 packages/cactus-cmd-api-server/src/test/resources/cactus-plugin-dummy-javascript/main/typescript/plugin-keychain-memory.js create mode 100644 packages/cactus-cmd-api-server/src/test/resources/cactus-plugin-dummy-javascript/main/typescript/prometheus-exporter/data-fetcher.js create mode 100644 packages/cactus-cmd-api-server/src/test/resources/cactus-plugin-dummy-javascript/main/typescript/prometheus-exporter/metrics.js create mode 100644 packages/cactus-cmd-api-server/src/test/resources/cactus-plugin-dummy-javascript/main/typescript/prometheus-exporter/prometheus-exporter.js create mode 100644 packages/cactus-cmd-api-server/src/test/resources/cactus-plugin-dummy-javascript/main/typescript/prometheus-exporter/response.type.js create mode 100644 packages/cactus-cmd-api-server/src/test/resources/cactus-plugin-dummy-javascript/main/typescript/public-api.js create mode 100644 packages/cactus-cmd-api-server/src/test/resources/cactus-plugin-dummy-javascript/package.json diff --git a/packages/cactus-cmd-api-server/src/test/resources/cactus-plugin-dummy-javascript/main/json/openapi.json b/packages/cactus-cmd-api-server/src/test/resources/cactus-plugin-dummy-javascript/main/json/openapi.json new file mode 100644 index 00000000000..15839c5929d --- /dev/null +++ b/packages/cactus-cmd-api-server/src/test/resources/cactus-plugin-dummy-javascript/main/json/openapi.json @@ -0,0 +1,192 @@ +{ + "openapi": "3.0.3", + "info": { + "title": "Hyperledger Cactus Plugin - Keychain Memory ", + "description": "Contains/describes the Hyperledger Cactus Keychain Memory plugin.", + "version": "0.2.0", + "license": { + "name": "Apache 2.0", + "url": "https://www.apache.org/licenses/LICENSE-2.0.html" + } + }, + "components": { + "schemas": { + "GetKeychainEntryRequest": { + "type": "object", + "required": [ + "key" + ], + "additionalProperties": false, + "properties": { + "key": { + "type": "string", + "description": "The key for the entry to get from the keychain.", + "minLength": 1, + "maxLength": 1024, + "nullable": false + } + } + }, + "GetKeychainEntryResponse": { + "type": "object", + "required": [ + "key", + "value" + ], + "properties": { + "key": { + "type": "string", + "description": "The key that was used to retrieve the value from the keychain.", + "minLength": 1, + "maxLength": 1024, + "nullable": false + }, + "value": { + "type": "string", + "description": "The value associated with the requested key on the keychain.", + "minLength": 0, + "maxLength": 10485760, + "nullable": false + } + } + }, + "SetKeychainEntryRequest": { + "type": "object", + "required": [ + "key", + "value" + ], + "additionalProperties": false, + "properties": { + "key": { + "type": "string", + "description": "The key for the entry to set on the keychain.", + "minLength": 1, + "maxLength": 1024, + "nullable": false + }, + "value": { + "type": "string", + "description": "The value that will be associated with the key on the keychain.", + "minLength": 0, + "maxLength": 10485760, + "nullable": false + } + } + }, + "SetKeychainEntryResponse": { + "type": "object", + "required": [ + "key" + ], + "properties": { + "key": { + "type": "string", + "description": "The key that was used to set the value on the keychain.", + "minLength": 1, + "maxLength": 1024, + "nullable": false + } + } + }, + "PrometheusExporterMetricsResponse": { + "type": "string", + "nullable": false + } + }, + "requestBodies": { + "keychain_get_entry_request_body": { + "description": "Request body to obtain a keychain entry via its key", + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/GetKeychainEntryRequest" + } + } + } + }, + "keychain_set_entry_request_body": { + "description": "Request body to write/update a keychain entry via its key", + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/SetKeychainEntryRequest" + } + } + } + } + }, + "responses": { + "keychain_get_entry_200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/GetKeychainEntryResponse" + } + } + } + }, + "keychain_get_entry_400": { + "description": "Bad request. Key must be a string and longer than 0, shorter than 1024 characters." + }, + "keychain_get_entry_401": { + "description": "Authorization information is missing or invalid." + }, + "keychain_get_entry_404": { + "description": "A keychain item with the specified key was not found." + }, + "keychain_get_entry_500": { + "description": "Unexpected error." + }, + "keychain_set_entry_200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/SetKeychainEntryResponse" + } + } + } + }, + "keychain_set_entry_400": { + "description": "Bad request. Key must be a string and longer than 0, shorter than 1024 characters." + }, + "keychain_set_entry_401": { + "description": "Authorization information is missing or invalid." + }, + "keychain_set_entry_500": { + "description": "Unexpected error." + } + } + }, + "paths": { + "/api/v1/plugins/@hyperledger/cactus-plugin-keychain-memory/get-prometheus-exporter-metrics": { + "get": { + "x-hyperledger-cactus": { + "http": { + "verbLowerCase": "get", + "path": "/api/v1/plugins/@hyperledger/cactus-plugin-keychain-memory/get-prometheus-exporter-metrics" + } + }, + "operationId": "getPrometheusMetricsV1", + "summary": "Get the Prometheus Metrics", + "parameters": [], + "responses": { + "200": { + "description": "OK", + "content": { + "text/plain": { + "schema": { + "$ref": "#/components/schemas/PrometheusExporterMetricsResponse" + } + } + } + } + } + } + } + } +} diff --git a/packages/cactus-cmd-api-server/src/test/resources/cactus-plugin-dummy-javascript/main/typescript/generated/openapi/typescript-axios/api.js b/packages/cactus-cmd-api-server/src/test/resources/cactus-plugin-dummy-javascript/main/typescript/generated/openapi/typescript-axios/api.js new file mode 100644 index 00000000000..c73313d5305 --- /dev/null +++ b/packages/cactus-cmd-api-server/src/test/resources/cactus-plugin-dummy-javascript/main/typescript/generated/openapi/typescript-axios/api.js @@ -0,0 +1,118 @@ +"use strict"; +/* tslint:disable */ +/* eslint-disable */ +/** + * Hyperledger Cactus Plugin - Keychain Memory + * Contains/describes the Hyperledger Cactus Keychain Memory plugin. + * + * The version of the OpenAPI document: 0.2.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.DefaultApi = exports.DefaultApiFactory = exports.DefaultApiFp = exports.DefaultApiAxiosParamCreator = void 0; +const axios_1 = __importDefault(require("axios")); +// Some imports not used depending on template conditions +// @ts-ignore +const common_1 = require("./common"); +// @ts-ignore +const base_1 = require("./base"); +/** + * DefaultApi - axios parameter creator + * @export + */ +const DefaultApiAxiosParamCreator = function (configuration) { + return { + /** + * + * @summary Get the Prometheus Metrics + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + getPrometheusMetricsV1: async (options = {}) => { + const localVarPath = `/api/v1/plugins/@hyperledger/cactus-plugin-keychain-memory/get-prometheus-exporter-metrics`; + // use dummy base URL string because the URL constructor only accepts absolute URLs. + const localVarUrlObj = new URL(localVarPath, common_1.DUMMY_BASE_URL); + let baseOptions; + if (configuration) { + baseOptions = configuration.baseOptions; + } + const localVarRequestOptions = Object.assign(Object.assign({ method: 'GET' }, baseOptions), options); + const localVarHeaderParameter = {}; + const localVarQueryParameter = {}; + common_1.setSearchParams(localVarUrlObj, localVarQueryParameter, options.query); + let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = Object.assign(Object.assign(Object.assign({}, localVarHeaderParameter), headersFromBaseOptions), options.headers); + return { + url: common_1.toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + }; +}; +exports.DefaultApiAxiosParamCreator = DefaultApiAxiosParamCreator; +/** + * DefaultApi - functional programming interface + * @export + */ +const DefaultApiFp = function (configuration) { + const localVarAxiosParamCreator = exports.DefaultApiAxiosParamCreator(configuration); + return { + /** + * + * @summary Get the Prometheus Metrics + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async getPrometheusMetricsV1(options) { + const localVarAxiosArgs = await localVarAxiosParamCreator.getPrometheusMetricsV1(options); + return common_1.createRequestFunction(localVarAxiosArgs, axios_1.default, base_1.BASE_PATH, configuration); + }, + }; +}; +exports.DefaultApiFp = DefaultApiFp; +/** + * DefaultApi - factory interface + * @export + */ +const DefaultApiFactory = function (configuration, basePath, axios) { + const localVarFp = exports.DefaultApiFp(configuration); + return { + /** + * + * @summary Get the Prometheus Metrics + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + getPrometheusMetricsV1(options) { + return localVarFp.getPrometheusMetricsV1(options).then((request) => request(axios, basePath)); + }, + }; +}; +exports.DefaultApiFactory = DefaultApiFactory; +/** + * DefaultApi - object-oriented interface + * @export + * @class DefaultApi + * @extends {BaseAPI} + */ +class DefaultApi extends base_1.BaseAPI { + /** + * + * @summary Get the Prometheus Metrics + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof DefaultApi + */ + getPrometheusMetricsV1(options) { + return exports.DefaultApiFp(this.configuration).getPrometheusMetricsV1(options).then((request) => request(this.axios, this.basePath)); + } +} +exports.DefaultApi = DefaultApi; +//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYXBpLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vLi4vLi4vLi4vc3JjL21haW4vdHlwZXNjcmlwdC9nZW5lcmF0ZWQvb3BlbmFwaS90eXBlc2NyaXB0LWF4aW9zL2FwaS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUEsb0JBQW9CO0FBQ3BCLG9CQUFvQjtBQUNwQjs7Ozs7Ozs7OztHQVVHOzs7Ozs7QUFJSCxrREFBaUU7QUFDakUseURBQXlEO0FBQ3pELGFBQWE7QUFDYixxQ0FBNE47QUFDNU4sYUFBYTtBQUNiLGlDQUE0RjtBQW1FNUY7OztHQUdHO0FBQ0ksTUFBTSwyQkFBMkIsR0FBRyxVQUFVLGFBQTZCO0lBQzlFLE9BQU87UUFDSDs7Ozs7V0FLRztRQUNILHNCQUFzQixFQUFFLEtBQUssRUFBRSxVQUFlLEVBQUUsRUFBd0IsRUFBRTtZQUN0RSxNQUFNLFlBQVksR0FBRyw0RkFBNEYsQ0FBQztZQUNsSCxvRkFBb0Y7WUFDcEY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SUFBSSxDQUFDLFFBQVEsQ0FBQyxDQUFDLENBQUM7SUFDbEksQ0FBQztDQUNKO0FBWEQsZ0NBV0MifQ== \ No newline at end of file diff --git a/packages/cactus-cmd-api-server/src/test/resources/cactus-plugin-dummy-javascript/main/typescript/generated/openapi/typescript-axios/base.js b/packages/cactus-cmd-api-server/src/test/resources/cactus-plugin-dummy-javascript/main/typescript/generated/openapi/typescript-axios/base.js new file mode 100644 index 00000000000..7751b4d8cbf --- /dev/null +++ b/packages/cactus-cmd-api-server/src/test/resources/cactus-plugin-dummy-javascript/main/typescript/generated/openapi/typescript-axios/base.js @@ -0,0 +1,65 @@ +"use strict"; +/* tslint:disable */ +/* eslint-disable */ +/** + * Hyperledger Cactus Plugin - Keychain Memory + * Contains/describes the Hyperledger Cactus Keychain Memory plugin. + * + * The version of the OpenAPI document: 0.2.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.RequiredError = exports.BaseAPI = exports.COLLECTION_FORMATS = exports.BASE_PATH = void 0; +// Some imports not used depending on template conditions +// @ts-ignore +const axios_1 = __importDefault(require("axios")); +exports.BASE_PATH = "http://localhost".replace(/\/+$/, ""); +/** + * + * @export + */ +exports.COLLECTION_FORMATS = { + csv: ",", + ssv: " ", + tsv: "\t", + pipes: "|", +}; +/** + * + * @export + * @class BaseAPI + */ +class BaseAPI { + constructor(configuration, basePath = exports.BASE_PATH, axios = axios_1.default) { + this.basePath = basePath; + this.axios = axios; + if (configuration) { + this.configuration = configuration; + this.basePath = configuration.basePath || this.basePath; + } + } +} +exports.BaseAPI = BaseAPI; +; +/** + * + * @export + * @class RequiredError + * @extends {Error} + */ +class RequiredError extends Error { + constructor(field, msg) { + super(msg); + this.field = field; + this.name = "RequiredError"; + } +} +exports.Requi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BS0c7QUFDSCxNQUFhLGFBQWMsU0FBUSxLQUFLO0lBRXBDLFlBQW1CLEtBQWEsRUFBRSxHQUFZO1FBQzFDLEtBQUssQ0FBQyxHQUFHLENBQUMsQ0FBQztRQURJLFVBQUssR0FBTCxLQUFLLENBQVE7UUFEaEMsU0FBSSxHQUFvQixlQUFlLENBQUM7SUFHeEMsQ0FBQztDQUNKO0FBTEQsc0NBS0MifQ== \ No newline at end of file diff --git a/packages/cactus-cmd-api-server/src/test/resources/cactus-plugin-dummy-javascript/main/typescript/generated/openapi/typescript-axios/common.js b/packages/cactus-cmd-api-server/src/test/resources/cactus-plugin-dummy-javascript/main/typescript/generated/openapi/typescript-axios/common.js new file mode 100644 index 00000000000..6b64a2e3c49 --- /dev/null +++ b/packages/cactus-cmd-api-server/src/test/resources/cactus-plugin-dummy-javascript/main/typescript/generated/openapi/typescript-axios/common.js @@ -0,0 +1,138 @@ +"use strict"; +/* tslint:disable */ +/* eslint-disable */ +/** + * Hyperledger Cactus Plugin - Keychain Memory + * Contains/describes the Hyperledger Cactus Keychain Memory plugin. + * + * The version of the OpenAPI document: 0.2.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ +Object.defineProperty(exports, "__esModule", { value: true }); +exports.createRequestFunction = exports.toPathString = exports.serializeDataIfNeeded = exports.setSearchParams = exports.setOAuthToObject = exports.setBearerAuthToObject = exports.setBasicAuthToObject = exports.setApiKeyToObject = exports.assertParamExists = exports.DUMMY_BASE_URL = void 0; +const base_1 = require("./base"); +/** + * + * @export + */ +exports.DUMMY_BASE_URL = 'https://example.com'; +/** + * + * @throws {RequiredError} + * @export + */ +const assertParamExists = function (functionName, paramName, paramValue) { + if (paramValue === null || paramValue === undefined) { + throw new base_1.RequiredError(paramName, `Required parameter ${paramName} was null or undefined when calling ${functionName}.`); + } +}; +exports.assertParamExists = assertParamExists; +/** + * + * @export + */ +const setApiKeyToObject = async function (object, keyParamName, configuration) { + if (configuration && configuration.apiKey) { + const localVarApiKeyValue = typeof configuration.apiKey === 'function' + ? await configuration.apiKey(keyParamName) + : await configuration.apiKey; + object[keyParamName] = localVarApiKeyValue; + } +}; +exports.setApiKeyToObject = setApiKeyToObject; +/** + * + * @export + */ +const setBasicAuthToObject = function (object, configuration) { + if (configuration && (configuration.username || configuration.password)) { + object["auth"] = { username: configuration.username, password: configuration.password }; + } +}; +exports.setBasicAuthToObject = setBasicAuthToObject; +/** + * + * @export + */ +const setBearerAuthToObject = async function (object, configuration) { + if (configuration && configuration.accessToken) { + const accessToken = typeof configuration.accessToken === 'function' + ? await configuration.accessToken() + : await configuration.accessToken; + object["Authorization"] = "Bearer " + accessToken; + } +}; +exports.setBearerAuthToObject = setBearerAuthToObject; +/** + * + * @export + */ +const setOAuthToObject = async function (object, name, scopes, configuration) { + if (configuration && configuration.accessToken) { + const localVarAccessTokenValue = typeof configuration.accessToken === 'function' + ? await configuration.accessToken(name, scopes) + : await configuration.accessToken; + object["Authorization"] = "Bearer " + localVarAccessTokenValue; + } +}; +exports.setOAuthToObject = setOAuthToObject; +/** + * + * @export + */ +const setSearchParams = function (url, ...objects) { + const searchParams = new URLSearchParams(url.search); + for (const object of objects) { + for (const key in object) { + if (Array.isArray(object[key])) { + searchParams.delete(key); + for (const item of object[key]) { + searchParams.append(key, item); + } + } + else { + searchParams.set(key, object[key]); + } + } + } + url.search = searchParams.toString(); +}; +exports.setSearchParams = setSearchParams; +/** + * + * @export + */ +const serializeDataIfNeeded = function (value, requestOptions, configuration) { + const nonString = typeof value !== 'string'; + const needsSerialization = nonString && configuration && configuration.isJsonMime + ? configuration.isJsonMime(requestOptions.headers['Content-Type']) + : nonString; + return needsSerialization + ? JSON.stringify(value !== undefined ? value : {}) + : (value || ""); +}; +exports.serializeDataIfNeeded = serializeDataIfNeeded; +/** + * + * @export + */ +const toPathString = function (url) { + return url.pathname + url.search + url.hash; +}; +exports.toPathString = toPathString; +/** + * + * @export + */ +const createRequestFunction = function (axiosArgs, globalAxios, BASE_PATH, configuration) { + return (axios = globalAxios, basePath = BASE_PATH) => { + const axiosRequestArgs = Object.assign(Object.assign({}, axiosArgs.options), { url: ((configuration === null || configuration === void 0 ? void 0 : configuration.basePath) || basePath) + axiosArgs.url }); + return axios.request(axiosRequestArgs); + }; +}; +exports.createRequestFunction = createRequestFunction; +//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29tbW9uLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vLi4vLi4vLi4vc3JjL21haW4vdHlwZXNjcmlwdC9nZW5lcmF0ZWQvb3BlbmFwaS90eXBlc2NyaXB0LWF4aW9zL2NvbW1vbi50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUEsb0JBQW9CO0FBQ3BCLG9CQUFvQjtBQUNwQjs7Ozs7Ozs7OztHQVVHOzs7QUFJSCxpQ0FBb0Q7QUFHcEQ7OztHQUdHO0FBQ1UsUUFBQSxjQUFjLEdBQUcscUJBQXFCLENBQUE7QUFFbkQ7Ozs7R0FJRztBQUNJLE1BQU0saUJBQWlCLEdBQUcsVUFBVSxZQUFvQixFQUFFLFNBQWlCLEVBQUUsVUFBbUI7SUFDbkcsSUFBSSxVQUFVLEtBQUssSUFBSSxJQUFJLFVBQVUsS0FBSyxTQUFTLEVBQUU7UUFDakQsTUFBTSxJQUFJLG9CQUFhLENBQUMsU0FBUyxFQUFFLHNCQUFzQixTQUFTLHVDQUF1QyxZQUFZLEdBQUcsQ0FBQyxDQUFDO0tBQzdIO0FBQ0wsQ0FBQyxDQUFBO0FBSlksUUFBQSxpQkFBaUIscUJBSTdCO0FBRUQ7OztHQUdHO0FBQ0ksTUFBTSxpQkFBaUIsR0FBRyxLQUFLLFdBQVcsTUFBVyxFQUFFLFlBQW9CLEVBQUUsYUFBNkI7SUFDN0csSUFBSSxhQUFhLElBQUksYUFBYSxDQUFDL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QUFRLEdBQUcsR0FBRyxDQUFDLE1BQU0sR0FBRyxHQUFHLENBQUMsSUFBSSxDQUFBO0FBQy9DLENBQUMsQ0FBQTtBQUZZLFFBQUEsWUFBWSxnQkFFeEI7QUFFRDs7O0dBR0c7QUFDSSxNQUFNLHFCQUFxQixHQUFHLFVBQVUsU0FBc0IsRUFBRSxXQUEwQixFQUFFLFNBQWlCLEVBQUUsYUFBNkI7SUFDL0ksT0FBTyxDQUFDLFFBQXVCLFdBQVcsRUFBRSxXQUFtQixTQUFTLEVBQUUsRUFBRTtRQUN4RSxNQUFNLGdCQUFnQixtQ0FBTyxTQUFTLENBQUMsT0FBTyxLQUFFLEdBQUcsRUFBRSxDQUFDLENBQUEsYUFBYSxhQUFiLGFBQWEsdUJBQWIsYUFBYSxDQUFFLFFBQVEsS0FBSSxRQUFRLENBQUMsR0FBRyxTQUFTLENBQUMsR0FBRyxHQUFDLENBQUM7UUFDNUcsT0FBTyxLQUFLLENBQUMsT0FBTyxDQUFDLGdCQUFnQixDQUFDLENBQUM7SUFDM0MsQ0FBQyxDQUFDO0FBQ04sQ0FBQyxDQUFBO0FBTFksUUFBQSxxQkFBcUIseUJBS2pDIn0= \ No newline at end of file diff --git a/packages/cactus-cmd-api-server/src/test/resources/cactus-plugin-dummy-javascript/main/typescript/generated/openapi/typescript-axios/configuration.js b/packages/cactus-cmd-api-server/src/test/resources/cactus-plugin-dummy-javascript/main/typescript/generated/openapi/typescript-axios/configuration.js new file mode 100644 index 00000000000..d444641b8a2 --- /dev/null +++ b/packages/cactus-cmd-api-server/src/test/resources/cactus-plugin-dummy-javascript/main/typescript/generated/openapi/typescript-axios/configuration.js @@ -0,0 +1,43 @@ +"use strict"; +/* tslint:disable */ +/* eslint-disable */ +/** + * Hyperledger Cactus Plugin - Keychain Memory + * Contains/describes the Hyperledger Cactus Keychain Memory plugin. + * + * The version of the OpenAPI document: 0.2.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ +Object.defineProperty(exports, "__esModule", { value: true }); +exports.Configuration = void 0; +class Configuration { + constructor(param = {}) { + this.apiKey = param.apiKey; + this.username = param.username; + this.password = param.password; + this.accessToken = param.accessToken; + this.basePath = param.basePath; + this.baseOptions = param.baseOptions; + this.formDataCtor = param.formDataCtor; + } + /** + * Check if the given MIME is a JSON MIME. + * JSON MIME examples: + * application/json + * application/json; charset=UTF8 + * APPLICATION/JSON + * application/vnd.company+json + * @param mime - MIME (Multipurpose Internet Mail Extensions) + * @return True if the given MIME is JSON, false otherwise. + */ + isJsonMime(mime) { + const jsonMime = new RegExp('^(application\/json|[^;/ \t]+\/[^;/ \t]+[+]json)[ \t]*(;.*)?$', 'i'); + return mime !== null && (jsonMime.test(mime) || mime.toLowerCase() === 'application/json-patch+json'); + } +} +exports.Configuration = Configuration; +//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29uZmlndXJhdGlvbi5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uLy4uLy4uL3NyYy9tYWluL3R5cGVzY3JpcHQvZ2VuZXJhdGVkL29wZW5hcGkvdHlwZXNjcmlwdC1heGlvcy9jb25maWd1cmF0aW9uLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSxvQkFBb0I7QUFDcEIsb0JBQW9CO0FBQ3BCOzs7Ozs7Ozs7O0dBVUc7OztBQWFILE1BQWEsYUFBYTtJQW1EdEIsWUFBWSxRQUFpQyxFQUFFO1FBQzNDLElBQUksQ0FBQyxNQUFNLEdBQUcsS0FBSyxDQUFDLE1BQU0sQ0FBQztRQUMzQixJQUFJLENBQUMsUUFBUSxHQUFHLEtBQUssQ0FBQyxRQUFRLENBQUM7UUFDL0IsSUFBSSxDQUFDLFFBQVEsR0FBRyxLQUFLLENBQUMsUUFBUSxDQUFDO1FBQy9CLElBQUksQ0FBQyxXQUFXLEdBQUcsS0FBSyxDQUFDLFdBQVcsQ0FBQztRQUNyQyxJQUFJLENBQUMsUUFBUSxHQUFHLEtBQUssQ0FBQyxRQUFRLENBQUM7UUFDL0IsSUFBSSxDQUFDLFdBQVcsR0FBRyxLQUFLLENBQUMsV0FBVyxDQUFDO1FBQ3JDLElBQUksQ0FBQyxZQUFZLEdBQUcsS0FBSyxDQUFDLFlBQVksQ0FBQztJQUMzQyxDQUFDO0lBRUQ7Ozs7Ozs7OztPQVNHO0lBQ0ksVUFBVSxDQUFDLElBQVk7UUFDMUIsTUFBTSxRQUFRLEdBQVcsSUFBSSxNQUFNLENBQUMsK0RBQStELEVBQUUsR0FBRyxDQUFDLENBQUM7UUFDMUcsT0FBTyxJQUFJLEtBQUssSUFBSSxJQUFJLENBQUMsUUFBUSxDQUFDLElBQUksQ0FBQyxJQUFJLENBQUMsSUFBSSxJQUFJLENBQUMsV0FBVyxFQUFFLEtBQUssNkJBQTZCLENBQUMsQ0FBQztJQUMxRyxDQUFDO0NBQ0o7QUEzRUQsc0NBMkVDIn0= \ No newline at end of file diff --git a/packages/cactus-cmd-api-server/src/test/resources/cactus-plugin-dummy-javascript/main/typescript/generated/openapi/typescript-axios/index.js b/packages/cactus-cmd-api-server/src/test/resources/cactus-plugin-dummy-javascript/main/typescript/generated/openapi/typescript-axios/index.js new file mode 100644 index 00000000000..f939cf446ef --- /dev/null +++ b/packages/cactus-cmd-api-server/src/test/resources/cactus-plugin-dummy-javascript/main/typescript/generated/openapi/typescript-axios/index.js @@ -0,0 +1,28 @@ +"use strict"; +/* tslint:disable */ +/* eslint-disable */ +/** + * Hyperledger Cactus Plugin - Keychain Memory + * Contains/describes the Hyperledger Cactus Keychain Memory plugin. + * + * The version of the OpenAPI document: 0.2.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __exportStar = (this && this.__exportStar) || function(m, exports) { + for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); +}; +Object.defineProperty(exports, "__esModule", { value: true }); +__exportStar(require("./api"), exports); +__exportStar(require("./configuration"), exports); +//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi8uLi8uLi9zcmMvbWFpbi90eXBlc2NyaXB0L2dlbmVyYXRlZC9vcGVuYXBpL3R5cGVzY3JpcHQtYXhpb3MvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLG9CQUFvQjtBQUNwQixvQkFBb0I7QUFDcEI7Ozs7Ozs7Ozs7R0FVRzs7Ozs7Ozs7Ozs7O0FBR0gsd0NBQXNCO0FBQ3RCLGtEQUFnQyJ9 \ No newline at end of file diff --git a/packages/cactus-cmd-api-server/src/test/resources/cactus-plugin-dummy-javascript/main/typescript/get-prometheus-exporter-metrics/get-prometheus-exporter-metrics-endpoint-v1.js b/packages/cactus-cmd-api-server/src/test/resources/cactus-plugin-dummy-javascript/main/typescript/get-prometheus-exporter-metrics/get-prometheus-exporter-metrics-endpoint-v1.js new file mode 100644 index 00000000000..3ee7f26a626 --- /dev/null +++ b/packages/cactus-cmd-api-server/src/test/resources/cactus-plugin-dummy-javascript/main/typescript/get-prometheus-exporter-metrics/get-prometheus-exporter-metrics-endpoint-v1.js @@ -0,0 +1,70 @@ +"use strict"; +var __importDefault = + (this && this.__importDefault) || + function (mod) { + return mod && mod.__esModule ? mod : { default: mod }; + }; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.GetPrometheusExporterMetricsEndpointV1 = void 0; +const cactus_common_1 = require("@hyperledger/cactus-common"); +const openapi_json_1 = __importDefault(require("../../json/openapi.json")); +const cactus_core_1 = require("@hyperledger/cactus-core"); +class GetPrometheusExporterMetricsEndpointV1 { + constructor(opts) { + this.opts = opts; + const fnTag = "GetPrometheusExporterMetricsEndpointV1#constructor()"; + cactus_common_1.Checks.truthy(opts, `${fnTag} options`); + cactus_common_1.Checks.truthy(opts.plugin, `${fnTag} options.plugin`); + this.log = cactus_common_1.LoggerProvider.getOrCreate({ + label: "get-prometheus-exporter-metrics-v1", + level: opts.logLevel || "INFO", + }); + } + getAuthorizationOptionsProvider() { + // TODO: make this an injectable dependency in the constructor + return { + get: async () => ({ + isProtected: true, + requiredRoles: [], + }), + }; + } + getExpressRequestHandler() { + return this.handleRequest.bind(this); + } + get oasPath() { + return openapi_json_1.default.paths[ + "/api/v1/plugins/@hyperledger/cactus-plugin-keychain-memory/get-prometheus-exporter-metrics" + ]; + } + getPath() { + return this.oasPath.get["x-hyperledger-cactus"].http.path; + } + getVerbLowerCase() { + return this.oasPath.get["x-hyperledger-cactus"].http.verbLowerCase; + } + getOperationId() { + return this.oasPath.get.operationId; + } + async registerExpress(expressApp) { + await cactus_core_1.registerWebServiceEndpoint(expressApp, this); + return this; + } + async handleRequest(req, res) { + const fnTag = "GetPrometheusExporterMetrics#handleRequest()"; + const verbUpper = this.getVerbLowerCase().toUpperCase(); + this.log.debug(`${verbUpper} ${this.getPath()}`); + try { + const resBody = await this.opts.plugin.getPrometheusExporterMetrics(); + res.status(200); + res.send(resBody); + } catch (ex) { + this.log.error(`${fnTag} failed to serve request`, ex); + res.status(500); + res.statusMessage = ex.message; + res.json({ error: ex.stack }); + } + } +} +exports.GetPrometheusExporterMetricsEndpointV1 = GetPrometheusExporterMetricsEndpointV1; +//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZ2V0LXByb21ldGhldXMtZXhwb3J0ZXItbWV0cmljcy1lbmRwb2ludC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LENBQUM7WUFDdEUsR0FBRyxDQUFDLE1BQU0sQ0FBQyxHQUFHLENBQUMsQ0FBQztZQUNoQixHQUFHLENBQUMsSUFBSSxDQUFDLE9BQU8sQ0FBQyxDQUFDO1NBQ25CO1FBQUMsT0FBTyxFQUFFLEVBQUU7WUFDWCxJQUFJLENBQUMsR0FBRyxDQUFDLEtBQUssQ0FBQyxHQUFHLEtBQUssMEJBQTBCLEVBQUUsRUFBRSxDQUFDLENBQUM7WUFDdkQsR0FBRyxDQUFDLE1BQU0sQ0FBQyxHQUFHLENBQUMsQ0FBQztZQUNoQixHQUFHLENBQUMsYUFBYSxHQUFHLEVBQUUsQ0FBQyxPQUFPLENBQUM7WUFDL0IsR0FBRyxDQUFDLElBQUksQ0FBQyxFQUFFLEtBQUssRUFBRSxFQUFFLENBQUMsS0FBSyxFQUFFLENBQUMsQ0FBQztTQUMvQjtJQUNILENBQUM7Q0FDRjtBQXpFRCx3RkF5RUMifQ== diff --git a/packages/cactus-cmd-api-server/src/test/resources/cactus-plugin-dummy-javascript/main/typescript/index.js b/packages/cactus-cmd-api-server/src/test/resources/cactus-plugin-dummy-javascript/main/typescript/index.js new file mode 100644 index 00000000000..64d61d03240 --- /dev/null +++ b/packages/cactus-cmd-api-server/src/test/resources/cactus-plugin-dummy-javascript/main/typescript/index.js @@ -0,0 +1,27 @@ +"use strict"; +var __createBinding = + (this && this.__createBinding) || + (Object.create + ? function (o, m, k, k2) { + if (k2 === undefined) k2 = k; + Object.defineProperty(o, k2, { + enumerable: true, + get: function () { + return m[k]; + }, + }); + } + : function (o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; + }); +var __exportStar = + (this && this.__exportStar) || + function (m, exports) { + for (var p in m) + if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) + __createBinding(exports, m, p); + }; +Object.defineProperty(exports, "__esModule", { value: true }); +__exportStar(require("./public-api"), exports); +//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi9zcmMvbWFpbi90eXBlc2NyaXB0L2luZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7Ozs7Ozs7OztBQUFBLCtDQUE2QiJ9 diff --git a/packages/cactus-cmd-api-server/src/test/resources/cactus-plugin-dummy-javascript/main/typescript/index.web.js b/packages/cactus-cmd-api-server/src/test/resources/cactus-plugin-dummy-javascript/main/typescript/index.web.js new file mode 100644 index 00000000000..9266b46b265 --- /dev/null +++ b/packages/cactus-cmd-api-server/src/test/resources/cactus-plugin-dummy-javascript/main/typescript/index.web.js @@ -0,0 +1,3 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXgud2ViLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vc3JjL21haW4vdHlwZXNjcmlwdC9pbmRleC53ZWIudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IiJ9 diff --git a/packages/cactus-cmd-api-server/src/test/resources/cactus-plugin-dummy-javascript/main/typescript/plugin-factory-keychain.js b/packages/cactus-cmd-api-server/src/test/resources/cactus-plugin-dummy-javascript/main/typescript/plugin-factory-keychain.js new file mode 100644 index 00000000000..0578c1d89e6 --- /dev/null +++ b/packages/cactus-cmd-api-server/src/test/resources/cactus-plugin-dummy-javascript/main/typescript/plugin-factory-keychain.js @@ -0,0 +1,20 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.PluginFactoryKeychain = void 0; +const uuid_1 = require("uuid"); +const cactus_core_api_1 = require("@hyperledger/cactus-core-api"); +const plugin_keychain_memory_1 = require("./plugin-keychain-memory"); +class PluginFactoryKeychain extends cactus_core_api_1.PluginFactory { + async create( + pluginOptions = { + backend: new Map(), + instanceId: uuid_1.v4(), + keychainId: uuid_1.v4(), + logLevel: "TRACE", + }, + ) { + return new plugin_keychain_memory_1.PluginKeychainMemory(pluginOptions); + } +} +exports.PluginFactoryKeychain = PluginFactoryKeychain; +//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicGx1Z2luLWZhY3Rvcnkta2V5Y2hhaW4uanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi9zcmMvbWFpbi90eXBlc2NyaXB0L3BsdWdpbi1mYWN0b3J5LWtleWNoYWluLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7OztBQUFBLCtCQUFvQztBQUdwQyxrRUFBNkQ7QUFFN0QscUVBR2tDO0FBRWxDLE1BQWEscUJBQXNCLFNBQVEsK0JBSTFDO0lBQ0MsS0FBSyxDQUFDLE1BQU0sQ0FDVixnQkFBOEM7UUFDNUMsT0FBTyxFQUFFLElBQUksR0FBRyxFQUFFO1FBQ2xCLFVBQVUsRUFBRSxTQUFNLEVBQUU7UUFDcEIsVUFBVSxFQUFFLFNBQU0sRUFBRTtRQUNwQixRQUFRLEVBQUUsT0FBTztLQUNsQjtRQUVELE9BQU8sSUFBSSw2Q0FBb0IsQ0FBQyxhQUFhLENBQUMsQ0FBQztJQUNqRCxDQUFDO0NBQ0Y7QUFmRCxzREFlQyJ9 diff --git a/packages/cactus-cmd-api-server/src/test/resources/cactus-plugin-dummy-javascript/main/typescript/plugin-keychain-memory.js b/packages/cactus-cmd-api-server/src/test/resources/cactus-plugin-dummy-javascript/main/typescript/plugin-keychain-memory.js new file mode 100644 index 00000000000..da61af0b628 --- /dev/null +++ b/packages/cactus-cmd-api-server/src/test/resources/cactus-plugin-dummy-javascript/main/typescript/plugin-keychain-memory.js @@ -0,0 +1,117 @@ +"use strict"; +var __importDefault = + (this && this.__importDefault) || + function (mod) { + return mod && mod.__esModule ? mod : { default: mod }; + }; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.PluginKeychainMemory = void 0; +const cactus_common_1 = require("@hyperledger/cactus-common"); +const openapi_json_1 = __importDefault(require("../json/openapi.json")); +const prometheus_exporter_1 = require("./prometheus-exporter/prometheus-exporter"); +const get_prometheus_exporter_metrics_endpoint_v1_1 = require("./get-prometheus-exporter-metrics/get-prometheus-exporter-metrics-endpoint-v1"); +class PluginKeychainMemory { + constructor(opts) { + this.opts = opts; + const fnTag = `${this.className}#constructor()`; + cactus_common_1.Checks.truthy(opts, `${fnTag} arg options`); + cactus_common_1.Checks.truthy( + opts.keychainId, + `${fnTag} arg options.keychainId`, + ); + cactus_common_1.Checks.truthy( + opts.instanceId, + `${fnTag} options.instanceId`, + ); + cactus_common_1.Checks.nonBlankString( + opts.keychainId, + `${fnTag} options.keychainId`, + ); + this.backend = opts.backend || new Map(); + cactus_common_1.Checks.truthy(this.backend, `${fnTag} arg options.backend`); + const level = this.opts.logLevel || "INFO"; + const label = this.className; + this.log = cactus_common_1.LoggerProvider.getOrCreate({ level, label }); + this.instanceId = this.opts.instanceId; + this.prometheusExporter = + opts.prometheusExporter || + new prometheus_exporter_1.PrometheusExporter({ pollingIntervalInMin: 1 }); + cactus_common_1.Checks.truthy( + this.prometheusExporter, + `${fnTag} options.prometheusExporter`, + ); + this.prometheusExporter.startMetricsCollection(); + this.log.info(`Created ${this.className}. KeychainID=${opts.keychainId}`); + this.log.warn( + `Never use ${this.className} in production. ` + + `It does not support encryption. It stores everything in plain text.`, + ); + } + get className() { + return PluginKeychainMemory.CLASS_NAME; + } + getOpenApiSpec() { + return openapi_json_1.default; + } + getPrometheusExporter() { + return this.prometheusExporter; + } + async getPrometheusExporterMetrics() { + const res = await this.prometheusExporter.getPrometheusMetrics(); + this.log.debug(`getPrometheusExporterMetrics() response: %o`, res); + return res; + } + async getOrCreateWebServices(expressApp) { + const { log } = this; + log.info(`Installing web services for plugin ${this.getPackageName()}...`); + const endpoints = []; + { + const opts = { + plugin: this, + logLevel: this.opts.logLevel, + }; + const endpoint = new get_prometheus_exporter_metrics_endpoint_v1_1.GetPrometheusExporterMetricsEndpointV1( + opts, + ); + endpoint.registerExpress(expressApp); + endpoints.push(endpoint); + } + const pkg = this.getPackageName(); + log.info(`Installed web services for plugin ${pkg} OK`, { endpoints }); + return endpoints; + } + getInstanceId() { + return this.instanceId; + } + getKeychainId() { + return this.opts.keychainId; + } + getPackageName() { + return `@hyperledger/cactus-plugin-keychain-memory`; + } + async onPluginInit() { + return; + } + async get(key) { + const value = this.backend.get(key); + if (value) { + return value; + } else { + throw new Error(`Keychain entry for "${key}" not found.`); + } + } + async has(key) { + return this.backend.has(key); + } + async set(key, value) { + this.backend.set(key, value); + this.prometheusExporter.setTotalKeyCounter(this.backend.size); + } + async delete(key) { + this.backend.delete(key); + this.prometheusExporter.setTotalKeyCounter(this.backend.size); + } +} +exports.PluginKeychainMemory = PluginKeychainMemory; +PluginKeychainMemory.CLASS_NAME = "PluginKeychainMemory"; +//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicGx1Z2luLWtleWNoYWluLW1lbW9yeS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uL3NyYy9tYWluL3R5cGVzY3JpcHQvcGx1Z2luLWtleWNoYWluLW1lbW9yeS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7QUFBQSw4REFLb0M7QUFNcEMsd0VBQXVDO0FBRXZDLG1GQUErRTtBQUcvRSwrSUFHdUY7QUFTdkYsTUFBYSxvQkFBb0I7SUFZL0IsWUFBNEIsSUFBa0M7UUFBbEMsU0FBSSxHQUFKLElBQUksQ0FBOEI7UUFDNUQsTUFBTSxLQUFLLEdBQUcsR0FBRyxJQUFJLENBQUMsU0FBUyxnQkFBZ0IsQ0FBQztRQUNoRCxzQkFBTSxDQUFDLE1BQU0sQ0FBQyxJQUFJLEVBQUUsR0FBRyxLQUFLLGNBQWMsQ0FBQyxDQUFDO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BQUssQ0FBQyxHQUFHLENBQUMsR0FBVztRQUNuQixPQUFPLElBQUksQ0FBQyxPQUFPLENBQUMsR0FBRyxDQUFDLEdBQUcsQ0FBQyxDQUFDO0lBQy9CLENBQUM7SUFFRCxLQUFLLENBQUMsR0FBRyxDQUFDLEdBQVcsRUFBRSxLQUFhO1FBQ2xDLElBQUksQ0FBQyxPQUFPLENBQUMsR0FBRyxDQUFDLEdBQUcsRUFBRSxLQUFLLENBQUMsQ0FBQztRQUM3QixJQUFJLENBQUMsa0JBQWtCLENBQUMsa0JBQWtCLENBQUMsSUFBSSxDQUFDLE9BQU8sQ0FBQyxJQUFJLENBQUMsQ0FBQztJQUNoRSxDQUFDO0lBRUQsS0FBSyxDQUFDLE1BQU0sQ0FBQyxHQUFXO1FBQ3RCLElBQUksQ0FBQyxPQUFPLENBQUMsTUFBTSxDQUFDLEdBQUcsQ0FBQyxDQUFDO1FBQ3pCLElBQUksQ0FBQyxrQkFBa0IsQ0FBQyxrQkFBa0IsQ0FBQyxJQUFJLENBQUMsT0FBTyxDQUFDLElBQUksQ0FBQyxDQUFDO0lBQ2hFLENBQUM7O0FBdEhILG9EQXVIQztBQXRId0IsK0JBQVUsR0FBRyxzQkFBc0IsQ0FBQyJ9 diff --git a/packages/cactus-cmd-api-server/src/test/resources/cactus-plugin-dummy-javascript/main/typescript/prometheus-exporter/data-fetcher.js b/packages/cactus-cmd-api-server/src/test/resources/cactus-plugin-dummy-javascript/main/typescript/prometheus-exporter/data-fetcher.js new file mode 100644 index 00000000000..114a300349c --- /dev/null +++ b/packages/cactus-cmd-api-server/src/test/resources/cactus-plugin-dummy-javascript/main/typescript/prometheus-exporter/data-fetcher.js @@ -0,0 +1,11 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.collectMetrics = void 0; +const metrics_1 = require("./metrics"); +async function collectMetrics(keyCount) { + metrics_1.totalKeyCount + .labels(`${metrics_1.K_CACTUS_KEYCHAIN_MEMORY_TOTAL_KEY_COUNT}`) + .set(keyCount.counter); +} +exports.collectMetrics = collectMetrics; +//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZGF0YS1mZXRjaGVyLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vLi4vc3JjL21haW4vdHlwZXNjcmlwdC9wcm9tZXRoZXVzLWV4cG9ydGVyL2RhdGEtZmV0Y2hlci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7QUFFQSx1Q0FHbUI7QUFFWixLQUFLLFVBQVUsY0FBYyxDQUFDLFFBQWtCO0lBQ3JELHVCQUFhO1NBQ1YsTUFBTSxDQUFDLEdBQUcsa0RBQXdDLEVBQUUsQ0FBQztTQUNyRCxHQUFHLENBQUMsUUFBUSxDQUFDLE9BQU8sQ0FBQyxDQUFDO0FBQzNCLENBQUM7QUFKRCx3Q0FJQyJ9 diff --git a/packages/cactus-cmd-api-server/src/test/resources/cactus-plugin-dummy-javascript/main/typescript/prometheus-exporter/metrics.js b/packages/cactus-cmd-api-server/src/test/resources/cactus-plugin-dummy-javascript/main/typescript/prometheus-exporter/metrics.js new file mode 100644 index 00000000000..8b29d5dd9f6 --- /dev/null +++ b/packages/cactus-cmd-api-server/src/test/resources/cactus-plugin-dummy-javascript/main/typescript/prometheus-exporter/metrics.js @@ -0,0 +1,13 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.totalKeyCount = exports.K_CACTUS_KEYCHAIN_MEMORY_TOTAL_KEY_COUNT = void 0; +const prom_client_1 = require("prom-client"); +exports.K_CACTUS_KEYCHAIN_MEMORY_TOTAL_KEY_COUNT = + "cactus_keychain_memory_total_key_count"; +exports.totalKeyCount = new prom_client_1.Gauge({ + registers: [], + name: exports.K_CACTUS_KEYCHAIN_MEMORY_TOTAL_KEY_COUNT, + help: "Total keys present in memory", + labelNames: ["type"], +}); +//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibWV0cmljcy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uL3NyYy9tYWluL3R5cGVzY3JpcHQvcHJvbWV0aGV1cy1leHBvcnRlci9tZXRyaWNzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7OztBQUFBLDZDQUFvQztBQUV2QixRQUFBLHdDQUF3QyxHQUNuRCx3Q0FBd0MsQ0FBQztBQUU5QixRQUFBLGFBQWEsR0FBRyxJQUFJLG1CQUFLLENBQUM7SUFDckMsU0FBUyxFQUFFLEVBQUU7SUFDYixJQUFJLEVBQUUsZ0RBQXdDO0lBQzlDLElBQUksRUFBRSw4QkFBOEI7SUFDcEMsVUFBVSxFQUFFLENBQUMsTUFBTSxDQUFDO0NBQ3JCLENBQUMsQ0FBQyJ9 diff --git a/packages/cactus-cmd-api-server/src/test/resources/cactus-plugin-dummy-javascript/main/typescript/prometheus-exporter/prometheus-exporter.js b/packages/cactus-cmd-api-server/src/test/resources/cactus-plugin-dummy-javascript/main/typescript/prometheus-exporter/prometheus-exporter.js new file mode 100644 index 00000000000..ad213fbb44a --- /dev/null +++ b/packages/cactus-cmd-api-server/src/test/resources/cactus-plugin-dummy-javascript/main/typescript/prometheus-exporter/prometheus-exporter.js @@ -0,0 +1,69 @@ +"use strict"; +var __createBinding = + (this && this.__createBinding) || + (Object.create + ? function (o, m, k, k2) { + if (k2 === undefined) k2 = k; + Object.defineProperty(o, k2, { + enumerable: true, + get: function () { + return m[k]; + }, + }); + } + : function (o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; + }); +var __setModuleDefault = + (this && this.__setModuleDefault) || + (Object.create + ? function (o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); + } + : function (o, v) { + o["default"] = v; + }); +var __importStar = + (this && this.__importStar) || + function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) + for (var k in mod) + if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) + __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; + }; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.PrometheusExporter = void 0; +const prom_client_1 = __importStar(require("prom-client")); +const data_fetcher_1 = require("./data-fetcher"); +const metrics_1 = require("./metrics"); +const metrics_2 = require("./metrics"); +class PrometheusExporter { + constructor(prometheusExporterOptions) { + this.prometheusExporterOptions = prometheusExporterOptions; + this.keyCount = { counter: 0 }; + this.metricsPollingIntervalInMin = + prometheusExporterOptions.pollingIntervalInMin || 1; + this.registry = new prom_client_1.Registry(); + } + setTotalKeyCounter(keyCount) { + this.keyCount.counter = keyCount; + data_fetcher_1.collectMetrics(this.keyCount); + } + async getPrometheusMetrics() { + const result = await this.registry.getSingleMetricAsString( + metrics_1.K_CACTUS_KEYCHAIN_MEMORY_TOTAL_KEY_COUNT, + ); + return result; + } + startMetricsCollection() { + this.registry.registerMetric(metrics_2.totalKeyCount); + prom_client_1.default.collectDefaultMetrics({ register: this.registry }); + } +} +exports.PrometheusExporter = PrometheusExporter; +//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHJvbWV0aGV1cy1leHBvcnRlci5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uL3NyYy9tYWluL3R5cGVzY3JpcHQvcHJvbWV0aGV1cy1leHBvcnRlci9wcm9tZXRoZXVzLWV4cG9ydGVyLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7QUFBQSwyREFBbUQ7QUFFbkQsaURBQWdEO0FBQ2hELHVDQUFxRTtBQUNyRSx1Q0FBMEM7QUFNMUMsTUFBYSxrQkFBa0I7SUFLN0IsWUFDa0IseUJBQXFEO1FBQXJELDhCQUF5QixHQUF6Qix5QkFBeUIsQ0FBNEI7UUFKdkQsYUFBUSxHQUFhLEVBQUUsT0FBTyxFQUFFLENBQUMsRUFBRSxDQUFDO1FBTWxELElBQUksQ0FBQywyQkFBMkI7WUFDOUIseUJBQXlCLENBQUMsb0JBQW9CLElBQUksQ0FBQyxDQUFDO1FBQ3RELElBQUksQ0FBQyxRQUFRLEdBQUcsSUFBSSxzQkFBUSxFQUFFLENBQUM7SUFDakMsQ0FBQztJQUVNLGtCQUFrQixDQUFDLFFBQWdCO1FBQ3hDLElBQUksQ0FBQyxRQUFRLENBQUMsT0FBTyxHQUFHLFFBQVEsQ0FBQztRQUNqQyw2QkFBYyxDQUFDLElBQUksQ0FBQyxRQUFRLENBQUMsQ0FBQztJQUNoQyxDQUFDO0lBRU0sS0FBSyxDQUFDLG9CQUFvQjtRQUMvQixNQUFNLE1BQU0sR0FBRyxNQUFNLElBQUksQ0FBQyxRQUFRLENBQUMsdUJBQXVCLENBQ3hELGtEQUF3QyxDQUN6QyxDQUFDO1FBQ0YsT0FBTyxNQUFNLENBQUM7SUFDaEIsQ0FBQztJQUVNLHNCQUFzQjtRQUMzQixJQUFJLENBQUMsUUFBUSxDQUFDLGNBQWMsQ0FBQyx1QkFBYSxDQUFDLENBQUM7UUFDNUMscUJBQVUsQ0FBQyxxQkFBcUIsQ0FBQyxFQUFFLFFBQVEsRUFBRSxJQUFJLENBQUMsUUFBUSxFQUFFLENBQUMsQ0FBQztJQUNoRSxDQUFDO0NBQ0Y7QUE3QkQsZ0RBNkJDIn0= diff --git a/packages/cactus-cmd-api-server/src/test/resources/cactus-plugin-dummy-javascript/main/typescript/prometheus-exporter/response.type.js b/packages/cactus-cmd-api-server/src/test/resources/cactus-plugin-dummy-javascript/main/typescript/prometheus-exporter/response.type.js new file mode 100644 index 00000000000..bf5cfd519c1 --- /dev/null +++ b/packages/cactus-cmd-api-server/src/test/resources/cactus-plugin-dummy-javascript/main/typescript/prometheus-exporter/response.type.js @@ -0,0 +1,3 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicmVzcG9uc2UudHlwZS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uL3NyYy9tYWluL3R5cGVzY3JpcHQvcHJvbWV0aGV1cy1leHBvcnRlci9yZXNwb25zZS50eXBlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiIifQ== diff --git a/packages/cactus-cmd-api-server/src/test/resources/cactus-plugin-dummy-javascript/main/typescript/public-api.js b/packages/cactus-cmd-api-server/src/test/resources/cactus-plugin-dummy-javascript/main/typescript/public-api.js new file mode 100644 index 00000000000..fe3fd35e553 --- /dev/null +++ b/packages/cactus-cmd-api-server/src/test/resources/cactus-plugin-dummy-javascript/main/typescript/public-api.js @@ -0,0 +1,49 @@ +"use strict"; +var __createBinding = + (this && this.__createBinding) || + (Object.create + ? function (o, m, k, k2) { + if (k2 === undefined) k2 = k; + Object.defineProperty(o, k2, { + enumerable: true, + get: function () { + return m[k]; + }, + }); + } + : function (o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; + }); +var __exportStar = + (this && this.__exportStar) || + function (m, exports) { + for (var p in m) + if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) + __createBinding(exports, m, p); + }; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.createPluginFactory = exports.PluginFactoryKeychain = exports.PluginKeychainMemory = void 0; +__exportStar(require("./generated/openapi/typescript-axios/index"), exports); +var plugin_keychain_memory_1 = require("./plugin-keychain-memory"); +Object.defineProperty(exports, "PluginKeychainMemory", { + enumerable: true, + get: function () { + return plugin_keychain_memory_1.PluginKeychainMemory; + }, +}); +var plugin_factory_keychain_1 = require("./plugin-factory-keychain"); +Object.defineProperty(exports, "PluginFactoryKeychain", { + enumerable: true, + get: function () { + return plugin_factory_keychain_1.PluginFactoryKeychain; + }, +}); +const plugin_factory_keychain_2 = require("./plugin-factory-keychain"); +async function createPluginFactory(pluginFactoryOptions) { + return new plugin_factory_keychain_2.PluginFactoryKeychain( + pluginFactoryOptions, + ); +} +exports.createPluginFactory = createPluginFactory; +//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHVibGljLWFwaS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uL3NyYy9tYWluL3R5cGVzY3JpcHQvcHVibGljLWFwaS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7Ozs7O0FBQUEsNkVBQTJEO0FBRzNELG1FQUdrQztBQUZoQyw4SEFBQSxvQkFBb0IsT0FBQTtBQUd0QixxRUFBa0U7QUFBekQsZ0lBQUEscUJBQXFCLE9BQUE7QUFFOUIsdUVBQWtFO0FBRTNELEtBQUssVUFBVSxtQkFBbUIsQ0FDdkMsb0JBQTJDO0lBRTNDLE9BQU8sSUFBSSwrQ0FBcUIsQ0FBQyxvQkFBb0IsQ0FBQyxDQUFDO0FBQ3pELENBQUM7QUFKRCxrREFJQyJ9 diff --git a/packages/cactus-cmd-api-server/src/test/resources/cactus-plugin-dummy-javascript/package.json b/packages/cactus-cmd-api-server/src/test/resources/cactus-plugin-dummy-javascript/package.json new file mode 100644 index 00000000000..f9b92c4d838 --- /dev/null +++ b/packages/cactus-cmd-api-server/src/test/resources/cactus-plugin-dummy-javascript/package.json @@ -0,0 +1,19 @@ +{ + "name": "@hyperledger/cactus-plugin-dummy-javascript", + "version": "1.0.0-rc.2", + "description": "Dummy package for testing.", + "main": "main/typescript/index.js", + "dependencies": { + "@hyperledger/cactus-common": "1.0.0-rc.2", + "@hyperledger/cactus-core": "1.0.0-rc.2", + "@hyperledger/cactus-core-api": "1.0.0-rc.2", + "axios": "0.21.4", + "express": "4.17.1", + "prom-client": "13.2.0", + "uuid": "8.3.2" + }, + "devDependencies": { + "@types/express": "4.17.13" + } + } + \ No newline at end of file